/* *** SCRIPT SYMBOL: [File] File::ReadStringBack^0 *** */ static const char* File_ReadStringBack(sc_File *fil) { check_valid_file_handle(fil->handle, "File.ReadStringBack"); if (feof(fil->handle)) { return CreateNewScriptString(""); } int lle = getw(fil->handle); if ((lle >= 20000) || (lle < 1)) quit("!File.ReadStringBack: file was not written by WriteString"); char *retVal = (char*)malloc(lle); fread(retVal, lle, 1, fil->handle); return CreateNewScriptString(retVal, false); }
/* *** SCRIPT SYMBOL: [String] String::Replace^3 *** */ static const char* String_Replace(const char *thisString, const char *lookForText, const char *replaceWithText, bool caseSensitive) { char resultBuffer[STD_BUFFER_SIZE] = ""; int thisStringLen = (int)strlen(thisString); int outputSize = 0; for (int i = 0; i < thisStringLen; i++) { bool matchHere = false; if (caseSensitive) { matchHere = (strncmp(&thisString[i], lookForText, strlen(lookForText)) == 0); } else { matchHere = (strnicmp(&thisString[i], lookForText, strlen(lookForText)) == 0); } if (matchHere) { strcpy(&resultBuffer[outputSize], replaceWithText); outputSize += strlen(replaceWithText); i += strlen(lookForText) - 1; } else { resultBuffer[outputSize] = thisString[i]; outputSize++; } } resultBuffer[outputSize] = 0; return CreateNewScriptString(resultBuffer, true); }
/* *** SCRIPT SYMBOL: [String] String::ReplaceCharAt^2 *** */ static const char* String_ReplaceCharAt(const char *thisString, int index, char newChar) { if ((index < 0) || (index >= (int)strlen(thisString))) quit("!String.ReplaceCharAt: index outside range of string"); char *buffer = (char*)malloc(strlen(thisString) + 1); strcpy(buffer, thisString); buffer[index] = newChar; return CreateNewScriptString(buffer, false); }
/* *** SCRIPT SYMBOL: [String] String::Format^101 *** */ static const char* String_Format(const char *texx, ...) { char displbuf[STD_BUFFER_SIZE]; va_list ap; va_start(ap,texx); my_sprintf(displbuf, get_translation(texx), ap); va_end(ap); return CreateNewScriptString(displbuf); }
/* *** SCRIPT SYMBOL: [String] String::Substring^2 *** */ static const char* String_Substring(const char *thisString, int index, int length) { if (length < 0) quit("!String.Substring: invalid length"); if ((index < 0) || (index > (int)strlen(thisString))) quit("!String.Substring: invalid index"); char *buffer = (char*)malloc(length + 1); strncpy(buffer, &thisString[index], length); buffer[length] = 0; return CreateNewScriptString(buffer, false); }
/* *** SCRIPT SYMBOL: [String] String::Truncate^1 *** */ static const char* String_Truncate(const char *thisString, int length) { if (length < 0) quit("!String.Truncate: invalid length"); if (length >= (int)strlen(thisString)) return thisString; char *buffer = (char*)malloc(length + 1); strncpy(buffer, thisString, length); buffer[length] = 0; return CreateNewScriptString(buffer, false); }
const char* get_text_property_dynamic_string(CustomProperties *cprop, const char *property) { int idx = game.propSchema.findProperty(property); if (idx < 0) quit("!GetTextProperty: no such property found in schema. Make sure you are using the property's name, and not its description, when calling this command."); if (game.propSchema.propType[idx] != PROP_TYPE_STRING) quit("!GetTextProperty: need to use GetProperty for a non-text property"); const char *valtemp = cprop->getPropertyValue(property); if (valtemp == NULL) { valtemp = game.propSchema.defaultValue[idx]; } return CreateNewScriptString(valtemp); }
const char* TextBox_GetText_New(GUITextBox *texbox) { return CreateNewScriptString(texbox->Text); }
const char* IAGSEngine::CreateScriptString(const char *fromText) { return CreateNewScriptString(fromText); }
void * ScriptString::CreateString (const char *fromText) { return (void *) CreateNewScriptString (fromText); }
const char *System_GetVersion() { return CreateNewScriptString(EngineVersion.LongString); }
const char* InventoryItem_GetName_New(ScriptInvItem *invitem) { return CreateNewScriptString(get_translation(game.invinfo[invitem->id].name)); }
/* *** SCRIPT SYMBOL: [ListBox] ListBox::geti_Items *** */ const char* ListBox_GetItems(GUIListBox *listbox, int index) { if ((index < 0) || (index >= listbox->numItems)) quit("!ListBox.Items: invalid index specified"); return CreateNewScriptString(listbox->items[index]); }
const char* Button_GetText_New(GUIButton *butt) { return CreateNewScriptString(butt->text); }
/* *** SCRIPT SYMBOL: [String] String::Copy^0 *** */ static const char* String_Copy(const char *srcString) { return CreateNewScriptString(srcString); }
/* *** SCRIPT SYMBOL: [File] File::ReadRawLineBack^0 *** */ static const char* File_ReadRawLineBack(sc_File *fil) { char readbuffer[MAX_MAXSTRLEN + 1]; File_ReadRawLine(fil, readbuffer); return CreateNewScriptString(readbuffer); }
/* *** SCRIPT SYMBOL: [String] String::UpperCase^0 *** */ static const char* String_UpperCase(const char *thisString) { char *buffer = (char*)malloc(strlen(thisString) + 1); strcpy(buffer, thisString); strupr(buffer); return CreateNewScriptString(buffer, false); }
/* *** SCRIPT SYMBOL: [String] String::Append^1 *** */ static const char* String_Append(const char *thisString, const char *extrabit) { char *buffer = (char*)malloc(strlen(thisString) + strlen(extrabit) + 1); strcpy(buffer, thisString); strcat(buffer, extrabit); return CreateNewScriptString(buffer, false); }
/* *** SCRIPT SYMBOL: [String] String::AppendChar^1 *** */ static const char* String_AppendChar(const char *thisString, char extraOne) { char *buffer = (char*)malloc(strlen(thisString) + 2); sprintf(buffer, "%s%c", thisString, extraOne); return CreateNewScriptString(buffer, false); }