JANOS Help System: [Commands] [Topics] [Tech Support] [Printable Manual] [Search]
Script Tags Scripting DESCRIPTION Script is inserted using the <?php opening tag and ?> closing tag. A closing tag at the end of a file is not required thus avoiding the insertion of unnecessary trailing white space. The <php= opening shortcut can be used with the following content assumed to be parameters to an ECHO statement. With JANOS scripting the preference is to use the generic scripting tags <? and ?>. The "php" characters are optional in the opening tags. So to add lines of script you can just use <? or for the shorthand echo statement <?=. WEBSERVER The JANOS Web Server interprets PHP script in files with the .PHP extension. The index.php file is a default home page which if it exists takes precedence over and index.html file. The PHP file is assumed to contain HTML content which would be served like any other page with the exception of any script which is identified by the special tags. A .PHP file when served first executes script (if any) generating a .HTML file which subsequently is served to the client browser. Scripts then are designed to render HTML. BATCH PROCESSING From the JANOS Command Line you can execute Batch Files which have the .BAT extension. Script may be interposed in these files for pre-processing. The syntax is identical to that used in the HTML implementation including the <? and ?> tags. The script renders commands formatted as if entered at the command line which are then executed. You can use script to conditionally customize and/or generate the commands. SCRIPTED PROGRAMS The scripting implementation is very powerful. While such scripting is usually implemented by an interpreter, JANOS compiles these scripts prior to execution and caches the compiled code for reuse. As a result scripts execute fast and efficiently. This can be used to create utility and even application programs. A Program File can be created with the default extension .PRG and executed directly using the RUN command. These program files are logically created just as PHP HTML pages or scripted batch files. One or more blocks of script are interposed using the <? and ?> tags. In this case, text outside of the script is merely echoed as program output. INLINE SCRIPT Script may be entered at the command line. The line must begin with the opening <? tag and be terminated with ?>. The script therein generates the command that then is executed. This can be useful in testing fragments of script. Inline script entered in this fashion must also simulate an ENTER keystroke by including a trailing newline character '\n'. Output without the newline is simply displayed and execution is not attempted. The puts($string) function echos the $string followed by the necessary carriage return and linefeed for execution. For example: bruce_dev /> <? puts("date");?> date Sun Jun 27 08:02:45 EDT 2021 bruce_dev /> <? echo "date\n";?> date Sun Jun 27 08:03:02 EDT 2021 bruce_dev /> <?="date\n";?> date Sun Jun 27 08:03:11 EDT 2021 bruce_dev /> <?="date";?> date bruce_dev /> Inline script can also simply generate output that would not be interpreted as a command. a Line of script may be entered following an exclamation point '!'. This syntax assumes the opening and closing tags. These should not then be entered. For example: bruce_dev /> ! puts("Hello World."); Hello World. NOTES Errors in scripts are reported in the php.log file. Inline script errors are reported to the console. bruce_dev /> <? echo "Hello World." ?> Scripting error: /temp/tmp31076 (Line 1) 1: <? echo "Hello World." ?> 1: ^ expected semicolon bruce_dev /> SEE ALSO HELP Topics: VARIABLES, SCRIPTING, RUN [/flash/manpages/program.hlp:264]