Hello, I’m using Natural V 6.1.1 Pl 15 on Linux. I know this is long post, so if you want to answer only one of my questions, I would be very happy :).
I had this idea of creating Natural programs from outside the editor to do simple tasks as reading some Adabas fields. Simple as:
I need a way to save the file under Natural database and stow it programmaticaly, can it be achieved?
Is there any way to save the workfile under other name? how can i change the file output without messing with the Natural configuration?
Is there a way to output to the stdout without having those “MORE” prompts? Then, i could capture the stdout without having to store all my data on disk.
Is there a way of READING a file that has not the name of a workfile?
Is there any Natural language construct that could let me store data (as in a linked list) whitout having to store it on disk? If this could be done, it would be very helpfull.
[/b]
I think the only way to do something “like that” in Natural (ie storing data in a place with dinamical storage capacity) is using work files. I’m right?
The mistake is: video is not equal to stdout!
format PS=0 uses the page size of the physical device. If you output to video, you use the number of lines on your display. Output to another unix device (except video!) and it will work.
But why do you print the data you want to capture? Why do you not write it to a work file?
How many times have you done, for example,
ls | grep -e ‘myfile’, or
who | grep ‘user’, or
ps | grep ‘something’
and things like that?
I have a multiuser enviroment and sometimes it’s really a pain to use workfiles, because i don’t really know if i’m breaking the workfile another user is using.
if i had the posibility of using the pipe (|) to redirect natural output, i wouldn’t need to use workfiles.
Then you can define a printer script LPTnn that echoes all input from STDIN to STDOUT. That’s the normal NATURAL way to do things in UNIX.
The reason for your problems is: Natural normally uses block oriented devices and UNIX uses character oriented devices. So Natural emulates block oriented devices in UNIX and that’s a real problem for UNIX people.
One method is to redirect a work- or printfile to /dev/stdout. But Natural uses STDOUT for displaying the Natural version etc. But Natural doesn’t use STDERR. So please try the follwing:
Write a little program to produce some lines of output on STDERR. For example:
define data local
01 #n3 (N3)
end-define
define work file 1 "/dev/stderr" type "ASCII"
for #n3 = 1 to 100
write work file 1 #n3
end-for
close work file 1
end
Save it and type in the following on the linux command line
Another solution is to use the “real batch mode” in Natural. There you are able to redirect all output to STDOUT without defining a workfile. Here’s a sample program again:
define data local
01 #n3 (N3)
end-define
for #n3 = 1 to 100
write notitle #n3
end-for
end
And the command line on Linux/Unix looks like this:
Logon accepted to library MYLIB.
1
2
3
4
...
97
98
99
100
NAT9995 Natural session terminated normally.
Used CPU time: 0 00:00:00.02
Elapsed time: 0 00:00:00.04
With the natural-parameters bmtime=off endmsg=off you can supress the last three lines of the output. But I don’t know a way to suppress the logon-Message at the beginning. Of course | tail +2 would work, but a natural-paramter would be better …