Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / [DBP] -is there a simple way of reading a string as a line of code?

Author
Message
Kezzla
16
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 19th May 2011 09:03
I want to be able to implement a user defined if statement inside a program.

is there a command that can simply take a string and read it as a line of code to be executed?

I already have a game plan for doing it the long and hard way, I just wonder if there is a far simpler way of going about it.

something like a command I haven't found that does this already.

thank-you
Kezzla

Sometimes I like to use words out of contents
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 19th May 2011 12:33
DBP programs are compiled not interpreted so it's not possible.

You can use Lua to perform this kind of process by writing a lua script dynamically then executing it.

If you tell us more about what you are trying to do then maybe we can find an answer. For example, you may be able to make your own parsing routines to achieve the result.

Kezzla
16
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 19th May 2011 13:54
thanks batvink,
my goal is to make a mockup of an idea I have for a better ebanking system.

so it'll be a program where the user can write a little program within the ebanking to allocate funds and control finances with more finesse than is currently available.
eg



stuff like that, even to divide the cash within one account so I can seperate savings, bills, food, spending money etc. effectivly giving me multiple accounts in one.

Id like to set it up with a code window, so people with a little computer savvy can fine tune their own ebanking to suit them.

Do you think Lua would be best for this?
I havn't got the unity plugin, but Ill have to look into getting it I think.
thanks again
kezzla

Sometimes I like to use words out of contents
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 19th May 2011 18:51
You should be doing these kinds of operations in logic.

For example a bank does not need to write scripted code for each account's overdraft value. Paying the rent is simply a schedule.

You need to think about the transaction types you want to perform, then you can parameterise and code them. For example:

Value based transaction. Parameters = Value, Action
If the balance of account is less than a value then perform an action
If the balance of account is less than a value then perform an action

Date based transaction Parameters = Date (or period), Action
If the date is X then perform action
If the period since last action = X then repeat action

Actions are then defined elsewhere. An action may be "Display Message" or "Make Transfer". Again, the actions are parameterised.

Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 20th May 2011 00:53
This brings back memories of Color BASIC on the Radio Shack Color Computer. You could set up a string towards the end of your program, then do some PEEKing to find the string in memory when the program was being run. Then you could POKE values into the string, changing the string into a statement that would execute when the interpreter got to that part of the program.

Using this technique, I wrote a program that let the user put in an equation, like "3 + 2 - 5 * 6" and the result could be calculated on the fly.

Memories...

Kezzla
16
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 20th May 2011 12:40
cool, Ill do it with logic, thanks guys.
kezzla

Sometimes I like to use words out of contents

Login to post a reply

Server time is: 2024-11-16 21:36:36
Your offset time is: 2024-11-16 21:36:36