126.96.36.199 From Script and Command Window
Script Window and the (newer) Command Window.
Each window can execute single or multiple lines of script.
The Command Window has a prompt and will execute all code entered at the prompt.
Two Windows exist for direct execution of LabTalk: the (older)
The Script Window has only a cursor and will execute highlighted code or code at the current cursor position when you press Enter.
Both windows accept Ctrl+Enter without executing.
When using Ctrl+Enter to add additional lines, you must include a semicolon (;) at the end of a statement. You can also turn Script Execution off or on in the Edit menu by selecting Script Execution:None.
The Command Window includes Intellisense for auto-completion of X-Functions, a command history and recall of line history (Up and Down Arrows) while the Script Window does not.
The Script Window allows for easier editing of multiline commands and longer scripts.
Below is an example script that expects a worksheet with data in the form of one X column and multiple Y columns. The code finds the highest and lowest Y values from all the Y data, then normalizes all the Y's to that range.
// Find the lowest minimum and the highest maximun
double absMin = 1E300;
double absMax = -1E300;
if(absMin > stats.min) absMin = stats.min;
if(absMax < stats.max) absMax = stats.max;
// Now normalize each column to that range
wcol(ii)-=stats.min; // Shift to minimum of zero
wcol(ii)/=(stats.max - stats.min); // Normalize to 1
wcol(ii)*=(absMax - absMin); // Normalize to range
wcol(ii)+=absMin; // Shift to minimum
To execute in the Script Window, paste the code, then select all the code with the cursor (selected text will be highlighted), and press Enter.
To execute the script in the Command Window, paste the code then press Enter. Note that if there were a mistake in the code, you would have it all available for editing in the Script Window, whereas the Command Window history is not editable and the line history does not recall the entire script.
Origin also has a native script editor, Code Builder, which is designed for editing and debugging both LabTalk and Origin C code. To access Code Builder, enter ed.open() into the script or command window, or select the button from the Standard Toolbar.
The font in Script Window can be customized in this way:
- Open the Origin.ini file in User Files Folder, search for the [font] section: paste the contents below in [font] section.
- Restart the Origin and check the Script Window again, the font and size both changed.
ScriptWindowFaceName=Times New Roman
For more charset value, see http://msdn.microsoft.com/en-us/library/cc250412.aspx