User Tools

Site Tools


pf:prpldocs:strings

<script type="text/javascript"> function selectText(containerid) { if (document.selection) { var range = document.body.createTextRange(); range.moveToElementText(document.getElementById(containerid)); range.select(); } else if (window.getSelection) { var range = document.createRange(); range.selectNode(document.getElementById(containerid)); window.getSelection().addRange(range); } } </script>   <a href="#" onclick="selectText('selectable')">Select All</a><br/> Save the contents to "Strings.txt"   <div id="selectable">

=CMD
=COMMAND Concat (string string) string
=DESC
Takes the first two items from the stack and concatenates them.
=ENDDESC
=EX 
Trace(Concat("abc" "def")) # Prints "abcdef"
=ENDEX
=ENDCMD

=CMD
=COMMAND Substring (string int int) string
=DESC
String, Arg1: string to find substring from
Int, Arg2: index for the start of the substring (the first character of a string has index 0)
Int, Arg3: length of the substring
TODO
=ENDDESC
=EX 
Trace( Substring("Particle" 1 3)) # Prints "art"
=ENDEX
=ENDCMD

=CMD
=COMMAND StartsWith (string string) bool
=DESC 
Takes two strings from the stack and returns whether the first string starts with the second (case sensitive)
=ENDDESC
=EX
if (StartsWith("Hello there" "Hello"))
    Trace("I opened with hello")
endif
=ENDEX
=ENDCMD

=CMD
=COMMAND EndsWith (string string) bool
=DESC 
Takes two strings from the stack and returns whether the first string ends with the second (case sensitive)
=ENDDESC
=EX
if (EndsWith("Hello there" "there"))
    Trace("I went there")
endif
=ENDEX
=ENDCMD

=CMD
=COMMAND Split (string string) list
=DESC
Takes two strings from the stack and splits the first wherever the second occurs. Returns a list of strings.
=ENDDESC
=EX
Split("Here is a sentence with some words in." " ") ->wordsList
<-wordsList GetListCount 0 do
	Trace(<-wordsList[I])
loop
=ENDEX
=ENDCMD

=CMD
=COMMAND StringToList (string) list
=DESC
Takes a string from the stack and returns the list of characters in the string.
=ENDDESC
=EX
StringToList("Hello human") ->charactersList
<-charactersList GetListCount 0 do
	Trace(<-wordsList[I])
loop
=ENDEX
=ENDCMD

=CMD
=COMMAND ToUpper (string) string
=DESC 
Converts a string to uppercase.
=ENDDESC
=EX 
Trace( ToUpper("knuckle"))
=ENDEX
=ENDCMD

=CMD
=COMMAND ToLower (string) string
=DESC 
Converts a string to lowercase.
=ENDDESC
=EX 
Trace( ToLower("CRACKER"))
=ENDEX
=ENDCMD

=CMD
=COMMAND StringLength (string) int
=DESC 
Returns the number of characters in a string.
=ENDDESC
=EX 
Trace( StringLength ("PRPL")) #Prints 4
=ENDEX
=ENDCMD

=CMD
=COMMAND StringReplace (string string string) string
=DESC 
string ARG1: The string to be searched
string ARG2: The string to search for in ARG1
string ARG3: The string to replace ARG2 with

Searches a string for all instances for another string, and replaces them with a different string.
=ENDDESC
=EX 
Trace(StringReplace ("Where there's a will, there's a way." "will" "way"))
=ENDEX
=ENDCMD

=CMD
=COMMAND CR string
=DESC 
Pushes a carriage return to the stack.
=ENDDESC
=EX 
Trace( Concat (Concat("ABC" CR) "DEF"))
=ENDEX
=ENDCMD

=CMD
=COMMAND LF string
=DESC 
Pushes a line feed to the stack.
=ENDDESC
=EX 
Trace( Concat (Concat("ABC" LF) "DEF"))
=ENDEX
=ENDCMD

</div>

pf/prpldocs/strings.txt · Last modified: 2016/06/24 18:06 by planetfall