IsComponentAvailable

Reports whether the optional parser or compiler component is available.

This function is exported by the KS module.

IsAvailable := IsComponentAvailable(Capability)

Parameters

Capability

Type: String

Specify "parser" or "compiler". "parsing" and "compilation" are accepted as synonyms. The name is not case-sensitive.

Return Value

Type: Integer (Boolean)

Returns 1 if the installed or embedded unit is compatible and can be loaded, otherwise 0. Checking a component loads it.

Error Handling

A ValueError is thrown if Capability is not a recognised name.

Remarks

A compiled script which statically calls RunScript, CompileScript or ValidateScript includes the component it needs. Use --without-compiler when the script should run without dynamic compilation; see Optional Scripting Components.

Examples

Uses dynamic compilation only when the compiler is present.

#Import "Ks" { IsComponentAvailable, RunScript }

if IsComponentAvailable("compiler")
    RunScript('FileAppend "compiled dynamically``n", "*"')
else
    FileAppend "compiler not installed`n", "*"

ValidateScript and CompileScript, RunScript, Command-Line Options