|
SEEK
Sept 1, 2022 17:22:29 GMT -5
Post by Walt Decker on Sept 1, 2022 17:22:29 GMT -5
Function SEEK fails with MAPHANDLE:
' MapName$ = "#OTHER" ByteNum = 0
OPEN This$ FOR BINARY AS #THAT
MAPHANDLE #THAT, MapName$
SEEK #MapName$, ByteNum '
|
|
|
SEEK
Sept 1, 2022 22:02:27 GMT -5
Post by Brandon Parker on Sept 1, 2022 22:02:27 GMT -5
This does not appear to be a failure of "Seek" to work with "Maphandle" to me. If you use the actual handle "#OTHER" after the use of "MapHandle" in the code, everything works correctly.
So, instead of the issue being that "Seek" does not work with "MapHandle", the issue is that the "Handle Variable" is not being evaluated when the "Seek" command is issued. In essence, "Function SEEK fails with Handle Variables"...
I am not sure if this has ever been noticed, but it would not surprise me since not too many people tend to use the "Seek" command from what I have observed over the years.
{:0)
Brandon Parker
|
|
|
SEEK
Sept 2, 2022 9:18:50 GMT -5
Post by Walt Decker on Sept 2, 2022 9:18:50 GMT -5
That is correct; however, it is not the variable with which the file was opened. Took me a bit to figure that out before I posted.
Not really. #THAT is the variable with which the file is opened. #OTHER should be empty since it does not equal #THAT; however OTHER$ should equal the value of #THAT. So, it is a failure of correctly evaluating MAPHANDLE variables.
I have not been around LB long, but it is my observation that folks shy away for "BINARY" files. All files are binary. It is the programming system that breaks a file into separate types.
|
|
|
SEEK
Sept 2, 2022 18:05:21 GMT -5
Post by Brandon Parker on Sept 2, 2022 18:05:21 GMT -5
I disagree...
The #OTHER handle should be pointing to what the #THAT handle originally pointed to after the use of the following line:
MAPHANDLE #THAT, MapName$
Using the actual #OTHER handle works perfectly fine from that point on and the #THAT handle is dereferenced and no longer reachable from the LB programmer's perspective.
Here are the tests that I have run so far...
filePath$ = "Your File and Path Here"
'This works Open filePath$ For Binary As #Test MapHandle #Test, #NewHandle Seek #NewHandle, 10 Close #NewHandle
'This works Open filePath$ For Binary As #Test handle$ = "#NewHandle" MapHandle #Test, handle$ Seek #NewHandle, 10 Close #NewHandle
'This does not work 'Notice that the issue lies in the evaluation 'for the handle variable within Seek Open filePath$ For Binary As #Test handle$ = "#NewHandle" MapHandle #Test, handle$ Seek #handle$, 10 Close #NewHandle
'This does not work 'Notice that the second parameter for the MapHandle 'command should be a string and NOT an evaluated handle variable Open filePath$ For Binary As #Test handle$ = "#NewHandle" MapHandle #Test, #handle$ Seek #NewHandle, 10 Close #NewHandle
{:0)
Brandon Parker
|
|