WebScripter supports executing PERL, PHP and Ruby scripts from the command line, checking syntax and run time errors. You can run a script in the default mode by using the Run item in the toolbar or Run Script command (command-R) in the Editor menu.
Run toolbar item selecting the preview mode.
Depending on the specified run mode, files are executed differently and the results handled accordingly. Run modes can be set on a per project basis (the mode effects all scripts being run) or on an individual file basis (the mode overrides the project).
There are 3 run modes:
|
Setting run mode in the project.
Setting run mode for a single file.
By using the Run & Debug command you can get errors from your script during run time and be directed to the line where the file occurred or even redirected to the file where it originated from. Each language offers different information but at minimum the functionality mentioned above.
PHP does not include an interactive debugger but has good error handling functions to compensate. Beyond an error message PHP supplies other information that will help you understand where the bug occurred and what was happening in the run-time environment at the time.
Above the error list there will be a toolbar with buttons containing additional information about the error. The buttons are described below.
|
Normally errors will be displayed if PHP detects a compile time error but you can also insert errors manually at any location to help debug your code by using the built-in PHP function trigger_error. The parameter you supply to the function will be displayed in the error list. For example:
trigger_error("error message"); |
Debugging a file in PHP.
Ruby has basic error messages and a simple stack trace that corresponds with each error. If you click the disclosure triangle next to an error it's stack trace will be displayed. If you select a function from the trace the line it was declared will be selected in the editor.
Debugging a file in Ruby.
Terminal mode simulates a UNIX terminal (like Apple's Terminal.app) in appearance but only supports output, no input. Using terminal mode is faster then the command line because the command is generated for you and the output is available directly in WebScripter, so you don't need to switch applications. Terminal mode is helpful for quickly testing scripts that produce simple text results, instead of HTML.
Running a PHP script in terminal mode.
Syntax checks will show the results in a small popup window by the cursor and disappear when you start typing again.
Syntax checks can be performed in a few ways:
|
Checking syntax in a PHP script.
WebScripter allows you to simulate command line arguments when running a script by using script arguments. The arguments you pass can be used to give a script dynamic state information that would normally be provided by a user, for example a GET string from an HTML form using the GET method. Note: The argument name and value are separated by the = symbol when supplied to the script.
The method arguments are available to the programmer vary in each language. Please refer to the manual on your preferred language and learn how it is used from the command line.
Setting script arguments in the file info window.
By default PERL, PHP and Ruby are all installed with every recent version of OS X so you don't need to worry about suppling the path to the compiler. However, if you installed another version or the original moved for some reason you can set the path where WebScripter can find the compiler.
To change command line preferences follow these steps:
|
Setting command line preferences.
If there is a problem with a script executing it can be aborted by clicking the Abort button which appears in the editor toolbar every time a script is run. This is useful in the instance the script is performing a lengthy process you don't want to see the end of (like a network operation or an infinite loop).
Abort button in the editor toolbar.