Source language: Translate to:

Save variables

Post your suggestions for future versions of NeoBook

Moderator: Neosoft Support

Save variables

Postby smartmedia » Sat Sep 10, 2011 1:46 am

Hi..

So far SaveVariables command saves all active variables into file. Is possible to save only the variables you want..??? Like the ClearVariables do, separated by coma.

This way you can use the method as a parameter storage without using Registry or INI files.

Thanks
User avatar
smartmedia
 
Posts: 889
Joined: Fri Apr 01, 2005 6:50 am
Location: Hellas

Postby Gaev » Sat Sep 10, 2011 4:27 am

smartmedia:

As long as you don't need to specify Variables to be Saved via a mask (e.g. abcd* or p?qrs) ... and you are prepared to specify each element of an Array Variable, here is a solution ...
Code: Select all
... populate some variables
SetVar "[abc]" "value of abc"
SetVar "[xyz]" "value of variable xyz"
SetVar "[First Name]" "content of First Name"
... setup parameters and call the routine
SetVar "[SaveVariables]" "abc,xyz,pqr4567,First Name"
SetVar "[SaveVariablesFile]" "!mySaves1.txt"
GoSub "SaveVariables"
... verify what was saved
FileRead "[SaveVariablesFile]" "All" "[SaveVariablesResult]"
AlertBox "File Content" "[SaveVariablesResult]"
... you can further reduce the 3 lines ...
Code: Select all
... setup parameters and call the routine
SetVar "[SaveVariables]" "abc,xyz,pqr4567,First Name"
SetVar "[SaveVariablesFile]" "!mySaves1.txt"
GoSub "SaveVariables"
... needed to trigger this ... to one line by converting the SubRoutine to a Function that can be called with a command like ...
Code: Select all
Call "gkSaveVariables" "[SaveVariables]" "[SaveVariablesFile]"


Here is the SubRoutine code ...
Code: Select all
:SaveVariables
... uses [SaveVariables] and [SaveVariablesFile]
FileExists "[SaveVariablesFile]" "[SaveVariablesFileExists]"
If "[SaveVariablesFileExists]" "=" "True"
   FileErase "[SaveVariablesFile]"
EndIf
StrParse "[SaveVariables]" "," "[SaveVariablesList]" "[SaveVariablesCount]"
Loop "1" "[SaveVariablesCount]" "[SaveVariablesCurrent]"
  SetVar "[SaveVariablesName]" "[SaveVariablesList[SaveVariablesCurrent]]"
  SetVar "[SaveVariablesValue]" "[[SaveVariablesName]]"
  If "[SaveVariablesValue]" ">" ""
     FileWrite "[SaveVariablesFile]" "Append" "[SaveVariablesName]=[SaveVariablesValue]"
  EndIf
EndLoop

Return
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby smartmedia » Sat Sep 10, 2011 5:19 am

Hi..

The reason i suggest it is to make our life simple. I can do it with 10 different ways, registry - INI - FileWrite - Database.

Thanks any way for your suggestion.
User avatar
smartmedia
 
Posts: 889
Joined: Fri Apr 01, 2005 6:50 am
Location: Hellas

Postby Neosoft Support » Mon Sep 12, 2011 11:05 am

So far SaveVariables command saves all active variables into file. Is possible to save only the variables you want..??? Like the ClearVariables do, separated by coma.


That's a good idea - I'll add it to our list. In the mean time, I think (as Gaev suggests) you should be able to do something similar with a subroutine or function.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5602
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby dec » Tue Sep 13, 2011 8:21 am

Hi,

I like the suggestion so put an "npSaveVariables" action into the npUtil plugin.

Thanks!
.
Enhance your NeoBook applications!
.
58 plugins, 1131 actions and 233 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain


Return to NeoBook Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest