CRI ADX
Last Updated: 2024-07-17 10:47 p
|
In this tutorial, we will write a Script to display the characters of "Hello, World" in the "Script log" window by the following two methods:
Using log output function is convenient for visually checking the Script execution status. Let's begin by learning the differences between these two log outputs.
First, prepare a Script file(Python file) for writing the process.
Start CRI Atom Craft, select "Script list..." from the "Script" menu to display the Script list window.
Select "tutorials [CRI]" from the Script list. Click the "New" button of the script file.
Click "New" button to display the dialog for creating files.
Input "tutorial01-1_helloworld.py" as the file name. Click the "Save" button to save the file.
The saved Script file "tutorial01-1_helloworld" is displayed in the Script list.
Script files are created.
There are some sample scripts in the "samples [CRI]" script list.
Script files other than the created "tutorial01-1_helloworld" also display explanations.
The Script list can read the written comment in the following format in the Script, and display the "<b>Description</b>" field of the script list.
Double-click "tutorial01-1_helloworld" in the Script list, open the Script list by Run the Script from the Script Editor , and input the comment for the description as follows:
After inputting the comment, click the "Save" button on the Script Editor toolbar to save the Script.
By returning to the Script list, you can check the displayed description of the "tutorial01-1_helloworld" Script.
For details about Script description format, refer to Extension for Script Editor .
After learning how to write the Script description, try using Python standard String output function - the print function to display "Hello, World".
Return Run the Script from the Script Editor and input the following:
Click the "Save" button on the Script Editor toolbar to save the Script.
Execute the created Script to display "Hello, World" in the Script log window.
Return to the Script list window, and click the "View log" button to display the Script log window.
Click "Run" button on the toolbar to execute the Script. "Hello, World" will appear in the Script log script.
Use Python's print function to display the characters "Hello, World" in the Script log.
Next, Use the CRI Atom Craft API - Debug Module , to display "Hello, World" in the Script log.
CRI Atom Craft contains Python modules for manipulating CRI Atom Craft.
To use an external Python module in Python, use import in the Script to declare the "Use module".
To use the CRI Atom Craft API - Debug Module , write as follows:
For details about the Debug module and other modules of CRI Atom Craft API, refer to Module reference .
Declaring "import" and get prepared to use the CRI Atom Craft API - Debug Module .
Now, try to use Debug module to display "Hello, World".
The Debug module provides several string output functions, but here we use the log function to display "Hello, World".
After declaring " import cri.atomcraft.debug ", write a script as below:
Save the Script and click the "Clear" button in the Script log window before executing the Script, to clear the log display.
By executing the Script, you can see that two lines of "Hello, World" characters are displayed together when using the "print" function.
Function name | Description |
---|---|
log | Outputs the standard log |
warning | Outputs the warning log The highlighted log will be output |