Guest
May 20, 2012, 4:07 pm UTCHome arrow Commands arrow Wolfscript arrow Strings arrow Wolfscript arrow String Functions
header image
String Functions
Written by Dream Dancer   
Jun 21, 2008 at 10:27 PM

Strings are the native datatype of furbot, unless the function the variable is being used in calls for a number, in which case, the engine preforms a VAL(#variable) on the selected element and uses that instead. There is no checking on whether or not a particular variable contains a valid numeric value before executing math statements on them, if the variable contained a string, say "Hello", and you execute &add #variable 5, then the variable will now contain the results of the math, that is, VAL("Hello") = 0, 0+5=5.

CHAR(CharCode)
0 Char Number
Returns a single character represented by CharCode , very useful for representing characters which are not normally printable or usable, like " for example, the engine will trash that into ' to prevent load errors.
COMPACT()
0 String
Takes the string passed to it and converts it into a packed string, keeping only strict alphanumeric characters. Useful for turning a complex name into a shortname. May fail with certain name structures.
DBTOSTR(String)
0 String To Translate
Takes String and reformats it from the treatment strings get when being used for database ID's. Much reading of DB documentation has revealed that quite a few characters used in Furcadia for names cannot be used properly with database record ID's, this includes  " # ? * & ¦  for starters.
Right now, the translations are   # -> §     " -> '     ' -> +     ¦ -> "SP"   . This will have to improve. But that's for later, currently if you feed &strtodb() a string like: Furre"Name¦#SM" , it will return as Furre+Name §SM+ . Which means this function will convert it back to: Furre'Name¦#SM' , and it's not quite the same, I'm not 100% certain that the server will work correctly with that.
FORMAT(ValueToFormat Format)
0 ValueToFormat
1 FormatString
Extension of VB's Format into WolfScript.
INSTR(Start String1 String2)
0 Start Char
1 Haystack
2 Needle
Finds the position of String2 in String1 starting from Start , Start is NOT optional, and the search mode is vbTextCompare . This results in string comparisons based on a case-insensitive text sort order determined by your system's locale. When the same characters are sorted using vbTextCompare, the following text sort order is produced:
  (A=a) < ( À=à) < (B=b) < (E=e) < (Ê=ê) < (Z=z) < (Ø=ø)  
So ALPHONSE will be found in the string "where is alphonse?".
JOIN Variable WithWhat
0 Destination Variable
1 What To Join
Joins the named Variable with WithWhat. The WithWhat is evaluated before it is added to the end of the Variable, so it is permitted to have a function or another variable here.
EX: &JOIN #result &DBF(#player Title)
EQ: Variable = Variable & WithWhat.
LCASE(String)
0 String To LCase$
Returns the lower case version of String .
LEFT(String Length)
0 String To Use
1 Length Desired
Returns the left Length of String.
LEN(String)
0 String To Use
Returns the number of characters in String.
LTRIM(String)
0 String To Use
Returns a string which the leading spaces have been removed.
MID(String Start Length)
0 String To Use
1 Starting Char
2 Optional Length
Returns a string from Start, of Optional Length characters, or until end of string is reached. If Start is greater than the length of String, an empty string is returned.
MID2(String Start)
0 String To Use
1 Starting Char
To Be Depreciated. Currently returns a string from Start until the end is reached. Use &mid(String Start), future bots may autoconvert this.
REPLACE(Source Find New)
0 String To Use
1 Search String
2 Replacement String
Replaces all occurances of Find in Source with New and returns the results. Case InSensitive,  ALPHONSE = alphonse .
RIGHT(String Length)
0 String To Use
1 Length Desired
Returns the right most Length from String.
RTRIM(String)
0 String To Use
Returns a string in which the trailing spaces have been removed.
SPRINTF(Source %1 ... %9)
0 SourceString
1 %1
2 ...
3 %9
Wonderfully interesting command, will take SourceString, and replace all the %n values in the string with the corresponding value from the parameter list. If said parameter does not exist, will gladly replace it with an empty string. The %n values can be repeated in the source string, each occurance is replaced. Parameters can be either numbers, text, or other functions, function does not care. Returns the resulting formatted string. See the &DBEXECUTE for an example.
STRTODB(String)
0 String To Use
Takes a "normal" string and returns a Database Compatible ID String. See DBTOSTR for details.
STRVAL(Variable)
0 Variable To Evaluate
Returns the value of the variable, kind of useless, considering all variables are strings unless they"re needed as a number.
UCASE(String)
0 String To Use
Returns the upper case version of String .
Last Updated ( Jan 25, 2011 at 09:44 PM )
<Previous
header image