× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.






Thanks everyone for your response!  Much easier than I thought.  Scott's
code snip really helps me understand since I already had those constants
defined.
I have seen many references to Scott's website in the past but I never
really looked in depth.  I think I should start doing that.  :)
I plan on doing the open and probably wrapping it separately and making a
command like CLRLNK.  That way, others could use it from their CL easily.
By clearing the files we will ensure that we don't pull previous data
populated by software.
Deleting and recreating probably wouldn't work very smooth as pointed out
with ensuring permission, CCSID, etc.

Craig

**Scott wrote:
Hi Craig,

> Anyone know of a command or a good way to clear an IFS file?  I probably
> need to open(), read(), close() but I am not sure how to clear.

If your application uses open(), specify the O_TRUNC flag and the file
will be cleared.

for example, this command opens a file for output only, clears it, and
converts from the current job's CCSID to the file's CCSID when writes are
done:
          x = open('/path/to/myfile': O_WRONLY+O_TRUNC+O_TEXTDATA)

If your application uses fopen(), you achieve the same result with the 'w'
flag.  For example:

          p = fopen('/path/to/myfile': 'w')

> DEL deletes the file but I want to keep the file empty.  Maybe something
> similar to CLRPFM.  The best way I know of is to use DEL and then
> recreate. Any thoughts?

It depends.  If you want to re-set the file's permissions and CCSID each
time you open it (which is often desirable) then you want to delete it and
re-create it.  That will ensure that it has the CCSID and permissions that
you specify.

If you want to always keep the same CCSID and permissions that it had
before, rather than hard-coding them into your program, then you'd be
better of clearing the file instead of deleting it.

> Anyone have some good examples of updating an IFS file similar to the
> RPG update, write, delete, etc?

I wrote a tutorial on it:
http://www.scottklement.com/rpg/ifs.html

Good Luck


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.