[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

RE: [sqr-users] renaming an input file?



SQR has a RENAME builtin command:

Renames old_filename to new_filename. The function returns either a zero (0)
to indicate success or the value returned from the operating system to
indicate an error. 

Syntax:         stat_var        =       rename(old_filename, new_filename) 
        old_filename    =       text literal, column, variable, or
expression. 
        new_filename    =       text literal, column, variable, or
expression. 
        stat_var        =       decimal, float, or integer variable.

Example:        let #fstatus = rename($old_filename, $new_filename) 

Function arguments are enclosed in parentheses and can be nested.  Arguments
referenced as x, y, and z indicate the first, second, and third argument to
a function.  Otherwise, functions take a single argument.
Use parentheses to override the normal precedence rules.

Hope this helps!

-----Original Message-----
From: sqr-users-bounces+bbeckner=icc.edu@sqrug.org
[mailto:sqr-users-bounces+bbeckner=icc.edu@sqrug.org] On Behalf Of
john.tucker@oracle.com
Sent: Tuesday, October 25, 2005 12:46 PM
To: sqr-users@sqrug.org
Subject: [sqr-users] renaming an input file?

I am once again writing the group on a question I already have an answer to,
just to see if someone has a better answer.  I am writing an interface that
reads an incoming file.  To prevent someone from running a given file more
than once, I need to rename the incoming file after I'm done with it.
Here's how I've thought to do it, in pseudo-code:

Open file.txt as 10 for-reading record=2226:fixed ...
Open renamedfile.txt as 20 for-writing record=2226:fixed ...

read a line from 10
write the line to 20

do whatever else I need to with the line

loop through until I'm done with the file

Close 10
Close 20

Open file.txt as 30 for-writing record=2226:fixed ...

write one blank line to 30
Close 30

Clearly (unless my pseudo-code is unreadable), this will get the job done,
but I just feel like it's a bit cheesy.  I'm guessing that this is a fairly
common thing to do, and I may be simply missing something incredibly
obvious.  Please let me know if any of you have a suggestion on a better way
for me to accomplish this.  Thanks!

-John T.


_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users

_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users