Builtin Functions

< Previous | Contents | Manuals Home | Boris FX | Next >

Builtin Functions

abs(x) or fabs(x) absolute value

atoi(str) Convert string to an integer value (~ str+0)

atof(str) Convert string to a floating point value (~ str+0)

atan(x) arc-tangent function

atan(y, x) arc-tangent of y/x

binaryinp() Read the current input file as binary, ie with no newline translation on Windows. (Does nothing on macOS and linux.)

ceil(x) smallest integer greater than x

closeinp() Stop reading current file, resume reading earlier file

closeout() Close redirection, output to previous file instead

CopyFile(fromnm, toname, failIfExists) Copies file fromnm to file toname. If

failIfExists is nonzero, then the operation fails if the file already exists. Either way, returns 1 if the operation succeeds, 0 if it does not.

WARNING: Dangerous!

cos(x) cosine function

DateTime(fmt) The current time and date in a user-selected format, see the strftime function on the Microsoft site: http://msdn.microsoft.com/library/default.asp? url=/library/en- us/vccore98/HTML/_crt_strftime.2c_.wcsftime

.asp For example, "%a, %b %d, %Y

%I:%M:%S %p" produces “Tue, Feb 25, 2003 10:19:22 PM”

DeleteFile(fnm) Deletes this file, returns 1/0 success/fail. WARNING: you can clobber any file on your computer!

exit() Stop running this script, immediately.

exp(x) exponential function

explode(str, sep) Breaks string into a list of pieces (strings), originally delimited by a single separator character sep. If the separator character is a space, contiguous runs of white-space characters all count as a single space, and blank fields are not created if the string begins or ends with white space. Space, tab, new-line, and return characters are white space. If the separator character is not a

space, the string is exploded solely based on that character and each additional separator character creates a new output field, even if the separator begins or ends the string.

Return and new line characters are dropped if they end a piece string. Using explode with a non-space separator is intended for comma or semicolon-delimited files.

floor(x) largest integer less than x

fmin(x,y) minimum

fmax(x,y) maximum

getline() Read a line from the current input file, returning a new-line terminated string or an empty string on end-of-file.

IdentityMap(n) Creates a new identity mapping of the integers 1..n, where i is mapped to i. Used to simplify exporters when no mapping is actually needed.

IncrementFileName(fnm) Returns the next filename in sequence after

fnm, by incrementing the numeric portion. index(look_in_here, for_this) Find first 2 nd string in 1st, return zero if not

found

isNull(x) Returns 1 if x is a null (non-existant) object, 0 if it an actual object

length(string) The length in bytes of the string (excluding terminator).

log(x) logarithm function

MatchTemplateWithVars(src, templ, targ [, termin]) Match the source file

name src (typically the SynthEyes scene file name) to a template templ that contains variable names $A-$Z (one upper-case character, always followed by a terminator character). Then substitute the variables into the target string targ. The optional termin string replaces the default terminator characters “.,:;/\\()-_[]{}|<>” (They do NOT include a space, so filenames can.) Other characters must match exactly. Returns the resulting string, or null if there is an error.

Intended to simplify generating structured file names for exports.

Message(msg) Pops up an informational dialog box

openinp(filename) Start reading this file (save read point in current file). Returns 1/0 if OK/not.

openout(filename) Start outputting to this file instead.

WARNING: you can clobber any file on your computer!

pow(x,y) x to the y’th power

printf(format, arguments….) Formatted Unix-style print to output or string.

Supports %c, %d, %x, %X, %f, %g, %e, %s formats.

random() A random number between 0 and 1 rindex(look_in_here, for_this) Find last 2 nd string in 1st, return zero if not

found

round(x) nearest integer

sin(x) sine function

scanf(format, arguments…) Read data from current input file. The

arguments should be variables or attributes that you might find on the left hand side of an assignment (no & required). Supports %s,

%c, %d, %x, %f, %lf, %g, %lg, %[..] and the ‘*’ assignment suppression. Returns the number of variables assigned to.

sprintf(format, arguments….) This is an exact synonym for printf, above, to

prevent inadvertent typos by script writers.

sqrt(x) square root

sscanf(string, format, arguments…) Read data from a string, see scanf for details.

strreplace(needle, repl, haystack) Replace all occurrences of needle with repl in

haystack.

substr(string, start [, count]) If the count is missing, continue to the end of

the string. If start is negative, measure from the end.

system(cmd [,dir[,dontwait]])* Run the command cmd as if from the

command line. WARNING: erroneous system commands can damage or destroy any file in your computer! If present, start in the directory dir, which must include a drive name and full path if present. Dontwait controls whether the system call waits for completion or returns immediately. Returns 0 or 1. See the full description below. (Not available in Demo version.)

tan(x) Tangent function

translate(string, from_chars, to_chars) Translate string, replacing each

character in from_chars to the corresponding character of to_chars. Other characters are unaffected.

typeof(x) A string giving x’s type: null, Double, String, SynTrk, SynObj, etc

YesNoCancel(question) Asks the question, click buttons for “yes”, “no”

 

©2023 Boris FX, Inc. — UNOFFICIAL — Converted from original PDF.