New topic: Question about formulas inside text boxes...
<http://forums.realsoftware.com/viewtopic.php?t=47247> Page 1 of 1 [ 8 posts ] Previous topic | Next topic Author Message Primoz128 Post subject: Question about formulas inside text boxes...Posted: Sun Mar 10, 2013 2:01 pm Joined: Sun Oct 21, 2012 10:47 am Posts: 56 Location: Slovenia Well i want to be able to type in the formula like this: ( (480*480 / 100) into the text box, and then return it's value with the below code via a push button: dim formula as double formula = val(TextField_graphics.Text) MsgBox( str(formula) ) And then i want that formula to be executed like a math equation you know... and i see the results... What i got from the above code is result: 0. Any ideas ? Top ktekinay Post subject: Re: Question about formulas inside text boxes...Posted: Sun Mar 10, 2013 2:27 pm Joined: Mon Feb 05, 2007 5:21 pm Posts: 520 Location: New York, NY I did exactly this with a class based on RBScript. Basically, it turns your text into an RBScript, runs that script, then returns the value as a Variant. I designed it to be safe (no multiple lines or extra code allowed), but to understand functions and the like. Let me know if you want it. Note that adding RBScript to your project increases the app size noticeably. _________________ Kem Tekinay MacTechnologies Consulting http://www.mactechnologies.com/ Need to develop, test, and refine regular expressions? Try RegExRX. Top Primoz128 Post subject: Re: Question about formulas inside text boxes...Posted: Sun Mar 10, 2013 2:38 pm Joined: Sun Oct 21, 2012 10:47 am Posts: 56 Location: Slovenia Im making a calculator for something personall, and i don't require speed nor size to be optimized. And yes i would very appreciate if you gave me the script. I am barely touching Real Studio, but i will more in the future, thus im really bad at it atm. (Getting my life together <.<... not an easy task <.<) Top ktekinay Post subject: Re: Question about formulas inside text boxes...Posted: Sun Mar 10, 2013 2:45 pm Joined: Mon Feb 05, 2007 5:21 pm Posts: 520 Location: New York, NY See here: https://dl.dropbox.com/u/26920684/Evaluator.zip Also included is an AppleScript-based Evaluator. _________________ Kem Tekinay MacTechnologies Consulting http://www.mactechnologies.com/ Need to develop, test, and refine regular expressions? Try RegExRX. Top Primoz128 Post subject: Re: Question about formulas inside text boxes...Posted: Sun Mar 10, 2013 3:14 pm Joined: Sun Oct 21, 2012 10:47 am Posts: 56 Location: Slovenia What if the program decides to say it cannot find the applescript ? What do i do then ? Top ktekinay Post subject: Re: Question about formulas inside text boxes...Posted: Sun Mar 10, 2013 3:15 pm Joined: Mon Feb 05, 2007 5:21 pm Posts: 520 Location: New York, NY Oh, that might be based on the MBS plugins. You can just delete that class. _________________ Kem Tekinay MacTechnologies Consulting http://www.mactechnologies.com/ Need to develop, test, and refine regular expressions? Try RegExRX. Top Primoz128 Post subject: Re: Question about formulas inside text boxes...Posted: Sun Mar 10, 2013 4:40 pm Joined: Sun Oct 21, 2012 10:47 am Posts: 56 Location: Slovenia Idk, if i delete it, then another 20 errors pop... Top ktekinay Post subject: Re: Question about formulas inside text boxes...Posted: Sun Mar 10, 2013 4:51 pm Joined: Mon Feb 05, 2007 5:21 pm Posts: 520 Location: New York, NY Right, all in the test code. You can comment out those lines, or just examine them to see how the class should be used. _________________ Kem Tekinay MacTechnologies Consulting http://www.mactechnologies.com/ Need to develop, test, and refine regular expressions? Try RegExRX. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 8 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
