Evaluate string?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Evaluate string?
I haven't been able to find an answer to this, so I figured I'd check here.
Is it possible to evaluate a string?
Let's say a string contains "put 1 into bla", I'd like to evaluate the string as if it was written in a regular script.
The longer story is that I'd like to be able to let users write scripts that can be read and run at runtime, using LiveCode, rather than having to write an interpreter in LiveCode to... LiveCode.
Is it possible to evaluate a string?
Let's say a string contains "put 1 into bla", I'd like to evaluate the string as if it was written in a regular script.
The longer story is that I'd like to be able to let users write scripts that can be read and run at runtime, using LiveCode, rather than having to write an interpreter in LiveCode to... LiveCode.
Marcus
Re: Evaluate string?
Hi Marcus,
you are looking for DO:
...
put "put 1 into bla" into tCommand
do tCommand
put bla
## -> gives 1
...
Best
Klaus
P.S.
TRY is your friend when dealing with USER INPUT this way!
you are looking for DO:
...
put "put 1 into bla" into tCommand
do tCommand
put bla
## -> gives 1
...
Best
Klaus
P.S.
TRY is your friend when dealing with USER INPUT this way!
Re: Evaluate string?
Thanks Klaus, I'll give that a go
I don't know how many beers I owe you at this point, but it's a few!
I don't know how many beers I owe you at this point, but it's a few!
Marcus
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Evaluate string?
If you want them to script in LiveCode why not just give them LiveCode?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 9669
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Evaluate string?
Hi.
Know that when including parameters with function or command calls, each is fully evaluated before being passed:
You get a pair of "22"s
Craig Newman
Know that when including parameters with function or command calls, each is fully evaluated before being passed:
Code: Select all
on mouseUp
doubleTheArgs 5 + 6,sum(5,6)
end mouseUp
on doubleTheArgs var1,var2
answer var1 * 2 && var2 * 2
end doubleTheArgs
Craig Newman
Re: Evaluate string?
Richard, it's to let others code in LiveCode in order to write small scripts which can be loaded and runtime.
I'm working on a modular testing-engine, it's nice to be able to write small scripts and just drop them into a folder and have them automatically picked up and run, instead of telling other coders to download the software, write new tests, compile for all the platforms, distribute the new binary with the new tests, and make sure everyone has the right version.
Or, just share a set of test files.
The engine is right now written in CFML and does exactly this, tests are written as components and just dropped into a folder containing all tests, the target directories are traversed and each file read, then passed on to each test which returns a bunch of data.
Writing new tests just means writing new components and dropping them in.
I want to do the same but in LiveCode, so a big thing is to be able to just write tests and have them automatically picked up.
I'm working on a modular testing-engine, it's nice to be able to write small scripts and just drop them into a folder and have them automatically picked up and run, instead of telling other coders to download the software, write new tests, compile for all the platforms, distribute the new binary with the new tests, and make sure everyone has the right version.
Or, just share a set of test files.
The engine is right now written in CFML and does exactly this, tests are written as components and just dropped into a folder containing all tests, the target directories are traversed and each file read, then passed on to each test which returns a bunch of data.
Writing new tests just means writing new components and dropping them in.
I want to do the same but in LiveCode, so a big thing is to be able to just write tests and have them automatically picked up.
Marcus
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Evaluate string?
Super cool. Is that for the LiveCode community or something else?trenatos wrote:I'm working on a modular testing-engine, it's nice to be able to write small scripts and just drop them into a folder and have them automatically picked up and run, instead of telling other coders to download the software, write new tests, compile for all the platforms, distribute the new binary with the new tests, and make sure everyone has the right version.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Evaluate string?
Originally it was just for CFML, but I'm thinking of making it a generic test-engine (Thus LiveCode) so you can run it standalone on any platform, using any set of tests you want.
It's a side-project for now, but it's getting a good chunk of my attention, so should have a demo working in the near future.
It's a side-project for now, but it's getting a good chunk of my attention, so should have a demo working in the near future.
Marcus
-
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Evaluate string?
The easiest way would be to let the engine do it. Read in the text file, set the script of a button to it, and then send a mouseUp to the button.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Evaluate string?
This really isn't rocket surgery, I just didn't know how to evaluate strings as code (do).
How about threading? Any chance of threading being available? (That's also something I haven't been able to find information about.
How about threading? Any chance of threading being available? (That's also something I haven't been able to find information about.
Marcus
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Evaluate string?
Some network I/O and animation options are non-blocking, but there is no explicit thread management provided in LiveCode at this time.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Evaluate string?
That's too bad.
Threading could speed things up so nicely (My CFML implementation gained some serious speed when I threaded it)
It's going to be fun comparing the two, how fast can I make the LC implementation go?
Threading could speed things up so nicely (My CFML implementation gained some serious speed when I threaded it)
It's going to be fun comparing the two, how fast can I make the LC implementation go?
Marcus
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Evaluate string?
CFML - this is for Server?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Evaluate string?
Originally I wrote it for testing only CFML code, but with a couple of tweaks I could test any code, so I had the idea of moving from a CFML-based implementation, which requires you to run an OpenBD CFML server, to a multi-platform GUI application with no special pre-requisites.
Ironically I won't be able to run tests against LiveCode code due to their silly choice of going with binary source code rather than clear text, but that's a non-issue.
Ironically I won't be able to run tests against LiveCode code due to their silly choice of going with binary source code rather than clear text, but that's a non-issue.
Marcus
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Evaluate string?
Server scripts can be plain text files.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn