Opening a known file name

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

Post Reply
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Opening a known file name

Post 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.
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Opening a known file name

Post by andyglezl »

Ya trataste con esto ?
+-------------------------
Have you tried this yet?

RESTORE FROM "c:\hmgstorage\myarrays.mem"
Andrés González López
Desde Guadalajara, Jalisco. México.
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Re: Opening a known file name

Post 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.
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Opening a known file name

Post 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
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Re: Opening a known file name

Post 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
User avatar
Anand
Posts: 595
Joined: Tue May 24, 2016 4:36 pm
DBs Used: DBF

Re: Opening a known file name

Post 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
Regards,

Anand

Image
Post Reply