I have been using a very old clipper code for saving and restoring array to and from text file. It auto recurse itself if array is multidimensional. I have found it useful still in Xbase++ and HMG codes.
I have attached the same as it may be useful to members requiring the same.
Regards,
Anand
saving and restoring array to and from text file
Moderator: Rathinagiri
saving and restoring array to and from text file
- Attachments
-
- SaveArray.zip
- (1.52 KiB) Downloaded 295 times
Re: saving and restoring array to and from text file
Good code, in good old Clipper!
Luckily, an even better successor has followed.
FYI, Harbour includes a very powerful pair of functions,
with which you can achieve exactly the same functionality,
but with only two lines of code, although, If you're less "brave"
and more cautious, you might want to add two more lines for error-checking.
here is:
(it's amazing to see how evolution can make programmer's life easier,
although, the opposite is some times true also, unfortunately...)
regards,
Pete
Luckily, an even better successor has followed.
FYI, Harbour includes a very powerful pair of functions,
with which you can achieve exactly the same functionality,
but with only two lines of code, although, If you're less "brave"
and more cautious, you might want to add two more lines for error-checking.
here is:
Code: Select all
//save array
hb_MemoWrit( "arr.txt", hb_Serialize( aArray ) )
// restore
aArray := hb_Deserialize( hb_MemoRead( "arr.txt" ) )
although, the opposite is some times true also, unfortunately...)
regards,
Pete
Re: saving and restoring array to and from text file
Hi Pete, thanks for the tip.
The difference is that hb_Serialize output is non-human readable but can handle all types.
Though it does not matter if read/save is done by computer. Only if we need to check the values, say in a backup folder.
Now same Serialize logic is available in different language platforms and I use it.
I wanted array to save in something human readable, but obviously it can handle only standard types.
Regards,
Anand
The difference is that hb_Serialize output is non-human readable but can handle all types.
Though it does not matter if read/save is done by computer. Only if we need to check the values, say in a backup folder.
Now same Serialize logic is available in different language platforms and I use it.
I wanted array to save in something human readable, but obviously it can handle only standard types.
Regards,
Anand