Difference between revisions of "StringToken"
imported>Speedo (→Sample StringTokens: new tokens) |
imported>Speedo m (→Special Codes:) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
__NoTOC__ | __NoTOC__ | ||
'''StringTokens''' are special premade strings, defined internally within [[:Category: Pluggy|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. | '''StringTokens''' are special premade strings, defined internally within [[:Category: Pluggy|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 the special codes beyond -1310. | ||
Generally, '''StringTokens''' will be used with [[StringCat]] when you need to add individual characters onto an existing string. | Generally, '''StringTokens''' will be used with [[StringCat]] when you need to add individual characters onto an existing string. | ||
Line 8: | Line 8: | ||
==Sample StringTokens== | ==Sample StringTokens== | ||
===Special Codes:=== | |||
Code Character | Code Character | ||
-1 Empty String | -1 Empty String | ||
Line 14: | Line 15: | ||
-257 SOH (Start of Heading) | -257 SOH (Start of Heading) | ||
-1310 EOL (End of Line, see [[StringToken#Notes|Notes]]) | -1310 EOL (End of Line, see [[StringToken#Notes|Notes]]) | ||
-9000 Current system date (MM/DD/YYYY) | -9000 Current system date (MM/DD/YYYY) | ||
-9001 Current system time (HH:MM:SS) | -9001 Current system time (HH:MM:SS) | ||
-9010 Current system time-milliseconds (ZZZ) | -9010 Current system time - milliseconds (ZZZ) | ||
-9011 Current system time-seconds (SS) | -9011 Current system time - seconds (SS) | ||
-9012 Current system time-minutes (MM) | -9012 Current system time - minutes (MM) | ||
-9013 Current system time-hours (HH) | -9013 Current system time - hours (HH - 24 hour format) | ||
-9014 Current system date-day (DD) | |||
-9015 Current system date-month (MM) | -9014 Current system date - day (DD) | ||
-9016 Current system date-year (YYYY) | -9015 Current system date - month (MM) | ||
-9016 Current system date - year (YYYY) | |||
-9017 Current system time - hours (HH - 12 hour format) | |||
-9018 Current system time - day phase (AM or PM) | |||
===Characters:=== | |||
<pre> | <pre> | ||
Code Character | Code Character |
Latest revision as of 12:40, 8 April 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 the special codes beyond -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[edit | edit source]
Special Codes:[edit | edit source]
Code Character -1 Empty String -256 /0 (Null Character) -257 SOH (Start of Heading) -1310 EOL (End of Line, see Notes) -9000 Current system date (MM/DD/YYYY) -9001 Current system time (HH:MM:SS) -9010 Current system time - milliseconds (ZZZ) -9011 Current system time - seconds (SS) -9012 Current system time - minutes (MM) -9013 Current system time - hours (HH - 24 hour format) -9014 Current system date - day (DD) -9015 Current system date - month (MM) -9016 Current system date - year (YYYY) -9017 Current system time - hours (HH - 12 hour format) -9018 Current system time - day phase (AM or PM)
Characters:[edit | edit source]
Code Character -32 Space -33 ! -34 " -35 # ... -123 { -124 | -125 } -126 ~
Example[edit | edit source]
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:
- Insert a space between String1 and String2
- Insert an exclamation point after String2
- 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[edit | edit source]
- The StringToken -0 does not exist.
- ASCII code 0 (/0) can be inserted with StringToken -256.
- The StringToken -1 does not correspond to ASCII code 1.
- StringToken -1 is an empty string
- ASCII code 1 (SOH) can be inserted with StringToken -257.
- The following ASCII codes are Control Characters. In general, you won't need to (and shouldn't) use them.
- 2 through 31
- 127 through 159
- -1310 inserts a DOS style End of Line, and so is actually two characters: Carriage Return followed by Line Feed, hex 0x0D0A.
- The StringToken -2000000000 inserts an ASCII art bunny.