Adding optional function parameters to uBasic - General Discussion and Assistance - CHDK Forum  

Adding optional function parameters to uBasic

  • 2 Replies
  • 2573 Views
*

Offline lapser

  • *****
  • 1093
Adding optional function parameters to uBasic
« on: 04 / December / 2012, 20:16:30 »
Advertisements
I was able to add an optional "range" parameter to:

get_histo_range(from,to[,range])

It works great in Lua, but I'm not sure how to implement it for uBasic. Here's the relevant section of ubasic.c
Code: (C) [Select]
case TOKENIZER_GET_HISTO_RANGE:
    accept(TOKENIZER_GET_HISTO_RANGE);
    int from = expr();
    int to = expr();
    //int scale = expr(); //is optional possible??
    r = (unsigned short)shot_histogram_get_range(from, to, 100);//returns -1 for error
    break;
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline reyalp

  • ******
  • 14079
Re: Adding optional function parameters to uBasic
« Reply #1 on: 04 / December / 2012, 20:28:30 »
Print takes a variable number of arguments, so you might want to look at that. Your code can be simpler since you only need 2 or 3 arguments.
Don't forget what the H stands for.

*

Offline lapser

  • *****
  • 1093
Re: Adding optional function parameters to uBasic
« Reply #2 on: 04 / December / 2012, 22:24:48 »
Print takes a variable number of arguments, so you might want to look at that. Your code can be simpler since you only need 2 or 3 arguments.
Good idea. I'll take a look.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

 

Related Topics