Greg Woodhouse and I were corresponding about this just recently because of 
something I was trying to figure out.  This particular part I thought might 
be helpful to you.   It explains the "WNS" I see when I am importing routines 
with %RI - they are parameters.

**************
Anyway...

When you open a file for writing you normally obtain an exclusive  
lock (or you can't open it), but if you're just going to throw away  
the file contents, gaining an exclusive lock *may* not be necessary  
(hence the "S"[Nancy note- Share]).  The "N" (for new version) means you throw 
away the  file contents on all platforms except VMS. On VMS, you would get a  
series of file versions: TMP.TXT;1, TMP.TXT;2, etc. You can open  
files for reading, writing or both, but opening a file that doesn't  
already exist will normally fail:

USER>O "/tmp/junk.txt":"RW"

O "/tmp/junk.txt":"RW"
^
<INTERRUPT>
USER>D ^%CLI

CLI command: touch /tmp/junk.txt

USER>O "/tmp/junk.txt":"RW"

USER>C "/tmp/junk.txt"

USER>

(The Unix  command "touch" just opens and closes a file, having the  
effect of creating it if it doesn't already exist.) It seems that  
Cache doesn't have a "C" flag, but "N" is semantically equivalent to  
passing the "c" flag to fopen() in C. So, if you prefer, just think  
of "N" as "create".


On Wednesday 16 November 2005 10:31 am, K.S. Bhaskar wrote:
Eddie / Kevin --

IO parameters in M are different for each implementation (yes, the
standard is to be different).  You will have more luck with the GT.M
Programmers Guide
(http://www.sanchez-gtm.com/user_documentation/GTM-PG-UNIX44/index.htm)
in this area.

-- Bhaskar

On Wed, 2005-11-16 at 08:34 -0600, Eddie Hagood wrote:
> Hey all,
>
> This is Kevin T.  I am working with Eddie Hagood, who is new in our
> office and interested in learning M (Great!).
>
> We are going through some example codes, and I am having a hard time
> explaining the OPEN command.  We have R. Walters book, and he gives
> examples like this:
> OPEN 1,2:("C":"DATAFILE.TXT")
> ...
> USE 2 READ RECORD
> ...
>
> I, on the other hand, in the past have found and copied code like
> this:
> SET FNAME="/tmp/mytext.txt"
> OPEN FNAME
> USE FNAME
> WRITE "TEXT OUT GOES HERE."
> USE $P
>
>
> I know that OPEN has LOTS of parameters, but I don't understand the
> "1,2" above.  Is this assigning the output file a device number or
> something?
>
> Also, how do I specify overwriting vs. appending?
>
> Thanks
> Kevin & Eddie.

-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
Hardhats-members mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hardhats-members

-- 
Nancy Anthracite


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
Hardhats-members mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hardhats-members

Reply via email to