Eval function

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
serge_girard
Posts: 3308
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Eval function

Post by serge_girard »

Long time ago I had some function to calculate simple formulas directly but I cannot find it ...

Input text field (example): 25 + 2 * (2/4)
Button to calculate result into MSGINFO .

Something like this:

Code: Select all


LOCAL SOM := Form_REPKAL.T2_SOM.Value   
bBlock := { SOM }                       
MSGINFO (EVAL(bBlock))                  
RETURN                                  
Just like the old dBase prompt ? 25 + 2 * (2/4) would return result

Serge
There's nothing you can do that can't be done...
User avatar
Rathinagiri
Posts: 5480
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Eval function

Post by Rathinagiri »

Code: Select all

   som := '25 + 2 * 2/4'
   bBlock := { || &som }
   msginfo( eval( bBlock ) )
The above code gave me the desired result of 26. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
serge_girard
Posts: 3308
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Eval function

Post by serge_girard »

Thanks Rathi !

The & ampersand miracle !!!

Serge
There's nothing you can do that can't be done...
Post Reply