Opening a known file name

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

Post Reply
bluebird
Posts: 166
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF
Has thanked: 49 times
Been thanked: 7 times

Opening a known file name

Post by bluebird » Sat Jun 15, 2019 10:57 pm

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: 1149
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 35 times
Been thanked: 68 times
Contact:

Post by andyglezl » Sun Jun 16, 2019 4:12 am

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: 166
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF
Has thanked: 49 times
Been thanked: 7 times

Post by bluebird » Sun Jun 16, 2019 5:41 pm

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: 3196
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 214 times
Been thanked: 120 times
Contact:

Post by mol » Sun Jun 16, 2019 6:16 pm

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: 166
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF
Has thanked: 49 times
Been thanked: 7 times

Post by bluebird » Mon Jun 17, 2019 5:34 am

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: 393
Joined: Tue May 24, 2016 4:36 pm
DBs Used: DBF
Has thanked: 105 times
Been thanked: 57 times

Post by Anand » Tue Jun 18, 2019 10:19 am

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
Image

Post Reply