× 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.



Your calls to lseek() don't make any sense. What is -7 supposed to do?!

There are 3 parameters to lseek()

a) The file descriptor/handle (the thing returned by open())
b) The offset (position) to seek to.
c) where to base that offset from (the start of the file? The end of the file? The current position?)

That 3rd parameter has 3 possible values, which according to POSIX standards should be represented by the following 3 constants:

D SEEK_SET C CONST(0)
D SEEK_CUR C CONST(1)
D SEEK_END C CONST(2)

SEEK_SET means that the offset is from the start of the file.
SEEK_CUR means that the offset is from the current position
SEEK_END means that the offset is from the end of the file.

So if you want to advance 8 bytes from your current position, you'd do this:

lseek(FD: 8: SEEK_CUR);

Here's a page that documents this in a little more detail:
http://www.scottklement.com/rpg/ifs_ebook/random.html#SEEKING

For some reason, you're passing the number 8 for the number of bytes to move, and the number -7 for the place to start from. I have no clue what that'd do since -7 isn't a valid value for the 3rd parameter. I suspect that it's assuming that you want to move from the current position, and therefore moving you 8 bytes.

It's unclear to me what your routine is SUPPOSED to do, so it's hard for me to tell you how to fix it.


Booth Martin wrote:
I am having fun with writing to the IFS but now its time to update a an IFS file and its not going as easil;y as I expected.

I want to see if a specific string is in the first 500 columns of the file, and if the string is found, replace the string with another value. For now, the two strings are the same length if that makes a difference.

Here's what I have currently. It works, but not correctly.
eval wSeeking = 'ho ho ho'
for wNdx = 1 to 500 callp lSeek(FD: 8: -7) callp Read(FD: %addr(wValue): 8) if wValue = wSeeking eval wNewValue = 'hee hee ' callp lSeek(FD: 8: -7) callp Write(FD: %addr(wNewValue): 8) endif endfor
One problem I know I am having is that I am setting the file over by 8, not by 1.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.