fast loading of variables from file (taken from old forum)

Code tips and tricks for beginners
Post Reply
Posts: 6
Joined: Sun Mar 21, 2021 8:38 am
Has thanked: 50 times
Been thanked: 14 times

fast loading of variables from file (taken from old forum)

Post by MarioL »

in some programs it is necessary to load the values from a file and assign these to the variables in the shortest time,
this is likely the fastest method.
I used the command COMMAND temp$, temp $ is a string loaded from the file as "var1 = nnn : var2 = nn : ...... var$ = "pippo"

in alcuni programmi è necessario caricare i valori da un file ed assegnarli alle variabili nel minor tempo possibile,
questo, forse, è il metodo più veloce.
Ho usato il comando COMMAND temp$, temp$ e una stinga caricata dal file del tipo "var1 = nnn : var2 = nn : ...... var$ = "pippo"

Code: [Local Link Removed for Guests]

 'fast loading of variables from file

intValCh1 = 255  'Value data channel 1
intValCh2 = 127  'Value data channel 2
intValCh3 = 63  'Value data channel 3
intValCh4 = 31  'Value data channel 4
intValCh5 = 15  'Value data channel 5
intValCh6 = 128  'Value data channel 6
intValCh7 = 64  'Value data channel 7
intValCh8 = 32  'Value data channel 8
intValCh9 = 16  'Value data channel 9
intValCh10 = 8  'Value data channel 10
intValCh11 = 4  'Value data channel 11
intValCh12 = 1  'Value data channel 12
intValCh13 = 0  'Value data channel 13
intValCh14 = 7  'Value data channel 14
intValCh15 = 3  'Value data channel 15
intValCh16 = 222  'Value data channel 16

noteSt1$  = "Nota di lunghezza variab"

html | SET01:| + BUTTON$("RECALL",lblRCL01,"IDbutRcl") + TEXTBOX$(noteSt1$,"IDtxtNoteS") + BUTTON$("SAV",lblSAV01)


'************************************** SAVE AND RECALL SETTING *********************************
t1 = millis
filename$ = "/PRST01.TXT"
noteSt$ = |:noteSt1$="|+noteSt1$+|"|
gosub lblWriteFileSet
print "t save1 ="; millis-t1

lblWriteFileSet:  'write setting file 
Testo$ = "intValCh1=" + STR$(intValCh1) + ":intValCh2="+ STR$(intValCh2) + ":intValCh3="+ STR$(intValCh3) + ":intValCh4="+ STR$(intValCh4) 
Testo$ = Testo$ + ":intValCh5="+ STR$(intValCh5)+ ":intValCh6="+ STR$(intValCh6) + ":intValCh7="+ STR$(intValCh7) + ":intValCh8="+ STR$(intValCh8)
Testo$ = Testo$ + ":intValCh9="+ STR$(intValCh9) + ":intValCh10="+ STR$(intValCh10)+ ":intValCh11="+STR$(intValCh11) + ":intValCh12="+ STR$(intValCh12)
Testo$ = Testo$ + ":intValCh13="+ STR$(intValCh13) + ":intValCh=14"+ STR$(intValCh14)+ ":intValCh15="+ STR$(intValCh15)+ ":intValCh16="+ STR$(intValCh16)+ noteSt$
FILE.SAVE filename$, Testo$

t1 = millis
temp$ = FILE.READ$("/PRST01.TXT")
command temp$
print "t recall1 ="; millis-t1
@t vW
Posts: 10
Joined: Tue Feb 23, 2021 8:00 pm
Location: Hoorn Holland (Netherlands)
Has thanked: 44 times
Been thanked: 2 times

Re: fast loading of variables from file (taken from old forum)

Post by @t vW »

Sorry, but does not look very attractive, (but instead, complicated).
No doubt because I'm not very familier with it.
User avatar
Posts: 272
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 54 times
Been thanked: 127 times

Re: fast loading of variables from file (taken from old forum)

Post by Electroguard »

MarioL's point is worth clarification - so In a nutshell...
Nearly all of his example is just lots of sample variables=data being saved to file as a single concatenated string$ using the : (colon) character.
So it serves only as lots of example data for demonstrating the point he is making.

His actual point is that multiple saved 'variable=value' pairs of data can be combined into a single string for sending to the COMMAND instruction to process with just a quick single command... instead of slowly reading in and processing every individual variable=data pair.
Post Reply