Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Please recommend a scripting language
Please recommend a scripting language [message #32814] Sun, 12 June 2011 21:36 Go to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor

My situation is something like this:

There is a product P (eg. a newspaper); it has variations for each weekday, P1, P2, ..., P7. Now we believe it would be more convenient to let the user just enter P and have my program to translate it to Pi according to today's weekday.

This is trivial if I am satisfied with hardcoding it.

But that might be similar product Q, or even some other ways of translating from one code to another. So using a scripting language to define translations is more suitable in this situation.


I would define a function in U++
int TodaysDayOfWeek()
{
    // return 1 to 7 according to today's date
}

// register this function with the script language engine


and then I can associate a string with P,
   'P' + TodaysDayOfWeek()


Then in my program, I can evaluate this expression using the script language engine to arrive at the intended product code.


Yes, many script language will be able to get system date and get the week day of the date natively, so please think it as a case when the script engine has to rely on an externally defined function.

Esc, v8, python, which comes closer to my requirements? Please offer your insight, thanks!
Re: Please recommend a scripting language [message #32815 is a reply to message #32814] Sun, 12 June 2011 22:36 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
EscApp has provided all capabilities requested by me. For now, I will go with EscApp for its simplicity and ready availability.

Suggestions still welcomed though.
Re: Please recommend a scripting language [message #32816 is a reply to message #32814] Sun, 12 June 2011 22:42 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Lance

I think that the options available in U++ are (you already named few): Esc, V8, JSCore, python and TCC.

I believe all of them can do what you ask for, but some might be better choice than others... I'll give you a really quick summary, maybe it'll help you decide.

Esc: Native U++ solution, lacks documentation, but very easy to work with (the script part).

V8: I'm not really familiar with it, but I think it should work for you... It should be fast and JS is quite simple language as well...

JSCore: Definitely can do what you want, but it is not really developed (actually it was pretty much just an experiment Smile ). It has impractically big codebase.

Python: From what I heard on the forum, the U++ integration is still work in progress...

TCC: Often overlooked package in bazaar. It allows you to use a C code as script by compiling it and running in memory. Binding it to the rest of your code is thus pretty simple Wink

If I were you, I would probably go for Esc or TCC, depending on what exactly I wanted it for...

If I made some mistakes in describing some of the scripting engines above, I'll humbly accept any corrections from those who know more Wink

Best regards,
Honza

Re: Please recommend a scripting language [message #32819 is a reply to message #32816] Mon, 13 June 2011 05:19 Go to previous message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
Thank you, Honza!

Esc is more than enough for me right now. v8/python on the other hand use more popular language. But as it's just simple formula, any user should figure out how to write correct formula giving some examples. I particularly like the ease to extend the language by writing UDF in host language (C++), plus, absolutely no extra steps is required to use it.

BTW, after some hours experiment, it now works exactly as I desired.

I spend some time to figure out a Esc string is an Array. Some more time to figure out instead of "String" + 100, I should use "String" + to_string(100). And to be able to use to_string, I need to call StdLib(...) as demonstrated in EscApp example. And finally, the EscValue::ToString() sandwiches output string in a pair of quotes, I need to remove them to get the String I needed.

Anyway, it only gets faster and better.

Thank you again for your help!
Previous Topic: stl question
Next Topic: MSVC 10 to Upp conversion
Goto Forum:
  


Current Time: Sat Apr 27 22:03:56 CEST 2024

Total time taken to generate the page: 0.02804 seconds