ZoriaRPG

string.txt for ZC 2.55

Nov 25th, 2016
96
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ==========================================================
  2. --- String.zh: string-handling constants and functions ---
  3. ==========================================================
  4.  
  5. //13-JUNE-2016
  6.  
  7. ===============
  8. -- Constants --
  9. ===============
  10.  
  11. * Message ASCII Code
  12. const int MSGC_LINEFEED = 10
  13. * The ASCII value for '\n'
  14.  
  15. * Message Format
  16. const int MF_NONE = 0
  17. const int MF_STRING = 1
  18. const int MF_INT = 2
  19. const int MF_FLOAT = 3
  20. const int MF_NUM = 4
  21. const int MF_PTR = 5
  22. const int MF_CHAR = 6
  23. * Entered directly into 'strcatf' and 'strncatf' as the format type for the
  24. * argument
  25. * Converted (respectively) from the '%n', '%s', '%i', '%f', '%d', '%p' and '%c'
  26. * format arguments in sprintf and printf (via the sprintf_MFCodeToInt function)
  27.  
  28. const int CHAR_*
  29. * A complete map of all ASCII characters.
  30.  
  31. ================================
  32. -- Single Character Functions --
  33. ================================
  34.  
  35. bool isControlCode(int chr)
  36. * Returns true if 'chr' is in the control code range of ascii characters
  37.  
  38. bool isNumber(int chr)
  39. * Returns true if 'chr' is in the range of ascii characters '0' to '9'
  40.  
  41. bool isAlphabetic(int chr)
  42. * Returns true if 'chr' is an alphabetic character
  43.  
  44. bool isAlphaNumeric(int chr)
  45. * Returns true if 'chr' is an alphanumeric character
  46.  
  47. bool isHex(int chr)
  48. * Returns true if 'chr' is in the set { '0'-'9', 'A'-'F' , 'a'-'f' }
  49.  
  50. bool isUpperCase(int chr)
  51. * Returns true if 'chr' is an upper-case character
  52.  
  53. bool isLowerCase(int chr)
  54. * Returns true if 'chr' is a lower-case character
  55.  
  56. int UpperToLower(int chr)
  57. * Converts all upper case characters to lower case, leaving non-alphabetic
  58. * characters unchanged
  59.  
  60. int LowerToUpper(int chr)
  61. * Converts all lower case characters to upper case, leaving non-alphabetic
  62. * characters unchanged
  63.  
  64. int ConvertCase(int chr)
  65. * Converts lower case to upper case and upper case to lower case
  66.  
  67. =========================
  68. -- Memory Manipulation --
  69. =========================
  70.  
  71. * Memory Set
  72. void memset(int ptr[], int value, int n)
  73. * Sets block of memory of size 'n' pointed by 'ptr' to 'value'
  74.  
  75. * Memory Copy
  76. int memcpy(int dest[], int src[], int n)
  77. * Copys block of memory pointed by 'src' of size 'n' to 'dest' and returns
  78. * 'dest'
  79.  
  80. * Memory Move
  81. int memmove(int dest[], int src[], int n)
  82. * As memcpy, but uses a buffer so memory space can overlap
  83.  
  84. * Array Set
  85. void arrayset(int a[], int a0, int a1, int a2,...)
  86. * Assign all elements of array 'a'. Overloaded for up to 16 elements
  87.  
  88. =========================
  89. -- String Manipulation --
  90. =========================
  91.  
  92. * String Copy
  93. void strcpy(int dest[], int src[])
  94. * Copys string 'src' into string 'dest' without checking for overflow in 'dest'
  95. void strncpy(int dest[], int src[], int n)
  96. * As strcpy, but only takes the first 'n' characters from src
  97.  
  98. * Remove Characters
  99. void remchr(int string[])
  100. * Remove all characters starting from pointer 'string'
  101. void remnchr(int string[], int n)
  102. * Remove 'n' characters and shift the rest of the string back to pointer 'string'
  103.  
  104. * String Length
  105. int strlen(int string[])
  106. * Returns the length of string 'string'
  107.  
  108. * String Concatenate
  109. int strcat(int dest[], int src[])
  110. * Appends string 'src' onto string 'dest' (assuming dest has enough extra memory
  111. * allocated to allow the operation)
  112. int strncat(int dest, int src, int n)
  113. * strcat for the first 'n' characters in src
  114.  
  115.  
  116. -- String Searching --
  117. ======================
  118.  
  119. * String Character
  120. int strchr(int string[], int character)
  121. * Returns the position of the first occurence of 'character' in 'string',
  122. * or -1 if none are found
  123.  
  124. * String Reverse Character
  125. int strrchr(int string[], int character)
  126. * Returns the position of the last occurence of 'character' in 'string'
  127. * starting from the end, or -1 if none are found
  128.  
  129. * String Sub-String
  130. int strstr(int string[], int sub[])
  131. * Returns the position of the first occurence of sub-string 'sub' in 'string,
  132. * or -1 if sub is not found
  133.  
  134. * String Span
  135. int strspn(int str[], int keys[])
  136. * Returns the length of characters in 'str' before a character not contained in
  137. * 'keys' is found
  138.  
  139. * String Complement Span
  140. int strcspn(int str[], int keys[])
  141. * Returns the length of characters in 'str' before a character contained in
  142. * 'keys' is found
  143.  
  144.  
  145. -- String Comparison --
  146. =======================
  147.  
  148. * String Compare
  149. int strcmp(int str1[], int str2[])
  150. * Iterates through str1 and str2 until a character is found which is not the same in
  151. * both strings, and then returns > 0 if the character is larger in str1, and < 0 if it is
  152. * larger in str2. Returns 0 if the strings are equal
  153. int strncmp(int str1[], int str2[], int n)
  154. * strcmp up to 'n' characters
  155.  
  156.  
  157. -- Converting between variables and strings --
  158. ==============================================
  159.  
  160. * ASCII to Integer
  161. int atoi(int string[])
  162. * Returns the decimal integer pointed by 'string'
  163.  
  164. * Integer Length
  165. int ilen(int string[])
  166. * Returns the length of characters of the decimal integer pointed by 'string'
  167.  
  168. * Hexadecimal ASCII to Integer
  169. int xtoi(int string[])
  170. * Returns the (positive) hexadecimal integer pointed by 'string'
  171.  
  172. * Hexadecimal Length
  173. int xlen(int string[])
  174. * Returns the length of characters of the (positive) hexadecimal integer pointed by 'string'
  175.  
  176. * ASCII to Float
  177. float atof(int string[])
  178. * Returns the floating point number pointed by 'string'
  179.  
  180. * Float Length
  181. int flen(int string[])
  182. * Returns the length of characters of the floating point number pointed by 'string'
  183.  
  184. * ASCII to Number
  185. float aton(int string[])
  186. * Returns the number pointed by 'string', calling either atoi or atof depending on context
  187.  
  188. * Number Length
  189. int nlen(int string[])
  190. * Returns the length of characters of the number pointed by 'string', calling either
  191. * ilen or flen depending on context
  192.  
  193. * Integer to ASCII
  194. int itoa(int string[], int num)
  195. * Places integer 'num' into string 'string' without checking for overflow,
  196. * and returns the number of characters used
  197.  
  198. * Float to ASCII
  199. int ftoa(int string[], float num, bool printall)
  200. * Places float 'num' into string 'string' without checking for overflow,
  201. * and returns the number of characters used. If 'printall' is true, it will add 4 decimal places
  202. * regardless of the most significant digit
  203.  
  204. * Number to ASCII
  205. int ntoa(int string[], float num)
  206. * Checks whether 'num' is an integer or not, and calls the appropriate function
  207.  
  208.  
  209. -- String Formatting --
  210. =======================
  211.  
  212. * String Concatenate Format
  213. int strcatf(int dest[], int arg, int format)
  214. * Appends 'arg' onto 'dest' as the MF_ constant passed into 'format'
  215. int strncatf(int dest[], int arg, int format, int n)
  216. * As strcatf, using only 'n' characters of 'arg'
  217.  
  218. * String Print Format
  219. void sprintf(int ret[], int formatstr[], int a0, int a1, int a2,...)
  220. * Prints string 'formatstr' into 'ret' according to the arguments inputted (see C function for reference),
  221. * returning the number of characters used. Does not check for overflow in 'ret'
  222. * Overloaded up to a maximum of 16 arguments. Enter the right number of arguments for your format string;
  223. * there is (currently) no way to check how many arguments have been entered or of what type they are
  224. * Currently supported arguments:
  225. * '%s' - String
  226. * '%i' - Integer
  227. * '%f' - Float
  228. * '%d' - Number (Integer/Float depending on context)
  229. * '%n' - Nothing
  230. * '%p' - Pointer Address
  231. * '%c' - Single character
  232. * '%x' - Hexadecimal Integer (lower case)
  233. * '%X' - Hexadecimal Integer (upper case)
  234. * '\n' places a line feed ASCII character into the string
  235.  
  236. * Print Format
  237. void printf(int formatstr[], int a0, int a1, int a2,...)
  238. * Uses a buffer to print the results of sprintf(formatstr,...) straight to allegro.log
  239. * Overloaded up to a maximum of 16 arguments
  240.  
  241. ================================================
  242. -- string.zh Changes and Additions ( 2.50.2 ) --
  243. ================================================
  244. As of this version, string.zh is a base include with std.zh. You no longer need to call it separately, as it
  245. is imported directly from the main std.zh file. If this poses a problem for you, you may comment out that
  246. import directive instruction.
  247.  
  248. //Constants for string.zh
  249.  
  250. const int CHAR_*
  251. * ASCII CHaratcers 0 to 255
  252.  
  253. //New Functions for string.zh
  254.  
  255. bool isSpace(int chr)
  256. * Returns true if 'chr' is a space.
  257.  
  258. bool isVowel(int chr)
  259. * Returns true if 'chr' is a vowel (a, e, i, o , u, A, E, I, O, U)
  260.  
  261. bool ContainsChar(int chr, int buffer)
  262. * Returns true is string 'buffewr' contains the character 'chr'.
  263.  
  264. int ContainsCharPos(int chr, int buffer)
  265. * Returns the index position of the first occurrence of charcter 'chr' in string 'buffer'.
  266. * Returns -1 if the char was not present.
  267.  
  268. int NumCharsOf(int str, int chr)
  269. * Returns the number of chracters of a given type in a specified string.
  270.  
  271. int ReturnStringCharPos(int str, int chr)
  272. * Returns the index of the first character matching 'chr', starting at index 0.
  273.  
  274. int IsChar(int chr)
  275. * Returns the numeric value of chr constant.
  276.  
  277. bool IsChar(int chr, int compare){
  278. * Returns true if character chr is identical to the value specified as 'compare'.
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×