- Quote, Str, List
- UnQuote, Val, UnList
- ToUpper, ToLower
- LenLen, ListLens
- SpecialCharacter, ^
- Sin, Cos
All names of functions are not case sensitive.
Argument of the function shall not be empty i.e. f( ) causes syntax error. However expression in brakets may be evaluated as empty. For example
arg = A=Quote(arg) // A = "" now
Some of the functions have different names ( aliases). Consider first one as a most recommended.
For most of the functions listed here see Hans’s Scripting Book for more info and more examples. ( pp 82-92)
These three different names mean the same function. In a nutshell, function QUOTE returns argument embraced into straight quotes. For example
Quote(53) = "53" Quote(hahaha) = "hahaha"
If argument already contains straight quotes, every ” is replaced with \”
Quote("53") = "\"53\"" Quote(abc"d"ef) = "abc\"d\"ef"
Alternative names of the function:
Str – to be consistent with VB
List- Because it is possible to use this function to encapsulate list of tokens into one token.
List("Red","Green","Blue") = "\"Red\",\"Green\",\"Blue\""
Now you can pass this single token into subroutine or return it from subroutine.
If you are trying to pass just these 3 colors “\”Red\”,\”Green\”,\”Blue\”" is not better then “Red”,”Green”,”Blue”. However if some other information should be concatenated, and the length of the color list is not known in advance, then “\”Red\”,\”Green\”,\”Blue\”" is much better.
It is possible to parse correctly
These three different names mean the same function. This function removes straight quotes from the begin and end of the argument. If first or last char is not a quote error condition is set. If there is escape sequence(s) \”, then ‘\’ before the each quote is removed.
UnQuote("abc\"d\"ef")=abc"d"ef Val("53") = 53 UnList("\"Red\",\"Green\",\"Blue\"") = "Red","Green","Blue"
Truncates everything following the last ‘.’ in the string.
Trunc(3.14) = 3 Trunc(-7.8) = -7 Trunc(first.second.third) = first.second
Warning: Do not apply function trunc to a quoted string.
Trunc("a.b") = "a
This halfquoted string will cause error condition not at the script line containing function TRUNC, but when result will be used in any calculations.
removes trailing zeroes. Argument can be just a number or list of numbers.
Zstrip(12.300,3.4050,-10) = 12.3,3.405,-10
Returns 1 if argument is empty string and 0 otherwise
Returns 1 if argument is ’0′ and 0 otherwise.
This function takes as an argument full path and file name. ( No filenames relative to the current script directory )
Returns 1 if such a file exists, 0 otherwise
Exist("c:\autoexec.bat") = 1 Exist("c:\bogus\bogus.txt") = 0 ( unless this file really exists on some bogus computer)
In curently shipped version of the Script Engine the function EXIST does not work with long file names.
Converts all lower case chars in the argument into upper case and vice versa.
This function requires as an argument 3 parameters separated with commas. First one should be a quoted string. Second should be an integer, indicating beginning of the substring. Note that opening quote does not count and the first char after the quote is char #1. Third parameter also shall be an integer indicating the length of the substring.
Function returns substring as defined by the second and third parameters. Returned string is embraced in quotes.
SubStr("123456",2,2) = "23"
Argument of this function should be a quoted string.
Function Path does its best to convert Windows path to Macintosh and vice versa. Result of the function depends on the platform you are using.
For example, when scripting on Windows,
Path("Plugins:Scripts:MyScript.spt")= "Plugins\Scripts\MyScript.spt" Path("c::temp:Scripts:MyScript.spt")= "c:\temp\Scripts\MyScript.spt" Path(":::Plugins:Scripts:MyScript.spt")= "..\..\Plugins\Scripts\MyScript.spt"
If some computations including path and file name are due, one might consider performing them with ‘:’ instead of ‘\’ to avoid \” – confusion at the end of the quoted expression. After all computations are done, use function Path to convert he result into what Windows expects.
Function returns number of tokens in a list
LEN("Red","Green","Blue") = 3 LEN("\"Red\",\"Green\",\"Blue\"") = 1
Function returns number(s) of chars in every token. Quotes count.
LenLen("Red","Green","Blue") = 5,7,6 LenLen("\"Red\",\"Green\",\"Blue\"") = 28 ( \ before " also counts )
See Hans’s book on p 97. Arguments may use both upper and lower case. Return value is always quoted. Note that ^(DblQt) = “\”".
[Editor's note: digging the pmscript.exe file in hexadecimal viewer, I found this special characters:]
Tab : tabulation CR : carriage return NewLn : new line NBSl : non breaking ... (?) NBHy : non breaking Hyphen (?) PgN : page number EmSp : em space EnSp : en space ThSp : thin space DisHy : discretionary hyphen DblQt : double quote SngQt : single quote Blt : bullet EnDh : en dash EmDh : em dash NBSp : non breaking space eof : not shure if it is special character
When supplied with 2 parameters returns random value equidistributed in the segment defined by parameters. If supplied with just one parameter, function considers 0 as a beginning of the segment.
There is no seed value, sequences of a random numbers are repeatable when reentering the script. See examle in the Hans’s book ( p.91) on how to introduce beter stochastic.
gettime >> ...,...,...,...,...,...,...,T,... loop t=1,T%100 x = rand(100) endloop
Returns chars by their ascii number.
Do not try to obtain comma (,) by ASCII function because such a value shall cause error condition when trying to use it in computations.
It useful to know that ascii number of the straight quote is 92.
Thus expression “c:\temp\”+”test.p65″ will cause an error because \” confusion. At the same time “c:\temp”+quote(ascii(92))+”test.p65″ works fine.
Removes `-’ at the beginning of the of the parameter string.
Abs(-42) = 42 Abs(-abc) = abc
Accept as an argument list of numbers of any length. Returns one of them – maximal or minimal. Behaviour of the functions is not efined for the case of empty argument.
Returns 1 if argument of the argument is a number, 0 oherwise. If string is quoted, then it is not a number.
IsNumber(76) = 1 IsNumber(haha) = 0 Isumber("76")=0
Trigonomeric functions. Accept argument in degrees.
Argument should not exceed pi/2 by absolute value. Returns value in degrees
Natural exponential function; base = e = 2.7182818…. Argument should not exceed 230.
Natural logarithm, base e = 2.7182818…, positive number expected as an argument.
Square root, non negative number expected as an argument.