7. X-script¶
X-script can be used to extend RDE, create shell commands, write AGV scripts, make animation in the 3d graphic panel. User interfaces can be designed in Qt designer then deloyed with x-script application.
X-script have some limited object oriented abilities. When it is compiled it generate a byte code, than can be executed by the XVM (X-script virtual machine).
Its syntax is similar to C, pascal and basic. The official documentation provide quite fair explanation of the basic syntax.
The VMI documentation can be found in every tool that can use the X-script language:
- Command Shell
- 3D graphic panel
- AgvManager
- etc.
7.1. Basic syntax¶
int, uint, long ; 32 bit
int16, uint16, short, ushort ; 16 bit
char, uchar, byte, bool ; 8 bit
real ; 64 bit
float ; 32 bit
string ; strings are terminated wit /0 like C
handle (uint)
color (uint)
timeout (real)
if(condition)
else
end or endif
while(condition)
end or endwhile
do
end condition
for(init, cond, update)
endfor
select(var)
case 2
;
break
default
;
break
end or endselect
7.2. Functions¶
A function is declared using the keyword code
and end
or endcode
:
code functionName()
; function body
end
code function2() : int
int res
; function body
return res
end
code func3(uint par, uint i = 0)
; function body
end
If a function is implemented in a file after another function that use it, the keyword forward should be used
. It is like in C
a function prototype should be provided.
forward func2(int)
code func1()
func2(10)
end
code func2(int c)
; function body
endcode
7.3. Objects¶
X-scripts objects are like Classes, in order to use them they should be instanciated. An object is declared using the keyword object
and endobject
or end
. First an object interface, header should be provided, then the implementation. Can be done in the same file. An object have also a contructor method.
object obClass
code constructor()
int var
code method1()
code method2(int):bool
endobject
code obClass.contructor()
; constructor implementation code
end
code obclass.method1()
; method implementation
end
Objects are used as classed, can be instanciated. Properties and methods can be accessed via the dot operator.
7.4. 3D graphic panel¶
To create a 3D graphic panel in the workspace right click then: New object –> editors –> 3D graphic panel.
3D graphic panels can be customized using X-script language. An example can be found in Workspace –> specials –> predefined examples – > R3/OB:rc_rod_crank Demo and in Workspace –> specials –> predefined examples – > OB: Element location
7.5. Shell commands file¶
To create new shell commands in the workspace right click then: New object –> editors –> commands file editor. A file with extension .shc
will be created.
Shell commands are implemented using X-script language.
Every shell command should have at least the execute()
and the help()
function.
code execute (CMDLINE @cl): BOOL
; TODO: code for execution of command
return true
end
code help (): BOOL
; TODO: code to request help, like print() o invokeHelp()
return true
end
A user interface ui
can be desinged in Qt designer
and used in the command shell.
7.6. AGV¶
AGV’s plant logic, dispatching, are implemented in X-script language. The script is compiled by AgvManager, not by RDE. Consult the documentation of AGV for more information.