10.02 - Converters

From file to script.sahi

Category-Name: script

What: This 'script' converter will convert a resource of category file to a resource of category script.sahi. Two cases:

  • Standalone Sahi script

In the case of a standalone script (The script doesn't depend on other files, e.g. script includes or files to be uploaded) then you could use the syntax below. The initial resource references the sahi script.
CONVERT {scriptToConvert<Res:file>} TO script.sahi (script) AS {converted<Res:script.sahi>}

Input:
  • scriptToConvert<Res:file>: The name of the resource to convert (Resource of category file). This ressource references a sahi script (e.g. by using a LOAD instruction on the sahi scipt path).
Output:
  • converted<Res:scipt.sahi>: The name of the converted resource. (Resource of category script.sahi)

Example:

LOAD path/to/sahi_script.sah AS sahi_script.file
CONVERT sahi_script.file TO script.sahi (script) AS sahi_script.sahi


  • Sahi script with dependencies

In the case of a script which depends on other file, you have to use the syntax below. The initial resource references a directory. This directory should contains in its tree the whole resources needed by the main sahi script. You also have to define where is the main sahi script to execute (mainScriptPath of the USING clause). This path should be RELATIVE to the directory referenced by the initial resource.
CONVERT {rootDirectory<Res:file>} TO script.sahi (script) AS {converted<Res:script.sahi>} USING {mainScriptPath<Res:file>}
Input:
  • rootDirectory<Res:file>: Name of the resource which references the root directory. This root directory should contain the whole files needed to execute the sahi script.
  • mainScriptPath<Res:file>: Name of the configuration resource. The content of the file should be: 'mainpath:relativePathToMainSahiScript' (Note: you could use an inline definition). This path to main sahi script should be relative to the directory given as rootDirectory.
Output:
  • converted<Res:scipt.sahi>: The name of the converted resource (Resource of category script.sahi)

Example:

LOAD path/to/rootDirectory AS root_directory.file
CONVERT root_directory.file TO script.sahi (script) AS sahi_script.sahi USING $(mainpath:relative/path/to/main/sahi_script.sah)