MultiScript - Misc Core Functions

×

Warning message

  • Filefield sources: remote plugin will be disabled without php-curl extension.
  • Filefield sources: remote plugin will be disabled without php-curl extension.
Sleep Pause the script for a specified number of milliseconds.
min Return the minimum value of many values or from an array of values.
max Return the maximum value of many values or from an array of values.
mod Modulo, Returns the remainder after a division of the provided values .
GetRandomValue generate a random value between a min and max value
Log Log text to a log window.
LogDump Dump the contents of a variable to the log.
LogDumpArray Dump the contents of an array to the log.
LogAppInfo Log text to the application log window.
MessageBox Show a messagebox.
AskText Ask the user for text via a dialog.
AskOption Ask the user to pick one of  a list of items from a dropdown list.
SaveArray Save an array of strings to a file.
LoadArray Load a file of strings into an array.
SaveStringToFile Save a string to a file.
LoadStringFromFile Load a file into a string.
GetClipboardText Get the text stored in the clipboard.
SetClipboardText Set text in the clipboard.
GetTagValue Expand a MultiTag value.
TranslateEnvString Translate an environmental string.
 

Sleep

Pause the script for a specified number of milliseconds.

<none> Sleep( <num> mmsec );

Parameters

mmsec
Milliseconds to wait before continuing.

Return value

Nothing.

Examples

Sleep( 10 );

min

Returns the minimum value from two or more values passed to the function.
It is also possible to pass it an array that contains multiple number values.

<num> min( <num> val1, <num> val2, ... , ...  );
<num> min( <array> arrrayVal );

Parameters

val1
A number value.
val2
A number value.
arrayVal
An array with multiple number values.

Return value

The minimum values of all the values passed to the function.

Examples

@var $v1 = 73;
@var $v2 = 52;
@var $v3 = 45;
@var $v4 = 87;
@var $res = min( $v1, $v2, $v3 , $v4 );
// $res == 45;

@var $vals[] = { 73, 52, 45, 87};
@var $res = min( $vals );
// $res == 45;

max

Returns the maximum value from two or more values passed to the function.
It is also possible to pass it an array that contains multiple number values.

<num> max( <num> val1, <num> val2, ... , ...  );
<num> max( <array> arrrayVal );

Parameters

val1
A number value.
val2
A number value.
arrayVal
An array with multiple number values.

Return value

The maximum values of all the values passed to the function.

Examples

@var $v1 = 73;
@var $v2 = 52;
@var $v3 = 45;
@var $v4 = 87;
@var $res = max( $v1, $v2, $v3 , $v4 );
// $res == 87;

@var $vals[] = { 73, 52, 45, 87};
@var $res = max( $vals );
// $res == 87;

mod

Modulo - Return the remainder after division of the values.

<num> mod( <num> val1, <num> val2, );

Parameters

val1
A number value.
val2
A number value.

Return value

The remainder when the first value if divided by the another.
Used when you want to know if a values is even divided by a another value. If it is the reminder is 0

Examples

@var $val = 17;
@var $res = mod( $val , 3 );
// $res == 2;

@var $val = 20;
@var $res = mod( $val , 5 );
// $res == 0;

GetRandomValue

Generate a random values between a min and max value.

<num> GetRandomValue( <num> min, <num> max, [<num> seed] );

Parameters

min
Minimum value.
max
Maximum value
seed
[OPTIONAL] Seed value for random value generator, If not specified a seed value will be generated.

Return value

A random value between the specified min and max values

Examples

@var $res = GetRandomValue( 10, 99 );
// $res == Anything from 10 to 99;

@var $res = GetRandomValue( 10, 99, 12345678 );

Log

Log text to a log window.

<num> Log( <num> logID, <num> logLevel, <str> logText );

Parameters

logID
ID of the logger that should receive the log text.
0 = Standard Application log
1 = File Operations Log
x = ID of user-created log
logLevel
Logging level for this log text. Logging can be set to only show info, warning or error.
10 = Info
20 = Warning
30 = Error
logText
Text that should be written to the log.

Return value

1 if message is logged, 0 if the log is not found.

Examples

Log( 0, 30, "Error - File Not found" );

LogDump

Dump the content of a variable to the log. (Useful for debugging.)

<num> LogDump( <var> var );

Parameters

var
Variable to dump to the log file.

Return value

Always 1.

Example

@var $str = "String1";
LogDump( $str );
// Log window output 
// ==[ Name : $str ]==[ Type : variable:string ]==[ Value : "String1" ]==

LogDumpArray

