How useful would it be to add string capability to uBASIC? - Script Writing - CHDK Forum
supplierdeeply

How useful would it be to add string capability to uBASIC?

  • 10 Replies
  • 7837 Views
*

Offline zeno

  • *****
  • 891
How useful would it be to add string capability to uBASIC?
« on: 22 / November / 2008, 11:17:54 »
Advertisements
Currently uBASIC only supports integer variables and arithmetic. As a result there are lots of things it can't do (but Lua can). I've been looking at how easy it would be to add string handling to uBASIC and it doesn't look too hard (nor would it consume much memory). The sort of extensions I have in mind would add:

1. 26 (or 52) new variables - a$ - z$
2. the 'standard' BASIC string functions (left$, right$, mid$, chr$, len, asc, intstr, val for example)
3. string comparisons - e.g. 'if (right$(a$,4) = ".jpg") then ...
4. string expressions in the print statement
4. some new CHDK functions that return strings - eg. 'buildinfo()' and perhaps some i/o functions

It's not clear to me if this is a waste of time given that Lua lets you do all this now. What do you scripters think?
A570, S100, Ixus 127
Author of ASSIST, STICK, WASP, ACID, SDMInst, LICKS, WICKS, MacBoot, UBDB, CFGEdit

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: How useful would it be to add string capability to uBASIC?
« Reply #1 on: 25 / November / 2008, 18:58:50 »
hm, there is not much response here, so my educated guess is that interest in this feature is not very big.
if it isnt very hard like you said, and it doesnt consume much memory, well then do it.
me, personally, i still prefer ubasic over lua because i am used to it, not because i think it is better. adding string capability to ubasic will probably help people like me, who dont wanna use lua because it SEEMS to be more complicated.
however, imo ubasic will be abandoned in the long run, i mean, having to script languages on an embedded device doesnt really make sense. now that we don't have hit the boundaries of chdk (in terms of binary size), ubasic and lua can still coexist peacefully.

you really think it isnt that hard? even i/o?
btw you also have to consider: if you now introduce string and i/o compatibility to ubasic, it will be much harder having to switch to lua for people who are used to ubasic, one day when we have to kick out one of these languages.
anyhow, thanks for your work :)

*

Offline reyalp

  • ******
  • 14118
Re: How useful would it be to add string capability to uBASIC?
« Reply #2 on: 26 / November / 2008, 01:03:41 »
IMO, anyone who is writing new, complex scripts should be using lua. The only reason ubasic is "easier" than lua is the limitations.  If you write your lua code like ubasic, it isn't any more complicated (unless you are addicted to goto).

If you add a bunch more stuff to ubasic, it will no longer be simple, but the result is unlikely to be as well designed or implemented as lua is.

If you really want to do it, and it doesn't add too much bloat... sure why not. OTOH, spending the same amount of time on some other code might be a better contribution.
Don't forget what the H stands for.

*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: How useful would it be to add string capability to uBASIC?
« Reply #3 on: 26 / November / 2008, 03:29:39 »
We should remember our time (your time, in this case) is the most valuable resource for CHDK and optimize its use.

Can you think of other areas where you have the abilities and time to work and where the benefits to the project would be larger?

Last point (not less important): would working in that areas be more or less fun for you?



*

Offline zeno

  • *****
  • 891
Re: How useful would it be to add string capability to uBASIC?
« Reply #4 on: 26 / November / 2008, 04:33:33 »
It's pretty clear there's not much call for it, though I've done the work anyway, just for fun. My reasoning (clearly faulty) was that there are lots of people familiar with the BASICs that came on early personal computers who would find it easier to write scripts that needed strings with uBasic rather than Lua.

I don't intend submitting the mod for general inclusion, but will make the source code available on my website soon (and maybe a build for the a570 I own).

By the way, it really doesn't add much bloat - a few k at most.
A570, S100, Ixus 127
Author of ASSIST, STICK, WASP, ACID, SDMInst, LICKS, WICKS, MacBoot, UBDB, CFGEdit

*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: How useful would it be to add string capability to uBASIC?
« Reply #5 on: 26 / November / 2008, 04:49:40 »
just for fun

you know, that's the real important part :-)

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: How useful would it be to add string capability to uBASIC?
« Reply #6 on: 26 / November / 2008, 06:02:40 »
well, why not releasing it here? we can certainly add it to the trunk if the work is already done.
btw i was thinking about adding your "wheel/mode-override" mod to the trunk some time in the future, including support for more cameras. do you have a diff somewhere that is working with current trunk?

*

Offline zeno

  • *****
  • 891
Re: How useful would it be to add string capability to uBASIC?
« Reply #7 on: 26 / November / 2008, 07:29:47 »
well, why not releasing it here? we can certainly add it to the trunk if the work is already done.
btw i was thinking about adding your "wheel/mode-override" mod to the trunk some time in the future, including support for more cameras. do you have a diff somewhere that is working with current trunk?

I don't have a current diff - it's been some time since I produced builds. I got it working on just 3 cameras - a560, a570 and a720. I tried to find out what was needed on an Ixus70 (which has a slider not a wheel to switch between photo and movie) - it seems that the slider does not make the same sort of internal changes that the wheel does). I suspect the same is true for all Ixus models.
A570, S100, Ixus 127
Author of ASSIST, STICK, WASP, ACID, SDMInst, LICKS, WICKS, MacBoot, UBDB, CFGEdit


*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: How useful would it be to add string capability to uBASIC?
« Reply #8 on: 26 / November / 2008, 07:43:24 »
well yes, maybe we could add this to these three cameras via #defines and add it to the other cams later. the basic code will then be there i guess.

*

Offline zeno

  • *****
  • 891
Re: How useful would it be to add string capability to uBASIC?
« Reply #9 on: 27 / November / 2008, 11:42:52 »
I've put a stand-alone version of the string-enhanced Basic interpreter here uBASIC with Strings

Note that this is NOT the CHDK version - it's merely an ugrade to Adam Dunkel's original (so it requires line numbers and doesn't have the CHDK enhancements like do/while and select/case). However it does come with source code as well as an exe, so you can see what I did!
A570, S100, Ixus 127
Author of ASSIST, STICK, WASP, ACID, SDMInst, LICKS, WICKS, MacBoot, UBDB, CFGEdit

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal