In many of the places that you could specify a variable name, you could also specify an expression. For example instead of numrows you could put
· numrows-1
· (numrows+1)/2
· MIN(numrows,2)
· ROUNDUP(numrows/2)
These are all numeric expressions, but you can also work with strings. For example you can put
· "Chapter " & chaptername
· LEFT(filename,3)
You can make choices using the IF or CHOOSE functions. For example
· IF ( numrows = 0 , 2 , numrows + 1 ) -- means, if the number of rows is zero, use a value of 2, otherwise use the value of numrows + 1.
· CHOOSE ( dayweek , "MON" , "TUE" , "WED" , "THU" , "FRI" ) – means, if dayweek is 1, use the string "MON”, if it is 2 use "TUE" and so on.
You can use the special “fields” that were available in earlier versions for example
· [Doc:NumPages]
· [Doc:FileName] (can be used in expressions such as LEFT ( [Doc:FileName] , 3 )
You can make up arithmetic using a mixture of these things:
· Names (which can contain letters, numbers and underscore only – for example there can’t be a name SIZE-2). Names cannot include accented characters.
· Numbers (including decimal point). Please use decimal point ‘.’ even if you would normally use a comma ‘,’. That is, always use 3.5 but never 3,5 for three and a half.
· Brackets, for example (A*3)/2
· Operators * (multiply), + (add), - (subtract), / (divide). Note that division may create a fractional number, for example 3/2 will be 1.5. To get whole numbers see QUOTIENT and MOD below. Division by zero will produce an error.
· Built in arithmetic functions:
o ABS(x) – the positive value of x, for example ABS(-3.5) is 3.5
o INT(x) – the closest whole number less than x, for example INT(4.5) is 4 and INT(-4.5) is -5. The same as ROUNDDOWN(x,0).
o QUOTIENT(x,y) – divides x by y and returns the whole number. Examples: QUOTIENT(10,3) is 3. QUOTIENT(-10,3) is -3.
o MOD(x,y) – divides x by y and returns the remainer. The answer is negative if y is negative. Examples: MOD(10,3) is 1. MOD(100,10) is 0. MOD(10,-3) is -1.
o MAX(a,b,c,…) – the largest number value in a list. The list can contain numbers, or strings of numbers separated by spaces. For example MAX("2 5","6 7 2") is 7.
o MIN(a,b,c,…) – the smallest number value in a list
o ROUND(x) – rounds x to the nearest whole number. Also ROUND(x,digits) – rounds x to the number of decimal digits given. If x is negative, rounds to powers of 10. Examples: ROUND(123.46,1) is "123.5"; ROUND (123.46,0) is "123"; ROUND (123.46,-1) is "120".
o ROUNDUP(x) or ROUNDUP(x,digits) – rounds up to the nearest whole number (or number of decimal places from digits). Examples: ROUNDUP(2.0) is "2". ROUNDUP(2.01) is "3". ROUNDUP(-1.9) is "-1". ROUNDUP(27.12,1) is "27.2". ROUNDUP(22,-1) is "30".
o ROUNDDOWN(x) or ROUNDDOWN(x,digits) – rounds down to the nearest whole number (or number of decimal places from digits). Examples: ROUNDDOWN(2.0) is "2". ROUNDDOWN(2.01) is "2". ROUNDDOWN(-1.1) is "-2". ROUNDDOWN(27.89,1) is "27.8". ROUNDDOWN(27,-1) is "20".
o RANDBETWEEN(low,high) – a random whole number between low and high (inclusive).
Some commands will need strings, not just numbers. This includes cases like a list of margins: 1.0 2.0 1.0 2.0 is a string, because it isn’t just one number. You can work with strings in these ways:
· String constants like "EXTRA WORDS" or "1.0 2.0". Note that the characters \ and " cannot just be included in a string constant. For \ you need to put \\. For " you need to put either \" or "".
· A number is turned into a string if needed, and a string is turned into a number when needed; there is usually an error if the string can’t be turned to a number when needed.
· The operator & (ampersand) which joins two strings together, for example "EXTRA" & "WORDS" is "EXTRAWORDS". Writing a & b is exactly the same as CONCAT(a,b).
· Built in string functions for joining strings
o CONCAT(string1,string2,string3,…) – joins together a list of strings, for example CONCAT ("ABC",7,"DEF") is "ABC7DEF"
o LIST(string1,string2,string3,…) – like CONCAT but adds a space between each string, for example LIST("ABC",7,"DEF") is "ABC 7 DEF"
o REPT(string,count) – makes a string by repeating a string as many times as you ask. For example REPT("ABC",3) is "ABCABCABC".
· Built in string functions for taking part of a string
o LEFT(string,num) – the first num characters in the string. For example LEFT("EXTRA",2) is "EX".
o RIGHT(string,num) – the last num characters in the string. For example RIGHT("EXTRA",3) is "TRA".
o MID(string,start,num) – num characters from the middle of the string, starting with start – the first character is a start of 1. For example MID("EXTRA",2,3) is "XTR".
o TRIMSPACES(string) – remove all spaces at the start or the end of the string
o INLIST(string,num) – treat the string as a list, separated by any number of spaces. Get an item from the list, where num is 1 for the first item. Spaces at the start and end are ignored. For example INLIST("10 9 8",2) is "9" If there is no such item, returns an empty string.
· Built in string functions for searching in strings
o TEXTAFTER(string,afterstring,instance) – searches for "afterstring" in "string", and returns all the text after "afterstring". If "afterstring" is not found, returns the whole of "string". For example TEXTAFTER("alpha-beta.pdf","-") is "beta.pdf". The “instance” is optional and defaults to 1, returning the text after the first instance of “afterstring”. If instance is greater than 1, the search continues for instance instance of “afterstring”. If instance is less than 0, the search starts at the end, so an “instance” of -1 returns text after the last instance of “afterstring”.
o TEXTBEFORE(string,beforestring,instance) – searches for "beforestring" in "string", and returns all the text before "beforestring". If "beforestring" is not found, returns the whole of "string". For example TEXTBEFORE("alpha-beta.pdf","-") is "alpha". instance defaults to 1 and has the same meaning as in TEXTBEFORE.
o FIND(findstring,instring,startchar) – searches for "findstring" in "instring", starting at character startchar within instring; the first character number is 1. If startchar is omitted it is assumed to be 1. Returns the character number where findstring begins in instring, or 0 if it is not found. The search is case dependent (upper/lower case must match), and there are no wildcard characters. Note: do not search for accented characters like "é" in file names on macOS, as they may not match. Examples:
§ FIND("-42","F-420") = 2.
§ FIND("","Anything",3) is 3.
§ FIND(".PDF","File.pdf") is -1.
§ FIND(".pdf","File.pdf") is 5.
§ FIND("AL","AL-AL",2) is 4.
§ FIND("Zip","Zip") is 1.
§ FIND("Z*","Zip") is -1.
§ MID("ALPHA-BETA",FIND("-","ALPHA-BETA")+1,999) is "BETA"
o CONTAINS(findstring,instring) – searches for "findstring" in "instring; returns "TRUE" if found and "FALSE" otherwise. Equivalent to ( FIND(findstring,instring,1) > 0 )
· Built in string functions for replacing text in strings
o INSERTBEFORE(oldstring,beforestring,insertstring) – searches for "beforestring" in "oldstring". Inserts the string "insertstring" before "beforestring". If " beforestring " is not found, the string "insertstring" is added at the start of "oldstring". Examples: INSERTBEFORE("alpha.pdf",".","-next") is "alpha-next.pdf". INSERTBEFORE ("alpha-beta.pdf","!","gamma") is "gammaalpha-beta.pdf".
o INSERTAFTER(oldstring,afterstring,insertstring) – searches for "afterstring" in "oldstring". Inserts the string "insertstring" after the end of "afterstring. If "afterstring" is not found, the string "insertstring" is added at the end of "oldstring". Examples: INSERTAFTER("alpha-beta.pdf","-","gamma") is "alpha-gammabeta.pdf". INSERTAFTER("alpha-beta.pdf","!","gamma") is "alpha-beta.pdfgamma".
o REPLACE(oldstring,startchar,numchar,newstring) – replaces characters in oldstring with newstring. The first character to replace in oldstring is at startchar (first character is 1). The number of characters to replace is numchar. Examples: REPLACE("abcde",2,3,"-") is "a-e" and REPLACE("first/last",1,5,"new") is "new/last".
· Miscellaneous string functions
o UNICHAR(number) – converts a number to a Unicode character as a string. For example UNICHAR(8364) returns "€", the Euro character.
o UUID() – returns a UUID, a common standard for (almost certainly) unique strings. Each time you call UUID() it will give a different answer. For example UUID() one time returned "03962e5e-fc60-4780-8fd4-12f7f67314dc". The result is always made of letters "a" to "f" and digits separated by dashes. The lengths of each part of the UUID are 8-4-4-4-12. A UUID cannot be used to identity the user or computer that created it.
Booleans are a string with the value "TRUE" or "FALSE". Unlike some other languages, numbers cannot be used instead. The strings can be upper or lower case, so "TRUE", "True" and "true" are equivalent. There is an error if anything other than the specified strings are used. The names TRUE and FALSE do not exist.
· Operators = (equal), <> (not equal), <, >, <= and >= are used to compare numbers or strings
o Where both sides are a valid number, even in a string, the comparison is done using the numeric value. So 1 = 1.0 and "2" = "02" are both the "TRUE".
o Where strings are compared, upper and lower case are ignored, so "Aa" = "aA" is "TRUE".
o This can only be relied upon for unaccented Latin characters. When comparing other alphabets, or accented characters, the results may depend on system settings.
o These alternative forms are allowed: == (two equals signs) for =; != for <>.
· AND(bool1,bool2) – return "TRUE" if both bool1 and bool2 are "TRUE".
· OR(bool1,bool2) – return "TRUE" if either or both bool1 and bool2 are "TRUE".
· NOT(bool1) – swaps "TRUE" to "FALSE" and "FALSE" to "TRUE"
· ISODD(value) – return "TRUE" if the value is a number and is odd, "FALSE" if the value is a number and is even, and gives an error if the value is not a number. If the number is not a whole number, the effect is the same as using INT() first, so ISODD(3.6) is "TRUE" and ISODD(-3.6) is "FALSE". Similarly ISEVEN(value).
· ISNUMBER(value) – return "TRUE" if the value can be understood as a number, "FALSE" otherwise.
· ISBLANK(value) – return "TRUE" if the value is an empty string "". 0 and "FALSE" are not blank.
· BOOL(value) – convert a value to a Boolean as follows. If it is a number, or a string containing a number, then 0 returns "FALSE" and all other values return "TRUE". If it is a non-numeric string, and is "TRUE" or "FALSE", this is used. Otherwise there is an error.
These let you choose among different options.
· CHOOSE(index,option1,option2,option3,…) chooses just one of the options, depending on the index number. If index is 2, for example, option2 is chosen. If index is less than 1, option 1 is chosen. If index is more than the number of options, the last option is chosen.
· IF(test,true_option,false_option) chooses either true_option or false_option, depending on the test. The test must be "FALSE" or "TRUE". For example, IF ( A < 0 , 0 , A ) or IF ( ISEVEN(A) , A , A - 1 )
· JOBNAME() – the name of the current job, often the name of the source file. It comes from one of these sources, highest priority first
o If the command line contains a -jobname value this is used
o If the command reads from a directory, then the directory name (without its parent directory). When Quite Hot Imposing is reading queues, this is the case of a job folder, so the job folder name is used.
o The command reads from a file. The filename (without its parent directory) is used. (If it reads from multiple files, the first is used).
o If the jobname ends .pdf, the .pdf is removed. If a command has multiple sources, the first source is used.
· TARGETPATH() – the full path name (directory and filename) where the result will be written.
· DIRNAME(filestring) – if filestring is a full file name, gives the directory part of the name. This will NOT end in a directory separator (/ or \). If filestring does not contain a directory separator, then filestring is returned unchanged. This only looks at the text, it does not check whether the result is a directory or whether it exists.
· BASENAME(filestring) – if filestring is a full filename, gives the last part of the name, that is the filename without any directory). If filestring does not contain a directory separator, then filestring is returned unchanged. This only looks at the text, it does not check whether the file exists, or whether it is actually a directory.
· BASENAMENOPREFIX(filestring) – like BASENAME, but if the result would start _xxxxx_ (underscore, exactly five letters, underscore), this part is removed. This is useful in Enfocus Switch, where working files often have a prefix in this style added. Note that since a filename with no directory separator is returned unchanged by BASENAME, this function can be used on a plain filename without directory.
· BASENAMENOSUFFIX(filestring) – like BASENAME, but removes the file type, which is everything from the last dot to the end. If there are multiple filetypes, removes only the last one.
· BASENAMENOPREFIXSUFFIX(filestring) – combines BASENAMENOPREFIX and BASENAMENOSUFFIX.
These functions return information on the pages of the current source PDF. If used in a context where there is no specific source PDF, they all return an empty string. They return a string list of numbers, for which the INLIST function might be useful.
· PAGESIZE(frompage, topage,[type]]) returns the size of one or more pages (range from frompage to topage) as a string separated by blanks. Each size is two numbers in the string, in the order width height. For all pages set topage to a large number or -1. The type is a string saying which of the different page sizes to use. The default is "crop" which is the size visible in Acrobat and most other viewers (for an uncropped page it is the original size). Valid types are "crop", "bleed" (bleed exterior), "trim" (bleed interior). Values are returned in points, and the result can be converted to inches, cm or mm using PTIN(), PTCM() or PTMM(). Example: PAGESIZE(2,2,"crop") – returns the page size as cropped in points with 2 decimal places such as "720 612". PTIN(PAGESIZE(2,2,"crop")) would return "10 8.5".
· PAGEWIDTH(frompage,topage,[type]) is like PAGESIZE but returns only the widths. Example: PAGEWIDTH(1,-1,"") returns the widths of all pages in mm, with the default number of decimals. This is convenient for use with MAX and MIN functions. For example, 4 pages mixing landscape and portrait might return "612 720 612 612". In this case MAX(PAGEWIDTH(1,-1,"")) would return 720.
· PAGEHEIGHT(frompage,[topage],[type]) is like PAGEWIDTH but returns a list of heights.
· INPT(x) convert inches to points. For example INPT(2) returns 144. Each of these conversion routines accepts a string listing numbers for example INPT("2 1.5") returns "144 108".
· MMPT(x) convert mm to points
· CMPT(x) convert cm to points
· PTIN(x) convert points to inches
· PTMM(x) convert points to mm
· PTCM(x) convert points to cm
You can use the fields available in stick on text and other places by just including them in square brackets. You can’t make use of the fields which apply only to the current page. Fields that refer to the current file (such as [Doc:NumPages]) cannot be used when reading variables files before the job, but can be used in any Set Variables command. Useful examples may include
· [Doc:FileName] – the filename part only
· [Doc:FileNameNoSuffix] – the filename part only (removing .pdf)
· [Doc:FileNameNoPrefix] – the filename part only (removing a prefix added by Enfocus Switch)
· [Doc:FullFileName] – the complete path name
· [Doc:NumPages] – the number of pages
· [Date:%Y/%m/%d] – the date as yyyy/mm/dd.
· [Info:Title] – the document title from metadata.
· [User:name] – the user variable name. You can just use the name alone without square brackets and User:, except where the name is a number. A name can only be a number if it is set as a “user field”, for example in the Enfocus Switch flow setup. In this case you might use a form like [User:1].
For example [Doc:FileNameNoSuffix] & "-1.pdf" will turn a filename of Extra.pdf into Extra-1.pdf (this doesn’t rename a document, just makes a string).
You can also use a vertical bar "|" in a field. What is after the bar is the default, for example:
· [User:alpha|3] – the variable alpha, or if it not set, the value 3.
· [User:alpha|nothing] – the variable alpha, or if it not set, the string "nothing".
· [User:alpha|] – the variable alpha, or if it not set, the empty string "".
A string in [] brackets which is not recognised and does not contain a vertical bar is left alone, keeping the brackets unchanged. It will be treated as a string including the brackets.