User Tools

Site Tools


pf:prpldocs:strings

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
pf:prpldocs:strings [2016/06/23 17:19] virgilwpf:prpldocs:strings [2025/02/14 14:57] (current) – external edit 127.0.0.1
Line 20: Line 20:
 </html> </html>
 <code> <code>
 +=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 =CMD
-=COMMAND TODO +=COMMAND Substring (string int int) string 
-=DESC +=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 TODO
 =ENDDESC =ENDDESC
 =EX  =EX 
-TODO+Trace( Substring("Particle" 1 3)) # Prints "art"
 =ENDEX =ENDEX
 =ENDCMD =ENDCMD
  
-</code>+=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</code>
 <html></div></html> <html></div></html>
pf/prpldocs/strings.1466702371.txt.gz · Last modified: 2025/02/14 14:56 (external edit)