{"id":1787,"date":"2010-11-28T15:51:41","date_gmt":"2010-11-28T18:51:41","guid":{"rendered":"http:\/\/meiradarocha.jor.br\/news\/?p=1787"},"modified":"2010-12-03T00:30:58","modified_gmt":"2010-12-03T03:30:58","slug":"pagemaker-scripting-language-functions","status":"publish","type":"post","link":"https:\/\/meiradarocha.jor.br\/news\/2010\/11\/28\/pagemaker-scripting-language-functions\/","title":{"rendered":"PageMaker Scripting Language: functions"},"content":{"rendered":"<p><a href=\"http:\/\/meiradarocha.jor.br\/news\/wp-content\/uploads\/2010\/11\/pagemaker-splash2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-medium wp-image-1788\" title=\"pagemaker-splash\" src=\"http:\/\/meiradarocha.jor.br\/news\/wp-content\/uploads\/2010\/11\/pagemaker-splash2-300x212.jpg\" alt=\"\" width=\"300\" height=\"212\" srcset=\"https:\/\/meiradarocha.jor.br\/news\/wp-content\/uploads\/2010\/11\/pagemaker-splash2-300x212.jpg 300w, https:\/\/meiradarocha.jor.br\/news\/wp-content\/uploads\/2010\/11\/pagemaker-splash2-150x106.jpg 150w, https:\/\/meiradarocha.jor.br\/news\/wp-content\/uploads\/2010\/11\/pagemaker-splash2.jpg 493w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><strong>Dr. Vladimir Samarskiy<\/strong><\/p>\n<address><small>Adobe Systems Corporation<\/small><\/address>\n<p><a href=\"http:\/\/www.oz.net\/~vsamarsk\/Functions.htm\">[Artigo original<\/a>]<\/p>\n<ul>\n<li><a href=\"#432\">Quote, Str, List<\/a><\/li>\n<li><a href=\"#1461\">UnQuote, Val, UnList<\/a><\/li>\n<li><a href=\"#1857\">Trunc<\/a><\/li>\n<li><a href=\"#2382\">Empty<\/a><\/li>\n<li><a href=\"#2442\">Not<\/a><\/li>\n<li><a href=\"#2492\">Exist<\/a><\/li>\n<li><a href=\"#2896\">ToUpper, ToLower<\/a><\/li>\n<li><a href=\"#2991\">SubStr<\/a><\/li>\n<li><a href=\"#3493\">Path<\/a><\/li>\n<li><a href=\"#4228\">Len<\/a><\/li>\n<li><a href=\"#4352\">LenLen, ListLens<\/a><\/li>\n<li><a href=\"#4549\">SpecialCharacter, ^<\/a><\/li>\n<li><a href=\"#4698\">Rand<\/a><\/li>\n<li><a href=\"#5154\">ASCII<\/a><\/li>\n<li><a href=\"#5583\">Abs<\/a><\/li>\n<li><a href=\"#5678\">Max,Min<\/a><\/li>\n<li><a href=\"#5854\">IsNumber<\/a><\/li>\n<li><a href=\"#6034\">Sin, Cos<\/a><\/li>\n<li><a href=\"#6095\">Arctan<\/a><\/li>\n<li><a href=\"#6178\">Exp<\/a><\/li>\n<li><a href=\"#6269\">Log<\/a><\/li>\n<li><a href=\"#6356\">Sqrt<\/a><\/li>\n<\/ul>\n<p>All names of functions are not case sensitive.<\/p>\n<p>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<\/p>\n<pre>arg =\r\nA=Quote(arg)\r\n\/\/ A = \"\" now<\/pre>\n<p>Some of the functions have different names ( aliases). Consider first one as a most recommended.<\/p>\n<p>For most of the functions listed here see Hans&#8217;s Scripting Book for more info and more examples. ( pp 82-92)<\/p>\n<h3><a name=\"432\"><\/a><strong>Quote, Str, List<\/strong><\/h3>\n<p>These three different names mean the same function. In a nutshell, function QUOTE returns argument embraced into straight quotes. For example<\/p>\n<pre>Quote(53) = \"53\"\r\nQuote(hahaha) = \"hahaha\"<\/pre>\n<p>If argument already contains straight quotes, every &#8221; is replaced with \\&#8221;<\/p>\n<pre>Quote(\"53\") = \"\\\"53\\\"\"\r\nQuote(abc\"d\"ef) = \"abc\\\"d\\\"ef\"<\/pre>\n<p>Alternative names of the function:<\/p>\n<p>Str &#8211; to be consistent with VB<\/p>\n<p>List- Because it is possible to use this function to encapsulate list of tokens into one token.<\/p>\n<p>Example:<\/p>\n<pre>List(\"Red\",\"Green\",\"Blue\") = \"\\\"Red\\\",\\\"Green\\\",\\\"Blue\\\"\"<\/pre>\n<p>Now you can pass this single token into subroutine or return it from subroutine.<\/p>\n<p>If you are trying to pass just these 3 colors &#8220;\\&#8221;Red\\&#8221;,\\&#8221;Green\\&#8221;,\\&#8221;Blue\\&#8221;&#8221; is not better then &#8220;Red&#8221;,&#8221;Green&#8221;,&#8221;Blue&#8221;. However if some other information should be concatenated, and the length of the color list is not known in advance, then &#8220;\\&#8221;Red\\&#8221;,\\&#8221;Green\\&#8221;,\\&#8221;Blue\\&#8221;&#8221; is much better.<\/p>\n<p>It is possible to parse correctly<\/p>\n<p>&#8220;\\&#8221;Red\\&#8221;,\\&#8221;Green\\&#8221;,\\&#8221;Blue\\&#8221;&#8221;,&#8221;TRUE&#8221;<\/p>\n<p>but not<\/p>\n<p>&#8220;Red&#8221;,&#8221;Green&#8221;,&#8221;Blue&#8221;,&#8221;TRUE&#8221;.<\/p>\n<h3><a name=\"1461\"><\/a><strong>UnQuote, Val, UnList<\/strong><\/h3>\n<p>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) \\&#8221;, then &#8216;\\&#8217; before the each quote is removed.<\/p>\n<pre>UnQuote(\"abc\\\"d\\\"ef\")=abc\"d\"ef\r\nVal(\"53\") = 53\r\nUnList(\"\\\"Red\\\",\\\"Green\\\",\\\"Blue\\\"\") = \"Red\",\"Green\",\"Blue\"<\/pre>\n<h3><a name=\"1857\"><\/a><strong>Trunc<\/strong><\/h3>\n<p>Truncates everything following the last &#8216;.&#8217; in the string.<\/p>\n<p>For example<\/p>\n<pre>Trunc(3.14) = 3\r\nTrunc(-7.8) = -7\r\nTrunc(first.second.third) = first.second<\/pre>\n<p>Warning: Do not apply function trunc to a quoted string.<\/p>\n<p>For example<\/p>\n<pre>Trunc(\"a.b\") = \"a<\/pre>\n<p>This halfquoted string will cause error condition not at the script line containing function TRUNC, but when result will be used in any calculations.<\/p>\n<p><strong>Zstrip<\/strong><\/p>\n<p>removes trailing zeroes. Argument can be just a number or list of numbers.<\/p>\n<p>Example:<\/p>\n<pre>Zstrip(12.300,3.4050,-10) = 12.3,3.405,-10<\/pre>\n<h3><a name=\"2382\"><\/a><strong>Empty<\/strong><\/h3>\n<p>Returns 1 if argument is empty string and 0 otherwise<\/p>\n<h3><a name=\"2442\"><\/a><strong>Not<\/strong><\/h3>\n<p>Returns 1 if argument is &#8216;0&#8217; and 0 otherwise.<\/p>\n<h3><a name=\"2492\"><\/a><strong>Exist<\/strong><\/h3>\n<p>This function takes as an argument full path and file name. ( No filenames relative to the current script directory )<\/p>\n<p>Returns 1 if such a file exists, 0 otherwise<\/p>\n<p>For example:<\/p>\n<pre>Exist(\"c:\\autoexec.bat\") = 1\r\nExist(\"c:\\bogus\\bogus.txt\") = 0 ( unless this file really exists on some bogus computer)<\/pre>\n<p>In curently shipped version of the Script Engine the function EXIST does not work with long file names.<\/p>\n<h3><a name=\"2896\"><\/a><strong>ToUpper, ToLower<\/strong><\/h3>\n<p>Converts all lower case chars in the argument into upper case and vice versa.<\/p>\n<h3><a name=\"2991\"><\/a><strong>SubStr<\/strong><\/h3>\n<p>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.<\/p>\n<p>Function returns substring as defined by the second and third parameters. Returned string is embraced in quotes.<\/p>\n<p>Example<\/p>\n<pre>SubStr(\"123456\",2,2) = \"23\"<\/pre>\n<h3><a name=\"3493\"><\/a><strong>Path<\/strong><\/h3>\n<p>Argument of this function should be a quoted string.<\/p>\n<p>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.<\/p>\n<p>For example, when scripting on Windows,<\/p>\n<pre>Path(\"Plugins:Scripts:MyScript.spt\")= \"Plugins\\Scripts\\MyScript.spt\"\r\nPath(\"c::temp:Scripts:MyScript.spt\")= \"c:\\temp\\Scripts\\MyScript.spt\"\r\nPath(\":::Plugins:Scripts:MyScript.spt\")= \"..\\..\\Plugins\\Scripts\\MyScript.spt\"<\/pre>\n<p>If some computations including path and file name are due, one might consider performing them with &#8216;:&#8217; instead of &#8216;\\&#8217; to avoid \\&#8221; &#8211; confusion at the end of the quoted expression. After all computations are done, use function Path to convert he result into what Windows expects.<\/p>\n<h3><a name=\"4228\"><\/a><strong>Len<\/strong><\/h3>\n<p>Function returns number of tokens in a list<\/p>\n<p>Example<\/p>\n<pre>LEN(\"Red\",\"Green\",\"Blue\") = 3\r\nLEN(\"\\\"Red\\\",\\\"Green\\\",\\\"Blue\\\"\") = 1<\/pre>\n<h3><a name=\"4352\"><\/a><strong>LenLen, ListLens<\/strong><\/h3>\n<p>Function returns number(s) of chars in every token. Quotes count.<\/p>\n<p>Example<\/p>\n<pre>LenLen(\"Red\",\"Green\",\"Blue\") = 5,7,6\r\nLenLen(\"\\\"Red\\\",\\\"Green\\\",\\\"Blue\\\"\") = 28 ( \\ before \" also counts )<\/pre>\n<h3><a name=\"4549\"><\/a><strong>SpecialCharacter, ^<\/strong><\/h3>\n<p>See Hans&#8217;s book on p 97. Arguments may use both upper and lower case. Return value is always quoted. Note that ^(DblQt) = &#8220;\\&#8221;&#8221;.<\/p>\n<p>[Editor&#8217;s note: digging the <strong>pmscript.exe<\/strong> file in hexadecimal viewer, I found this special characters:]<\/p>\n<pre>Tab   : tabulation\r\nCR    : carriage return\r\nNewLn : new line\r\nNBSl  : non breaking ... (?)\r\nNBHy  : non breaking Hyphen (?)\r\nPgN   : page number\r\nEmSp  : em space\r\nEnSp  : en space\r\nThSp  : thin space\r\nDisHy : discretionary hyphen\r\nDblQt : double quote\r\nSngQt : single quote\r\nBlt   : bullet\r\nEnDh  : en dash\r\nEmDh  : em dash\r\nNBSp  : non breaking space\r\neof   : not shure if it is special character\r\n<\/pre>\n<h3><a name=\"4698\"><\/a><strong>Rand<\/strong><\/h3>\n<p>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.<\/p>\n<p>There is no seed value, sequences of a random numbers are repeatable when reentering the script. See examle in the Hans&#8217;s book ( p.91) on how to introduce beter stochastic.<\/p>\n<pre>gettime &gt;&gt; ...,...,...,...,...,...,...,T,...\r\nloop t=1,T%100\r\n  x = rand(100)\r\nendloop<\/pre>\n<h3><a name=\"5154\"><\/a><strong>ASCII<\/strong><\/h3>\n<p>Returns chars by their ascii number.<\/p>\n<p>Example:<\/p>\n<pre>ASCII(65)=A\r\nASCII(65,66)=AB<\/pre>\n<p>Do not try to obtain comma (,) by ASCII function because such a value shall cause error condition when trying to use it in computations.<\/p>\n<p>It useful to know that ascii number of the straight quote is 92.<\/p>\n<p>Thus expression &#8220;c:\\temp\\&#8221;+&#8221;test.p65&#8243; will cause an error because \\&#8221; confusion. At the same time &#8220;c:\\temp&#8221;+quote(ascii(92))+&#8221;test.p65&#8221; works fine.<\/p>\n<h3><a name=\"5583\"><\/a><strong>Abs<\/strong><\/h3>\n<p>Removes `-&#8216; at the beginning of the of the parameter string.<\/p>\n<pre>Abs(-42) = 42\r\nAbs(-abc) = abc<\/pre>\n<h3><a name=\"5678\"><\/a><strong>Max,Min<\/strong><\/h3>\n<p>Accept as an argument list of numbers of any length. Returns one of them &#8211; maximal or minimal. Behaviour of the functions is not efined for the case of empty argument.<\/p>\n<h3><a name=\"5854\"><\/a><strong>IsNumber<\/strong><\/h3>\n<p>Returns 1 if argument of the argument is a number, 0 oherwise. If string is quoted, then it is not a number.<\/p>\n<p>Examples:<\/p>\n<pre>IsNumber(76) = 1\r\nIsNumber(haha) = 0\r\nIsumber(\"76\")=0<\/pre>\n<h3><a name=\"6034\"><\/a><strong>Sin, Cos<\/strong><\/h3>\n<p>Trigonomeric functions. Accept argument in degrees.<\/p>\n<h3><a name=\"6095\"><\/a><strong>Arctan<\/strong><\/h3>\n<p>Argument should not exceed pi\/2 by absolute value. Returns value in degrees<\/p>\n<h3><a name=\"6178\"><\/a><strong>Exp<\/strong><\/h3>\n<p>Natural exponential function; base = e = 2.7182818&#8230;. Argument should not exceed 230.<\/p>\n<h3><a name=\"6269\"><\/a><strong>Log<\/strong><\/h3>\n<p>Natural logarithm, base e = 2.7182818&#8230;, positive number expected as an argument.<\/p>\n<h3><a name=\"6356\"><\/a><strong>Sqrt<\/strong><\/h3>\n<p>Square root, non negative number expected as an argument.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Conhe\u00e7a as fun\u00e7\u00f5es da linguagem script do software de editora\u00e7\u00e3o PageMaker 7.0<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-1787","post","type-post","status-publish","format-standard","hentry","category-pagemaker"],"_links":{"self":[{"href":"https:\/\/meiradarocha.jor.br\/news\/wp-json\/wp\/v2\/posts\/1787","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meiradarocha.jor.br\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meiradarocha.jor.br\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meiradarocha.jor.br\/news\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/meiradarocha.jor.br\/news\/wp-json\/wp\/v2\/comments?post=1787"}],"version-history":[{"count":0,"href":"https:\/\/meiradarocha.jor.br\/news\/wp-json\/wp\/v2\/posts\/1787\/revisions"}],"wp:attachment":[{"href":"https:\/\/meiradarocha.jor.br\/news\/wp-json\/wp\/v2\/media?parent=1787"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meiradarocha.jor.br\/news\/wp-json\/wp\/v2\/categories?post=1787"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meiradarocha.jor.br\/news\/wp-json\/wp\/v2\/tags?post=1787"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}