![]() |
Forum Index : Microcontroller and PC projects : MMbasic 5.3 Requests.
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3282 |
More interesting suggestions... GUI TIMEBOX and GUI DATEBOX These are good but what I would like to do is extend the NUMBERBOX or TEXTBOX so that there is some sort of callback mechanism which would allow a user written subroutine to edit/control each keystroke as they are entered. Then you could create your own TIMEBOX and DATEBOX as well as a GPSBOX (enter GPS coordinates) or whatever. It might not be feasible to implement such a thing and in that case I will fall back to just GUI TIMEBOX and GUI DATEBOX. TIMER Command & Function enhancement The best way to do this is to store the current TIMER value and test if it has incremented beyond some value (ie, never reset it). Because the TIMER value will never overflow or roll over it is simple to implement. For example: DIM T2 AS INTEGER
... T2 = TIMER + 300 ... ' wait for 300mS DO WHILE TIMER < T2 : LOOP On another subject, the last three months have been pretty full on for me with overseas travel and overseas visitors but that has just about come to an end so you should now find me more responsive (for the next few months at least). Geoff Geoff Graham - http://geoffg.net |
||||
MicroBlocks![]() Guru ![]() Joined: 12/05/2012 Location: ThailandPosts: 2209 |
Maybe a alternative to the timebox/datebox a GUI MASKBOX could be considered. You would then define a MASK to allow a controlled entry. Each character in the mask would then allow a certain range of characters to be entered. Y for year, M for month, D for day, H for hour, m for Minute, S for second X for capital/upper case letters, x for lower case letter, # for a number and more... The 'editor' would then only allow characters at the current position that is defined in the mask, and skips over any character that is not a defined mask character. Like -,.:/? A time 'GUI BOX' would then be [code] HH:mm:SS [/code] A date 'GUI BOX' [code] YYYY-MM-DD [/code] Combined [code] YYYY-MM-DD HH:mm:ss [/code] A numeric value could be [code] xxxx.xx [/code] A name value [code] Xxxxxxxxxxxxxxxxxxxx [/code] etc.. The final check would need to be done in code to see if the values are in the intended range, but at least the right characters are entered which makes that task a lot easier. Microblocks. Build with logic. |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3282 |
Excellent idea... and simple to implement ![]() Geoff Graham - http://geoffg.net |
||||
redrok![]() Senior Member ![]() Joined: 15/09/2014 Location: United StatesPosts: 209 |
Hi Geoffg; I wonder if a variation of the VAL() function can be done. VAL( string$ ) Returns the numerical value of the ‘string$’. If 'string$' is an invalid number the function will return zero. This function will recognise the &H prefix for a hexadecimal number, &O for octal and &B for binary. What I would like is to evaluate the string to a number but include math functions. Something like this: PRINT VAL("12.34 + 56.78") 69.12 or PRINT VAL("12.34 / 56.78") 0.21733 Maybe the function needs a new name like: VAL#("") VALMATH("") EVAL("") Something like that. I have seen this done on some of the tiny basics. This is very useful. I have written routines for this in GWBasic but would really like it within the function itself. It occurs to me that the evaluation of the string math is already done in your math routines. If so the full power of the math library could be used. Including the use of variables names. I assume the evaluation would use "infix" notation. However, "Postfix" notation would be a real bonus to me. I will post my version of a Postfix routine in uMITE 5.2 shortly. This was needed because the INPUT command and INPUT$ function suspend interrupts so I did it with the INKEY$ function which doesn't suspend interrupts. Thanks for your consideration. redrok |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3282 |
Thanks Duane, that has been suggested before and is on my todo list to be looked at. I'm not sure how easy it will be to implement but it certainly does look simple as you pointed out. Geoff Geoff Graham - http://geoffg.net |
||||
MicroBlocks![]() Guru ![]() Joined: 12/05/2012 Location: ThailandPosts: 2209 |
Javascript has an EVAL() which can run code. This might be simpler as all the existing parts can be reused. It is the same as when a user enters some code on the command prompt level. It is run immediately. The string parameter from the EVAL function could use the same. Little code sequences could then be run, which might be useful as they can be manipulated in runtime. Microblocks. Build with logic. |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3282 |
I have just experimented with adding the EVAL() function and it works a treat. You will see it in the next version. This is its entry in the manual: Even better, it only used 120 bytes ![]() Geoff Geoff Graham - http://geoffg.net |
||||
MicroBlocks![]() Guru ![]() Joined: 12/05/2012 Location: ThailandPosts: 2209 |
In C there is a way of using evaluations as part of an expression. like: [code] int A = 1 int B = 0 B = (A == 1) ? 1 : 2; [/code] In Basic that would translate to [code] IF A = 1 then B = 1 else B = 2 [/code] Would that be possible to add to MMBasic. The C form will probably not work as it will break basic syntax but an alternative way might work. [code] B = (A = 1) THEN 1 ELSE 2 [/code] The THEN and ELSE will probably have to be replaced by some keyword or character that does not conflict with the parsing. I am not sure which ones are available or if the keywords THEN and ELSE can be reused in this context (Expressions). This would add another powerful layer of flexibility to MMBasic and therefore also to EVAL(). Microblocks. Build with logic. |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1128 |
In (some) BASICs, expressions have a value of 0 or 1 if they are false or true. For example, "PRINT 1=2" gives 0, "PRINT 1<2" gives 1. Does MMBASIC behave this way? In which case, your example code would be [code] B = 2 - A = 1 [/code] Looks nasty but works nicely. Visit Vegipete's *Mite Library for cool programs. |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
OK, MMBasic additions I'd like to see. These are more generic than some of the exotic stuff already mentioned: from years of VB I really miss these: EXIT SELECT : abort a CASE statement early LTRIM$/RTRIM$ : strip white space from the start/end of a string e.g A$=LTRIM$(A$) MID$ as a statement, e.g. MID$(a$,2,4)="FRED" and some more complex: SPLIT(<string>,<delimeter>) : split a string into array elements e.g. A$()=SPLIT(B$,":") JOIN$(<array>,<delimeter>) : join elements of an array into a string e.g. A$=JOIN$(B$(),":") my 2p h |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
oops... forgot these two UBOUND(<array>) : return the number of the top element in an array mega important if I get SPLIT ;o) e.g. DIM A(10): PRINT UBOUND(a) would give 10 LBOUND(<array>): return the lower bound of an array - this is essentially the OPTION BASE argument. can arguably be done with CONST OB=0: OPTION BASE OB h |
||||
kiiid Guru ![]() Joined: 11/05/2013 Location: United KingdomPosts: 671 |
How is EVAL acting in an imperative statement? For example EVAL("PRINT "HELLO"") or even the more curious one EVAL("RUN") http://rittle.org -------------- |
||||
TinkersALot Regular Member ![]() Joined: 20/11/2012 Location: United StatesPosts: 72 |
"marquis text" control -- a timer driven auto-scroll text area that works with a fixed array of strings and allowing the ability to set a string at a specific index in the array (the size of array declared at control creation) -- if horizontal orientation will scroll text as configured; either left to right; or right to left; -- if vertical orientation will scroll as configured; either top to bottom; or bottom to top; |
||||
TinkersALot Regular Member ![]() Joined: 20/11/2012 Location: United StatesPosts: 72 |
image scroll list This control would contain a list of images (an array of files?) that someone could 'scroll over' with swipes. They could 'click/select' one of the images and the index of the 'clicked' control would be returned from that action. ...too much??? thanks for considering this however. |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3282 |
That will cause an error. The function can only process an expression, not a statement. @TinkersAlot "marquis text" control and image scroll list are a bit too specialised and complex. Geoff Geoff Graham - http://geoffg.net |
||||
TinkersALot Regular Member ![]() Joined: 20/11/2012 Location: United StatesPosts: 72 |
No worries, Geoffg. Thanks for considering my questions. |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
ability to execute RUN from within a program... nice easy (=lazy) restart of a prog. cheers h |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3282 |
You can GOTO to the start of the program or use CPU RESTART along with OPTION AUTORUN. Geoff Geoff Graham - http://geoffg.net |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
Thanks Geoff. The latter is interesting (go to bed - it is late there ![]() |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
Minor Editor enhancement. The internal editor; I use it a bit, but mostly to experiment with minor changes like adjusting variables, or temporarily adding a print line to report on something like the timer. Usually I'm viewing the code in MMedit or Notepad++ & know exactly where I need to go. Could the search function be enhanced so it could go directly to a line number? Just now I wanted to look as my temp sensor response times, searched "Readtemp" & got to the function on the 8th occurance. If I could have used a search string like [203] it would have taken me right to the correct line. Cheers Phil. |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |