![]() |
Forum Index : Microcontroller and PC projects : MMBasic for Windows - alphas
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4251 |
I write self-modifying people just to upset code. Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10066 |
Exactly that. If you put it in MMB4L as well and drop the abuse of the CSUB then we have a standard |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10066 |
MMBasic.zip Implemented dim a(20) data 0,1,2,3,4,5,6,7,8,9 data 10,11,12,13,14,15,16,17,18,19 for i=0 to 13 read a(i) next i readmydata for i=14 to 19 read a(i) next i for i = 0 to 19 if a(i)<>i then print i,"WTF",a(i) next i end sub readmydata local s$(7) local i read save restore testlabel for i=0 to 6 read s$(i) next i read restore for i = 0 to 6 print s$(i); next i print "" end sub testlabel: data b,c,d,e,f,g,h C code is trivial in the extreme void cmd_read(void) { int i, j, k, len, card; unsigned char *p, datatoken, *lineptr = NULL, *ptr; int vcnt, vidx, num_to_read = 0; static unsigned char* SaveNextDataLine = ProgMemory; static int SaveNextData = 0; if (checkstring(cmdline, (unsigned char*)"SAVE")) { SaveNextDataLine = NextDataLine; SaveNextData = NextData; return; } if (checkstring(cmdline, (unsigned char*)"RESTORE")) { NextDataLine = SaveNextDataLine; NextData = SaveNextData; return; } |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4251 |
LOL, thanks for doing this Peter. Will incorporate in the next alpha for MMB4L, though that is some time away. Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10066 |
You may need to tweak signed/unsigned and the static initialisation depending on whether ProgMemory is a constant or a variable. For the CMM2 it is: static char* SaveNextDataLine = NULL; static int SaveNextData = 0; if (checkstring(cmdline, (char*)"SAVE")) { SaveNextDataLine = NextDataLine; SaveNextData = NextData; return; } if (checkstring(cmdline, (char*)"RESTORE")) { NextDataLine = SaveNextDataLine; NextData = SaveNextData; return; } getargs(&cmdline, (MAX_ARG_COUNT * 2) - 1, ","); // getargs macro must be the first executable stmt in a block if(SaveNextDataLine == NULL)SaveNextDataLine = ProgMemory; |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4251 |
Thanks Peter, I'm sure I will figure it out. I've noticed that in general you've been having fun and games with char signedness. With GCC you can tell the compiler whether unqualified chars should be treated as unsigned or signed, I've done the former in MMB4L and been removing qualifiers where I encounter then, seems to be working for me. YMMV but I'm not sure about using static function variables for this piece of state, it makes it difficult to "zero" out between RUNs. Best wishes, Tom Edited 2022-02-23 03:59 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10066 |
It has been a complete nightmare under C++ on VS2022 With your default every strlen, strcpy etc. would give a hard error because they only accept (char*) |
||||
Plasmamac![]() Guru ![]() Joined: 31/01/2019 Location: GermanyPosts: 572 |
hi matherp, can we have a mask color for the blit command? such like : option mask color = &hxyz can we have &B101 for the blit command which will not copy the mask color . gtx Plasma |
||||
MauroXavier Guru ![]() Joined: 06/03/2016 Location: BrazilPosts: 303 |
matherp, could you implement the OPTION DEGREE? This will help me a lot to keep the same source for the Into the Darkness to the MMBasic for Windows and CMM2 simultaneously. |
||||
Pluto Guru ![]() Joined: 09/06/2017 Location: FinlandPosts: 374 |
Tested a7 for MM.INFO. -MM.INFO(FILESIZE) gives syntax error -MM.INFO(WRITEPAGE) gives syntax error -MM.INFO(ERRMSG) crashes the program. Initially it was Ok, but now several restarts and crashes. In fact crashes every time now. Simple testprogram. I had to comment out the lines that gave errors in order to complete the tests. ?"SOUND: "; ?MM.INFO(SOUND) ?"MAX PAGES: "; ?MM.INFO(MAX PAGES) ?"PAGE ADDRESS: "; '?MM.INFO(PAGE ADDRESS) ?"FRAMEBUFFER: "; ?MM.INFO(FRAMEBUFFER) ?"DIRECTORY: "; ?MM.INFO(DIRECTORY) ?"EXISTS FILE: "; '?MM.INFO(EXISTS FILE) ?"EXISTS DIR: "; '?MM.INFO(EXISTS DIR) ?"OPTION AUTORUN: "; ?MM.INFO(OPTION AUTORUN) ?"OPTION EXPLICIT: "; ?MM.INFO(OPTION EXPLICIT) ?"OPTION BASE: "; ?MM.INFO(OPTION BASE) ?"PROGRAM: "; ?MM.INFO(PROGRAM) ?"AUTORUN: "; ?MM.INFO(AUTORUN) ?"DEVICE): "; ?MM.INFO(DEVICE) ' (same as MM.DEVICE$) ?"DEFAULT PATH: "; ?MM.INFO(DEFAULT PATH) ?"VERSION: "; ?MM.INFO(VERSION) ' (same as MM.VER) ?"VARCNT: "; ?MM.INFO(VARCNT) ?"CURRENT: "; ?MM.INFO(CURRENT) ?"FONTWIDTH: "; ?MM.INFO(FONTWIDTH) ?"FONTHEIGHT: "; ?MM.INFO(FONTHEIGHT) ?"FILESIZE: "; '?MM.INFO(FILESIZE) ?"SYNTAX ERROR" ?"FONTCOUNT: "; ?MM.INFO(FONTCOUNT) ' (how many chars are available in current font) ?"WIDTH: "; ?MM.INFO(WIDTH) ?"HEIGHT: "; ?MM.INFO(HEIGHT) ?"HPOS: "; ?MM.INFO(HPOS) ?"VPOS: "; ?MM.INFO(VPOS) ?"FCOLOUR: "; ?MM.INFO(FCOLOUR) ?"BCLOUR: "; ?MM.INFO(BCOLOUR) ?"FRAMEH: "; ?MM.INFO(FRAMEH) ?"FRAMEV: "; ?MM.INFO(FRAMEV) ?"WRITEPAGE: "; '?MM.INFO(WRITEPAGE) ?"syntax error" ?"FONT: "; ?MM.INFO(FONT) ?"ERRNO: "; ?MM.INFO(ERRNO) ?"ERRMSG: "; '?MM.INFO(ERRMSG) ?"CRASHES THE PROGRAM" ?"OPTION BREAK: "; ?MM.INFO(OPTION BREAK) end Regards Fred |
||||
Pluto Guru ![]() Joined: 09/06/2017 Location: FinlandPosts: 374 |
Sorry forgot the outputs: ![]() |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 3998 |
I use typedef to get uchar (an unsigned char) - usually just an 8-bit item, often not a character schar (a signed char) - hardly ever used char (don't care) - commonly actually is a character Seems to survive porting well. OTOH I don't tend to be porting existing code written by someone else. I wonder if you could use C++ overloading to make strlen(unsigned char *) the same as strlen(char *). John |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10066 |
MM.INFO(FILESIZE) gives syntax error -MM.INFO(WRITEPAGE) gives syntax error Perhaps try specifying a filename or directory name in the function? Shouldn't crash of course but calling it before there is an error makes no sense There is one - BLACK ![]() Edited 2022-02-23 08:36 by matherp |
||||
Plasmamac![]() Guru ![]() Joined: 31/01/2019 Location: GermanyPosts: 572 |
Ah , whats will do the trick , need only a bit precalculation. The for the hint ![]() Plasma |
||||
hitsware2![]() Guru ![]() Joined: 03/08/2019 Location: United StatesPosts: 715 |
![]() ![]() Box86 / Wine ( FOR without NEXT problem though ) ![]() my site |
||||
lizby Guru ![]() Joined: 17/05/2016 Location: United StatesPosts: 3309 |
for x = 1 to 3: ?x: next PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
hitsware2![]() Guru ![]() Joined: 03/08/2019 Location: United StatesPosts: 715 |
for x = 1 to 3: ?x: next A new paradigm ? my site |
||||
lizby Guru ![]() Joined: 17/05/2016 Location: United StatesPosts: 3309 |
Not sure what you're saying. The error you get with FOR on the command line and no NEXT is the same for MMBasic on any device. PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
hitsware2![]() Guru ![]() Joined: 03/08/2019 Location: United StatesPosts: 715 |
Duh ..... How do I get to the editor ? ![]() my site |
||||
KD5ZXG Regular Member ![]() Joined: 21/01/2022 Location: United StatesPosts: 53 |
Edit now requires a file name. Because numbered and un-numbered lines are both allowed, reliably positioning any new line requires either the editor or perfectly sequential entry of the whole shebang while some option to autosave is turned on, I forget exactly how. Your line 10 was immediately executed and not saved. Which is why you never got the chance to follow up with a line 20 and maybe NEXT x. Edited 2022-02-23 13:29 by KD5ZXG |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |