Slava Paperno wrote:

> I'm looking for a Lingo equivalent to the eval() or evaluate() function
> that exists in some other languages. It returns a pointer to the variable
> whose name is passed to it as a parameter.
>

Check out http://www.director-online.com/accessArticle.cfm?id=884 for a
detailed look at the value() function.

>
> This would be handy, e.g., in parsing a preferences file:
>
> [Settings]
> intFontSize=12
> strFontName="Times New Roman"
> ...
>
> I could read these pairs and so long as my variables are named
> "intFontSize", "strFontName" etc., it would be a cinch to set the
> variables' values to the settings from the pref file:
>
> the itemDelimiter = "="
> varName = the first item of strPrefs.line[i]
> varValue = the last item of strPrefs.line[i]
> eval(varName) = Trim(varValue)

Here is another approach to the above.
Instead of parsing through a bunch of lines like above you can make use of
the fact that the value function can turn a property string into a list in
one easy step.
Then you can have your settings be properties in a list something like

[Settings]
[#intFontSize:12, #strFontName:"Times New Roman"]

gSettings=eval(strPrefs.line[i])

then to call your preference values during runtime
gSetting.intFontSize or gSetting.strFontName

saving settings also becomes a snap since you can convert your list to string
with
string(gSettings)

HTH

Rob



[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to