Difference between revisions of "StringToken"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Speedo
(Deleted incorrect note)
imported>Speedo
Line 12: Line 12:
Code    Character
Code    Character
-1      Empty String
-1      Empty String
-256    /0 (Null Character)
-257    SOH (Start of Heading)
-1310    EOL (End of Line, see Notes)
-1310    EOL (End of Line, see Notes)
</pre>
</pre>
Line 18: Line 20:
<pre>
<pre>
Code    Character
Code    Character
-10      LF (Line Feed)
-32      Space
-32      Space
-33      !
-33      !
Line 24: Line 25:
-35      #
-35      #
...
...
-123    {
-124    |
-124    |
-125    }
-125    }
Line 29: Line 31:
</pre>
</pre>


A full list of ASCII codes can be found [http://www.asciitable.com/ here].  At present Pluggy supports codes only up to -126.
[http://en.wikipedia.org/wiki/ISO_8859-1 Full list of ASCII codes]


==Example==
==Example==

Revision as of 01:26, 29 February 2008


StringTokens are special premade strings, defined internally within Pluggy, which can be used with any Pluggy string function where the function isn't going to modify the string. Each token represents a single character, with the exception of -1 and -1310.

Generally, StringTokens will be used with StringCat when you need to add individual characters onto an existing string.

Most StringTokens are simply negative ASCII codes.

Sample StringTokens

Special Codes:

Code    Character
-1       Empty String
-256     /0 (Null Character)
-257     SOH (Start of Heading)
-1310    EOL (End of Line, see Notes)

Characters:

Code    Character
-32      Space
-33      !
-34      "
-35      #
...
-123     {
-124     |
-125     }
-126     ~

Full list of ASCII codes

Example

We have three strings:

  • String1 containing "Hello"
  • String2 containing "World"
  • String3 containing "This is how you use StringTokens!"

And we want to combine them into a single string that we can use to write the following to a text file:

Hello World!

This is how you use StringTokens!

Besides simply combining the three seperate strings, we're going to have to do several additional things:

  1. Insert a space between String1 and String2
  2. Insert an exclamation point after String2
  3. Insert a blank line after the exclamation point and before String3 (will require two back-to-back EOL's)

We can use StringCat together with StringTokens to combine everything in a single operation, without needing to create, set, or worry about destroying additional strings:

StringCat newString String1 -32 String2 -33 -1310 -1310 String3

Notes

  • -1310 inserts a DOS style End of Line, and so is actually two characters: Carriage Return followed by Line Feed, hex 0x0D0A.