Using Dyalog APL as a scripting language
6 posts
• Page 1 of 1
Using Dyalog APL as a scripting language
The GNU APL allows to write APL code in text file and execute it as an ordinary script:
Run it:
Is there a way to use Dyalog APL in the similar manner?
- Code: Select all
#!apl --script --
⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝
⍝ Simple APL script example
a←⍳10
⎕←a
)off
Run it:
- Code: Select all
./print.apl
1 2 3 4 5 6 7 8 9 10
Is there a way to use Dyalog APL in the similar manner?
- alexeyv
- Posts: 56
- Joined: Tue Nov 17, 2015 4:18 pm
Re: Using Dyalog APL as a scripting language
Ok what I finally did was to create a workspace with
where main is the entry function, and run it like this:
However there are 2 problems here:
1. If I want to "load" this workspace again, it closes the interpreter (because ⎕LX contains ⎕off)
2. I couldn't find a way to send command line arguments to the workspace.
Is where a way to overcome these problems?
⎕LX←'⍎''main''⋄ ⎕off'
where main is the entry function, and run it like this:
- Code: Select all
dyalog -b -s ~/Sources/apl/dyalog-workspaces/test.dws
However there are 2 problems here:
1. If I want to "load" this workspace again, it closes the interpreter (because ⎕LX contains ⎕off)
2. I couldn't find a way to send command line arguments to the workspace.
Is where a way to overcome these problems?
- alexeyv
- Posts: 56
- Joined: Tue Nov 17, 2015 4:18 pm
Re: Using Dyalog APL as a scripting language
Maybe
⎕XLOAD WSNAME
or
)XLOAD WSNAME
?
⎕XLOAD WSNAME
or
)XLOAD WSNAME
?
-
woody - Posts: 144
- Joined: Tue Dec 28, 2010 12:54 am
- Location: Atlanta, Georgia USA
Re: Using Dyalog APL as a scripting language
Thanks, this solves problem 1.
- alexeyv
- Posts: 56
- Joined: Tue Nov 17, 2015 4:18 pm
Re: Using Dyalog APL as a scripting language
I found this info from the late, great Dan.
You can pass a variety of arguments when calling APL... and then dig them out with
2 ⎕NQ'.' 'getcommandlineargs'
If you use 2 ⎕NQ'.' 'getcommandlineargs' you will get all the command line arguments as a VTV (Vector of Text Vectors) which you can deal with.
There are many arguments you can give to the interpreter - they are listed in the PDF in the help folder.
Those that are not recognized by the APL interpreter are left alone. You could use this feature to pass your own arguments, e.g. PORT=4500.
Hope that helps!
//W
You can pass a variety of arguments when calling APL... and then dig them out with
2 ⎕NQ'.' 'getcommandlineargs'
If you use 2 ⎕NQ'.' 'getcommandlineargs' you will get all the command line arguments as a VTV (Vector of Text Vectors) which you can deal with.
There are many arguments you can give to the interpreter - they are listed in the PDF in the help folder.
Those that are not recognized by the APL interpreter are left alone. You could use this feature to pass your own arguments, e.g. PORT=4500.
Hope that helps!
//W
-
woody - Posts: 144
- Joined: Tue Dec 28, 2010 12:54 am
- Location: Atlanta, Georgia USA
Re: Using Dyalog APL as a scripting language
Instead of the latent expression, you could use a script-file "*.dyalog" with scripted APL commands - created with ]save - and pipe this into dyalog.exe:
dyalog.exe <commands.dyalog -x -q myworkspace.dws
dyalog.exe <commands.dyalog -x -q myworkspace.dws
- jwied
- Posts: 5
- Joined: Wed Feb 24, 2010 7:30 am
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group