Page 1 of 1

Opening a known file name

Posted: Sat Jun 15, 2019 10:57 pm
by bluebird
Dear Mentors

I am able to save and restore a mem file using Getfile function but
It makes me select a file from a specified folder even if there
is only one such file nd you already know its name?

Is there a way for open a file without the complete dialog?

Ex file myarrrays.mem


as in Fopen(c:\hmgstorage\myarrays.mem instead of getfile(c:\hmgstorage\myarrays.mem) or some such function


Thanks for looking at my queery.

Re: Opening a known file name

Posted: Sun Jun 16, 2019 4:12 am
by andyglezl
Ya trataste con esto ?
+-------------------------
Have you tried this yet?

RESTORE FROM "c:\hmgstorage\myarrays.mem"

Re: Opening a known file name

Posted: Sun Jun 16, 2019 5:41 pm
by bluebird
Thanks for the reply but restore from cannot recall array memvars according to the
Clipper reference. "Arrays and local variables cannot be SAVEd or RESTOREd."

I think there is a function in Harbour somewhere but I can't find a description of it. HB_restore or something like that.

If anyone knows the document describing it please post a reply.

Re: Opening a known file name

Posted: Sun Jun 16, 2019 6:16 pm
by mol
I'm using such a trick to save array in .mem file:

Code: Select all

cTemp := "{ || aArrayToSave := " + hb_valtoexp(aArrayToSave) + "}"
save all like cTemp to "c:\hmgstorage\myarrays.mem"
and a piece of code to restore:

Code: Select all

if file("c:\hmgstorage\myarrays.mem")
	BEGIN SEQUENCE with {|e| break(e)}
	restore from ("c:\hmgstorage\myarrays.mem") additive
	if type(cTemp) <> "U"
		eval(&cTemp)
	endif
	END SEQUENCE
endif

Re: Opening a known file name

Posted: Mon Jun 17, 2019 5:34 am
by bluebird
Well! that's some trick. Its going to take me a while to understand but I'll give it a try.

BTW Where are all those HB functions described? I have seen list of them but no reference to use.

Thanks

Re: Opening a known file name

Posted: Tue Jun 18, 2019 10:19 am
by Anand
I have uploaded code for saving and restoring array to and from text file, you may check it.

viewtopic.php?p=58701#p58701

Regards,

Anand