Both sides previous revision
Previous revision
Next revision
|
Previous revision
Last revision
Both sides next revision
|
manual:chapter4:libs [2018/03/02 09:43] claudio |
manual:chapter4:libs [2018/03/02 09:46] claudio [Creating user libraries] |
=== Sample library "Hello world!" === | === Sample library "Hello world!" === |
| |
To create the library, first create an empty directory: '''helloLIB' CRLIB'' and go into it. This library will have a single command ''HWORLD'' that puts the message "Hello world!" on the stack. | To create the library, first create an empty directory: '''helloLIB' CRDIR'' and go into it. This library will have a single command ''HWORLD'' that puts the message "Hello world!" on the stack. |
| |
Create the variables needed inside the directory: | Create the variables needed inside the directory: |
|''$VISIBLE'' |''{ { 'HWORLD' 0 0 "Shows a nice↲greeting.↲ → " } }'' | | |''$VISIBLE'' |''{ { 'HWORLD' 0 0 "Shows a nice↲greeting.↲ → " } }'' | |
| |
Finally, use ''CRLIB'' to create the library, then ''ATTACH'' to attach it. From the main menu, ''Libs'' will now show an item ''mLIB''. Long pressing the item will show the library title. Going into the menu we should see the HWORLD command, long pressing it will show the help that was provided. | Finally, use ''CRLIB'' to create the library, then ''ATTACH'' to attach it. From the main menu, ''Libs'' will now show an item ''MyHW''. Long pressing the item will show the library title. Going into the menu we should see the HWORLD command, long pressing it will show the help that was provided. |
| |
Notice that in this case, the ''WORLD'' string was included in the library because it was referenced by the main program ''HWORLD'', but it is not visible to the user. | Notice that in this case, the ''WORLD'' string was included in the library because it was referenced by the main program ''HWORLD'', but it is not visible to the user. |
From now on, compiling a program that contains ''HWORLD'' will use the installed library command, rather than an identifier. Programs compiled before the library was attached will have an identifier instead. | From now on, compiling a program that contains ''HWORLD'' will use the installed library command, rather than an identifier. Programs compiled before the library was attached will have an identifier instead. |
| |
| |
---- | ---- |
| |