A "ByteArray" is just a stream of Bytes (i.e. a file) and you can address any position directly by offset.
cBytes = FileToStr(Getfile()) ? LEN(cBytes)
cBytes = STUFF(cBytes, 5648, 5, "Hello") && replace 5 Bytes at 5648 with a string; or insert or delete bytes. See help on that STUFF :)
StrToFile(cBytes, PutFile()) && write Bytestream back to disk with new name
Another option is just using LLFFs (LowLevelFileFunctions):
nHandle = FOPEN(GetFile()) FSEEK(nHandle, 5648, 0) FRWITE(nHandle, "Hello") FCLOSE(nHandle)
wOOdy
-----Ursprüngliche Nachricht----- Von: ProFox profox-bounces@leafe.com Im Auftrag von Joe Yoder Gesendet: Dienstag, 2. Mai 2023 04:33 An: profoxtech@leafe.com Betreff: Byte Arrays in VFP
I want to pull a 3.5 meg file into a Byte Array in Fox, make some changes to individual bytes, and write the array back to another file. The only way I have found to do so is to build the array one character at a time. Is there a better way to do this? Thanks in advance for any input ,
Joe
[excessive quoting removed by server]