2020-09-14 20:56:34 +02:00
|
|
|
# Scripting Support
|
|
|
|
|
|
|
|
This is the scripting interface words for use with retro-unix
|
|
|
|
or other interfaces providing device type 9 support.
|
|
|
|
|
|
|
|
## Rev. 0
|
|
|
|
|
|
|
|
The initial version of this I/O device provides support for some
|
|
|
|
basic interactions.
|
|
|
|
|
|
|
|
- obtaining the name of the script
|
|
|
|
- obtaining the number of arguments passed
|
|
|
|
- obtaining the arguments passed
|
|
|
|
- "including" a file (which has RETRO process the file as inuput)
|
|
|
|
|
|
|
|
## Rev. 1
|
|
|
|
|
|
|
|
In 2020.10, the device was extended to add support for new additional
|
|
|
|
introspection and control of the `include` process.
|
|
|
|
|
|
|
|
- obtaining the current file name
|
|
|
|
- obtaining the current line number
|
|
|
|
- direct RETRO to ignore the rest of the current line
|
|
|
|
- direct RETRO to ignore any remaining lines in the file
|
|
|
|
|
2020-11-16 15:16:36 +01:00
|
|
|
## Rev. 2
|
|
|
|
|
|
|
|
Adds support for `abort`.
|
|
|
|
|
2022-08-30 17:14:44 +02:00
|
|
|
## Rev. 3
|
|
|
|
|
|
|
|
Adds support for obtaining current source line text
|
|
|
|
|
2020-09-14 20:56:34 +02:00
|
|
|
# The Code
|
|
|
|
|
|
|
|
~~~
|
|
|
|
{{
|
2021-04-19 19:41:14 +02:00
|
|
|
:script:operation
|
|
|
|
#9 io:scan-for
|
|
|
|
dup n:negative? [ drop 'Error:_device_(0009)_not_found s:put nl ] if;
|
|
|
|
io:invoke ;
|
2020-09-14 20:56:34 +02:00
|
|
|
---reveal---
|
2021-04-19 19:41:14 +02:00
|
|
|
:script:arguments (-n) #0 script:operation ;
|
|
|
|
:script:get-argument (n-s) s:empty swap #1 script:operation ;
|
|
|
|
:include (s-) #2 script:operation ;
|
|
|
|
:script:name (-s) s:empty #3 script:operation ;
|
2020-09-14 20:56:34 +02:00
|
|
|
|
2021-04-19 19:41:14 +02:00
|
|
|
:script:current-file (-s) s:empty #4 script:operation ;
|
2021-06-03 16:07:29 +02:00
|
|
|
:script:current-line (-n) #5 script:operation class:data ; immediate
|
2021-04-19 19:41:14 +02:00
|
|
|
:script:ignore-to-eol (-) #6 script:operation ;
|
|
|
|
:script:abort-include (-) #7 script:operation ;
|
2020-11-16 15:16:36 +01:00
|
|
|
|
2021-04-19 19:41:14 +02:00
|
|
|
:abort (-) &Compiler v:off #8 script:operation ;
|
2022-08-30 17:14:44 +02:00
|
|
|
|
|
|
|
:script:current-line-text (-s) s:empty [ #9 script:operation ] sip ;
|
2020-09-14 20:56:34 +02:00
|
|
|
}}
|
|
|
|
~~~
|
2021-08-23 15:23:10 +02:00
|
|
|
|
|
|
|
## d:source
|
|
|
|
|
|
|
|
~~~
|
2023-04-12 02:40:25 +02:00
|
|
|
'interface/scripting.retro
|
|
|
|
dup 'abort d:set-source
|
|
|
|
dup 'script:abort-include d:set-source
|
|
|
|
dup 'script:ignore-to-eol d:set-source
|
|
|
|
dup 'script:current-line d:set-source
|
|
|
|
dup 'script:current-file d:set-source
|
|
|
|
dup 'script:name d:set-source
|
|
|
|
dup 'include d:set-source
|
|
|
|
dup 'script:get-argument d:set-source
|
|
|
|
dup 'script:arguments d:set-source
|
2023-10-22 18:18:59 +02:00
|
|
|
dup 'script:current-line-text d:set-source
|
2021-08-23 15:23:10 +02:00
|
|
|
drop
|
|
|
|
~~~
|