Previous Thread
Next Thread
Print Thread
ABSLOOKUP vs NOABSLOOKUP #37352 04 Jun 24 03:30 PM
Joined: Sep 2002
Posts: 5,471
F
Frank Online Content OP
Member
OP Online Content
Member
F
Joined: Sep 2002
Posts: 5,471
Good day -
Apparently we are using ABSLOOKUP but i need to determine if a file is sequential or random - is there another way? TIA

ps: temporarily i just disabled for this session

Last edited by Frank; 04 Jun 24 03:32 PM.
Re: ABSLOOKUP vs NOABSLOOKUP [Re: Frank] #37355 04 Jun 24 04:43 PM
Joined: Jun 2001
Posts: 11,794
J
Jack McGregor Offline
Member
Offline
Member
J
Joined: Jun 2001
Posts: 11,794
For better or worse, there's no physical distinction in any of the Linux and Windows file systems between what we call "random" and "sequential" files. So it's literally impossible to definitely distinguish between them; it's really just a matter of how you access it.

That said, unless you set OPTIONS=EXTFIO, "random" files must be a multiple of 512 bytes, and that is what LOOKUP uses to decide the file type.

You can make that determination yourself by using something like XCALL SIZE or MX_FILESTATS that returns the file size in bytes rather than blocks, perhaps wrapped in a user function Fn'Is'File'Random(fspec). But just be aware that there's a 1 in 512 chance that a "sequential" file will be a multiple of 512 bytes. If that's too big of a risk, then you could add additional logic to your wrapper function, inspired perhaps by the Linux file command, examining the file data for clues. (Note that you'd probably open it up for INPUT, i.e. as a sequential file, and then use some kind of raw input method such as INPUT RAW or XCALL GET to look for indicators such as chr(10), maybe embedded nulls, etc. to help make confirm your determination.

p.s. FWIW, if you do decide to just temporarily disable ABSLOOKUP, you could do it programmatically with MX_SETOPTIONS

Re: ABSLOOKUP vs NOABSLOOKUP [Re: Frank] #37356 04 Jun 24 04:45 PM
Joined: Sep 2002
Posts: 5,471
F
Frank Online Content OP
Member
OP Online Content
Member
F
Joined: Sep 2002
Posts: 5,471
Thanks Cap smile


Moderated by  Jack McGregor, Ty Griffin 

Powered by UBB.threads™ PHP Forum Software 7.7.3