Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : mmb4l: BIN2STR is not declared ?!?
Author | Message | ||||
homa Guru Joined: 05/11/2021 Location: GermanyPosts: 351 |
@thwill Hi Tom, I tried mmb4l for the first time today. Thanks for that and the very good instructions on GitHub! With my program, which runs from PicoMite and uses the "bin2str$" command without any problems, I get the error message with mmb4l: BIN2STR is not declared Could this be the case? Best regards Matthias |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4039 |
Hi Matthias, Yes, it looks like it is missing, I'll try and fix that in the next couple of days. Did you build from source or use the pre-built binaries, if the latter then which platform. Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
homa Guru Joined: 05/11/2021 Location: GermanyPosts: 351 |
Hi Tom, I used the 'x86_64' prebuild. I once used LIST COMMANDS and LIST FUNCTIONS. The countercommand STR2BIN also seems to be missing... My intention was to continue work on my PicoMite program on my Linux laptop while on the road. I think the Linux version is otherwise very successful, especially with the edit/nano integration. Matthias |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4039 |
Thanks, I will see to the function too. If you're wondering why they are missing it is because MMB4L is a fork of the old MMBasic for DOS / Micromite code-base (where they are not present) rather than one of Peter's PicRoMite/CMM2/PicoMite code-bases. I started from the DOS version because it was smaller/simpler, with fewer of the micro-controller specific "horrors" and being largely the work of a single author (Geoff) more consistently formatted. I've been filling in the missing bits by appropriating Peter's work as required or writing new bits myself; MMB4L has its own OPTION framework, implementation of the function/sub/variable tables and a nascent attempt to bring more rigour to the error handling. Best wishes, Tom Edited 2024-01-31 01:45 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4039 |
Apologies, but due to various non-technical reasons, and also because I haven't built a public release since migrating to my new laptop this is going to take me a few days more. Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
homa Guru Joined: 05/11/2021 Location: GermanyPosts: 351 |
Good things take time! Don't stress yourself, Tom. I have continued programming on the PicoMite for the time being. I look forward to the Linux version when the time comes. Matthias |
||||
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1611 |
Can you achieve what you want with the BIN$() function? Bill Keep safe. Live long and prosper. |
||||
homa Guru Joined: 05/11/2021 Location: GermanyPosts: 351 |
No, that is not an option. > print bin$(64) 1000000 > print bin2str$(UINT8, 64) @ > |
||||
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1611 |
Sorry my mistake but if that is your only use for it then can you use CHR$()? > print chr$(64) @ > Bill Keep safe. Live long and prosper. |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2135 |
Just a guess, perhaps '64' is just a printable example and wants to store values up to 255 in strings. > s$ = bin2str$(UINT8, 64) : ? s$ @ > s$ = bin2str$(UINT8, 144) : ? s$ >if s$<>"" then ? "something is in s$" something is in s$ > ? str2bin(uint8,s$) 144 > Maybe Hex$(n%,2) can be pressed into service, though requires twice as many characters. Edit. Apologies, chr$() does store the values. To read them though use PEEK(BYTE addr%). > s$= chr$(155) > ? str2bin(uint8,s$) 155 > ? PEEK(VARADDR s$) 537061120 > ? PEEK(BYTE 537061120+1) 155 > s$= chr$(144) > ? PEEK(BYTE 537061120+1) 144 > > ? PEEK(BYTE PEEK(VARADDR s$)+1) 144 > Edited 2024-02-02 14:24 by phil99 |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3801 |
Or simply s$= chr$(155) ? asc(s$) If multiple chars in s$ use such as mid$ to get each out. peek is OK but not needed for this. John |
||||
homa Guru Joined: 05/11/2021 Location: GermanyPosts: 351 |
Unfortunately not an option either. Hi Phil, John and Bill. The two functions are available in WebMite, so far no problem, and Tom is kind enough to update them in the mm4l version. You are right with your suggestions when it comes to 8bit values (uint8) and these are converted as characters between string and value. I need to be able to store a uint32 as a string and vice versa. So you can combine multiple uin32 values as a string, or read from a string and then do BIT operations on that integer32 value. (And yes, I know, mmbasic only knows 64bit integers). And I could write a function that does this for me ... value1 + value2 * 256(=2^8) + value3 * 65536(=2^16) + value4 * 16777216(=2^24), back it is a bit more complicated, but that is what the two commands are for, right? Or are there alternative commands that I am not aware of? So I'll wait patiently :-) Matthias Edited 2024-02-02 22:06 by homa |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2135 |
Not simpler but a bit faster:- value1 + (value2<<8) + (value3<<16) + (value4<<24) Or:- addr% = PEEK(VARADDR var) PEEK(WORD addr% + offset) 'WORD will return the word (32-bits) located at 'addr% Edited 2024-02-02 22:32 by phil99 |
||||
homa Guru Joined: 05/11/2021 Location: GermanyPosts: 351 |
I see you are also familiar with bit trickery ... |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3801 |
Perhaps a bit more info about your data & ways of using / wanting to use it... You mention value1 + value2 * 256 etc, so do you have the data as 8-bit values and want to convert to 32-bit and then string or what? Also, is time critical? The more it is the uglier the code may be! John |
||||
Print this page |