- Subject: Re: [slang-users] Working with S-Lang arrays
- From: "John E. Davis" <davis@xxxxxxxxxxxxx>
- Date: Thu, 22 Nov 2012 11:11:01 -0500
Duke Normandin <dukeofperl@xxxxxxxxxxx> wrote:
> Is the code substantially correct, or is it indicating that I may be
> heading for a punji-pit??
It looks ok -- see comments below.
> As well, I see that S-Lang has several ways of sending output to
> screen - print; printf; message; vmessage. The `print' function
> works to output numeric data only (it seems). However, I can't find
> any docs on it?
The function is documented in
<http://www.jedsoft.org/slang/doc/html/slshfun-11.html#ss11.1>. Its
documentation is also available from within slsh using:
slsh> help print
Also try
slsh> slsh_help
> -----------------------------------8<----------------------------------
> #!/usr/bin/env slsh
For playing with the language, it may be easier to use slsh in its
interactive mode. One advantage of this is that you will not have to
declare variables. That is, _auto_declare=1 while in the slsh>
commandline such that you can just say
slsh> i = 10;
instead of
slsh> variable i = 10;
You can also use
_auto_declare = 1;
at the top of your script. However, for scripts I strongly encourage
you to put as much as possible into functions, and in particular in
one called `slsh_main`, which slsh will automatically call. The
advantage of this approach is that it gives the interpreter the
opportunity to check the syntax before executing any of the code. For
examples, look at the files in the slang/slsh/scripts/ directory, such
as the "mv" script.
> % This is a comment
>
> variable i;
> variable a = @Array_Type(Integer_Type, [10]);
The standard way to create an array of 10 integers is to use:
a = Integer_Type[10];
a = Int_Type[10]; % Int_Type is an alias for Integer_Type
> a[[0:4]] = 11;
> a[[5:9]] = 22;
You can also use:
a[[:4]] = 11;
a[[5:]] = 22;
Good luck,
--John
[2012 date index]
[2012 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]