Dump the contents of an array to the log. (Useful for debugging.)

<num> LogDumpArray( <arr> array );

Parameters

array
Array to dump to the log file.

Return value

Always 1.

Example

@var $arr[] = {"String1", "String2", "String3"};
LogDumpArray( $arr );
// Log window output
// ==[ Variable : $arr ]==
// [0] : "String1"
// [1] : "String2"
// [2] : "String3"
// ===========================

LogAppInfo

Send text directly to the application log, with logging level 'Info'.

<num> LogAppInfo( <str> logText );

Parameters

logText
Text that should be written to the log file.

Return value

Always 1.

MessageBox

Show a messagebox.

<num> MessageBox( <str> caption, <str> text, <num> options );

Parameters

caption
The caption text for the messagebox.
text
The message text that should be shown.
option
One of the standard Win32 values for Button and Icon options. See MSDN here for a full list of values.
 
Button combinations and their option values are:
 
OK 0
OK + Cancel 1
Abort + Retry + Ignore 2
Yes + No + Cancel 3
Yes + No 4
Retry + Cancel 5
 

Return value

Possible return values and their meanings are:

 1 - OK button was selected
 2 - Cancel button was selected
 3 - Abort button was selected
 4 - Retry button was selected
 5 - Ignore button was selected
 6 - Yes button was selected
 7 - No button was selected (user cancelled with Esc)
 8 - Close button was selected
 9 - Help button was selected

AskText

Show a dialog in which the user can input text.

<num> AskText( <str> label, <str> inputText, <num> option );

Parameters

label
The dialog Label text that will be shown.
inputText
Text that will be pre-loaded into the input field when the dialog is first shown (can be: "").
option
Not yet used; can be set to 0.

Return value

0 if user cancelled the dialog, else a string with the text from the dialog's input field.

AskOption

Show a dialog in which the user can pick one of a list of items from a dropdown list.

<num> AskOption( <str> label, <arr> values, <num> selected );

Parameters

label
The Label text that will be shown.
values
An array of strings or numbers that will be shown in the dropdown list.
selected
Index of the item in the list that should be selected by default, -1 for no default item selected.

Return value

Index of the item selected, or -1 if user pressed Cancel.

Examples

@var $options[] = {"Option1", "Option2", "Option3", "Option4" };
@var $o = AskOption( "Select Option", $options, 2 );
if( $o > -1 )
{
   @var $sel = $options[$o];
   @var $msg = "You selected option : \"" + $sel + "\"";
   MessageBox("Selected Item", $msg, 0);
}

SaveArray

Save an array of strings to a file

<num> SaveArray( <str> filename, <arr> array, <num> overwrite, <num> format );

Parameters

filename
Complete file path where the file should be saved.
array
The array to save
overwrite
0 = Do not overwrite existing file, 1 = Overwrite existing file.
format
0 = ASCII
1 = UTF8
2 = Unicode

Return value

1 if array was saved successfully else 0.

LoadArray

Load a text file into an array.

<arr> LoadArray( <str> filename );

Parameters

filename
Complete path to the file to load.

Return value

An array where every line in the file filename is an item in an array.

SaveStringToFile

DESC

<num> SaveStringToFile( <str> filename, <str> string, <num> format );

Parameters

filename
Complete file path to where the file should be saved.
string
Content to save.
format
0 = ASCII
1 = UTF8
2 = Unicode

Return value

1 if string was saved successfully else 0.

LoadStringFromFile

Load the content of a text file into a string.

<str> LoadStringFromFile( <str> filename );

Parameters

filename
Complate file path of the file to load.

Return value

The content of the file as a string.

GetClipboardText

Get the text stored in the clipboard. If the clipboard content is not text then an empty string will be returned.

<str> GetClipboardText();

Return value

A string containing the content of the clipboard.

SetClipboardText

Store text in the global clipboard.

<num> SetClipboardText( <str> );

Return value

Nothing.

Example

@var $textClip = GetClipboardText();
// Replace all '-' with '_' 
$textClip = StrReplace( $textClip, "-", "_" );
// set the clipboard text with the new modified text.
SetClipboardText( $textClip );

GetTagValue

Expand a MultiTag.

<str> GetTagValue( <str> );

Return value

Expanded MultiTag value.

Example

@var $tag = GetTagValue("${mcinstallpath}");

TranslateEnvString

Translate a Windows environment variable.

<str> TranslateEnvString( <str> );

Return value

Expanded environmental string.

Example

@var $tag = TranslateEnvString("%WINDIR%");