AssignableStringVarToken::AssignableStringVarToken(UInt32 _id, UInt32 lbound, UInt32 ubound) : AssignableStringToken(_id, lbound, ubound) { StringVar* strVar = g_StringMap.Get(value.arrID); if (strVar) { upper = (upper > strVar->GetLength()) ? strVar->GetLength() - 1 : upper; substring = strVar->SubString(lower, upper - lower + 1); } }
bool Cmd_sv_SubString_Execute(COMMAND_ARGS) { UInt32 rhStrID = 0; UInt32 startPos = 0; UInt32 howMany = -1; std::string subStr; if (ExtractArgs(EXTRACT_ARGS, &rhStrID, &startPos, &howMany)) { StringVar* rhVar = g_StringMap.Get(rhStrID); if (!rhVar) return true; if (howMany == -1) howMany = rhVar->GetLength() - startPos; subStr = rhVar->SubString(startPos, howMany); } AssignToStringVar(PASS_COMMAND_ARGS, subStr.c_str()); return true; }