Python commands: Miscellaneous

The Miscellaneous commands in Python start and stop other processes that are not named in other command groups.

See Python commands for other commands you can use with GainSeeker.

Syntax

Example

Description/Remarks

misc.executescript("scriptname")

myvar1 = 345

misc.executescript("Show Result form")

myvar2 = "abc"

Sets a variable, runs the script named "Show Result form", and then sets another variable.

Executes another Python script of the same type (scripts for PC Collect or scripts for Dashboard controls).

This can take the place of copying and pasting the same code into multiple scripts, and changes to that code only need to happen in one script.

All variables, effects, etc. carry back into the parent script.

misc.parsecolumn(input, index, spliton="character(s)", isnumeric=True, noempty=False)

print misc.parsecolumn("Part#; Feature1; USpec; LSpec; Value1; A-50RB; Length; ; ; 0.503", 9, "; ", True, False)

Returns 0.503 as a number.

Splits the input into columns based on the character(s) specified by spliton. Returns the value for the specified column index returned by the split. Columns are zero based.

If isnumeric is True, the value to be returned should be a number.

If noempty is True, empty columns are automatically removed and are not counted for the column index.

misc.restart()

misc.restart()

Restarts the Python script from the beginning.

misc.run(target, waitforexit)

misc.run("C:\\temp\\sample.xlsx", True)

Uses the Windows default application for files with the .xlsx extension (such as Microsoft Excel) to open C:\temp\sample.xlsx .

Halts further script execution until the specified file (C:\temp\sample.xlsx) is closed.

Runs the specified application. If the file is not an executable, the default application for opening that file is launched.

If waitforexit is True, the script halts until the application closes.

misc.run(target, waitforexit, arguments)

misc.run("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\EXCEL.EXE", True, "/x /e")

Launches Microsoft Excel from the specified folder, with arguments /x and /e .

Halts further script execution until the specified file (EXCEL.EXE) is closed.

Runs the specified application. If the file is not an executable, the default application for opening that file is launched.

If waitforexit is True, the script halts until the application closes.

You can specify command line arguments for the application when it launches.

misc.stop()

misc.stop()

Stops the execution of the Python script.