Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "zcommon.acs"
- global int 0:strings[];
- function int addString(int string)
- {
- int strSize = StrLen(string) + 1; // gotta remember the null byte at the start
- int index = 0; int ret; int i = 0; int j; int c;
- while (1)
- {
- c = strings[index];
- if (c == 0)
- {
- if (i == 1)
- {
- ret = index;
- }
- i += 1;
- }
- else
- {
- i = 0;
- }
- if (i >= strSize)
- {
- break;
- }
- index += 1;
- }
- for (i = 0; i < strSize; i++)
- {
- j = i + ret;
- strings[j] = GetChar(string, i);
- }
- strings[ret + (strSize-1)] = 0;
- return ret;
- }
- function int getString(int index)
- {
- int ret = "";
- int i = 0; int j; int c;
- while (1)
- {
- j = i + index;
- i += 1;
- c = strings[j];
- if (c == 0)
- {
- break;
- }
- ret = StrParam(s:ret, c:c);
- }
- return ret;
- }
- function void freeString(int index)
- {
- int i = 0; int j; int c;
- while (1)
- {
- j = i + index;
- i += 1;
- c = strings[j];
- if (c == 0)
- {
- break;
- }
- strings[j] = 0;
- }
- }
- script 193 (void)
- {
- int strIndex = addString("potato pie, tell me why.");
- int herp = getString(strIndex);
- print(d:strIndex, s:"\n", s:herp);
- int strIndex2 = addString(StrParam(n:0));
- int derp = getString(strIndex2);
- print(d:strIndex2, s:"\n", s:derp);
- print(s:getString(strIndex));
- freeString(strIndex);
- freeString(strIndex2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement