|
Post by Walt Decker on Sept 1, 2022 16:11:06 GMT -5
COPYFILE(FromPath$, ToPath$)
SETEOF(#FILENUM) for BINARY and RANDOM ACCESS files
|
|
|
Post by Brandon Parker on Sept 1, 2022 20:36:20 GMT -5
Well, just so people know that there are options for the first one. What is your use case in Liberty BASIC for the setEOF() function?
originalFile$ = "Original Filename and Path Here" newFile$ = "New Filename and Path Here"
Print CopyFile(originalFile$, newFile$) End
Function CopyFile(fromPath$, toPath$) On Error GoTo [Error] Open fromPath$ For Binary As #CopyFile fileData$ = Input$(#CopyFile, LOF(#CopyFile)) Close #CopyFile Open toPath$ For Output As #CopyFile #CopyFile fileData$ Close #CopyFile Exit Function [Error] CopyFile = err Notice "Error [";err;"] - ";err$ End Function
{:0)
Brandon Parker
|
|
|
Post by Walt Decker on Sept 2, 2022 8:59:16 GMT -5
Assume a file of X bytes. I want to truncate the file to X - some bytes. I can do so by using API provided I write the file using API, but not via LB syntax.
|
|
|
Post by Brandon Parker on Sept 2, 2022 17:44:53 GMT -5
Will this work for what you want to do?
filePath$ = "Filename and Path Here" truncateAt = Your length here
Print TruncateBinaryFile(filePath$, truncateAt) End
Function TruncateBinaryFile(filePath$, truncateAt) On Error GoTo [Error] Open filePath$ For Binary As #TruncateFile truncatedData$ = Input$(#TruncateFile, truncateAt) Close #TruncateFile Open filePath$ For Output As #TruncateFile #TruncateFile truncatedData$ Close #TruncateFile TruncateBinaryFile = truncateAt Exit Function [Error] TruncateBinaryFile = err Notice "Error [";err;"] - ";err$ End Function
{:0)
Brandon Parker
|
|
|
Post by Walt Decker on Sept 4, 2022 17:03:57 GMT -5
No, I do not want to destroy the remaining data.
I can do it using API, but it would be handy if LB had a function that would do it.
|
|
|
Post by Brandon Parker on Sept 5, 2022 0:37:19 GMT -5
Have you tried adding an ASCII 26 at the location you want to stop the reading process?
{:0)
Brandon Parker
|
|
|
Post by Walt Decker on Sept 5, 2022 14:16:03 GMT -5
Have you tried adding an ASCII 26 at the location you want to stop the reading process? {:0) Brandon Parker
No. Duh, I did not see the obvious. Matter of fact, I forgot that I have a complete list of ANSI control codes.
Thank you.
|
|