TP_VIEW uses command strings to execute given task.
These strings are based on internal variable(cmd_list) with command ID.
- some commands require several parameters/arguments.
- simple commands are called or executed with a string containing the command name or by ID.
- :CALL TP_VIEW('HELP') or :CALL TP_VIEW(11);
- commands of same functional group have the group name separated by a dot from the command name.
- :CALL TP_VIEW('FORCE.VIEW');
CMD_LIST Variable:
[TP_VIEW]CMD_LIST Storage: DRAM Access: RW : CMD_LIST_T = Field: CMD_LIST.HELP Access: RW: INTEGER = 11 ... Field: CMD_LIST.WIDE_USER Access: RW: INTEGER = 17 Field: CMD_LIST.SCREEN.SINGLE Access: RW: INTEGER = 21 Field: CMD_LIST.SCREEN.WIDE Access: RW: INTEGER = 22 ...
Karel code: get the command id by extracting it from the first TP argument
CMD.CURR.ID = getINTByNam('CMD_LIST.'+ GET_TPE_STR(1))
The key is that we access the cmd_list variable 'BYNAME-builtin'.
In fact we need only one simple string computation to get a command ID. When trying to access a 'command' using a invalid command string like 'HELO' instead of 'HELP' the user gets a simple but informative (system) error message.
Using command id's is quite common because it's fast(!) and easy(mostly). The downside is that the (user/dev) has to deal with numbers instead of 'named' commands only.
The benefit of accessing commands 'BYNAME-builtin' is that it's fast AND easy for devs and users!
There is a second variable called [TP_VIEW]CMD_HELP with same structure, but of type string. This string contains little command specific help.
[TP_VIEW]CMD_HELP Storage: DRAM Access: RW : CMD_HELP_T = Field: CMD_HELP.HELP Access: RW: STRING[64] = 'TP_VIEW('HELP'); show web_help of this program'
So there is always(!)a simple help included inside the prog. It is possible to acces the va- file via web execution of this program like
_hostname_/karel/tp_view
The va-file and also an optional command-reference-file are included dynamically to the web help!