|
Post by jeffbobb on Aug 7, 2021 10:21:28 GMT -5
OK, still on-the-fence re:Liberty BASIC.
Things I like: 1) Somewhat VBA-like. 2) Has subroutines & functions. 3) Documentation is quite thorough. 4) Fast & thoughtful responses from forum.
Stuff I'm concerned about: 1) There doesn't seem to be a way to search through the documentation. I think that would be helpful. 2) No variable declaration/no variable types. I've done a LOT of embedded programming in BADIC (PicBASIC Pro, Proton Basic, & MikroBASIC, and Basic Stamp), and a fair amount of programming in VBA (Excel). I can live without nibbles, but the idea of not having bit, byte, or word variable types is exceptionally foreign to me. Being able to manipulate the individual bits in a byte or a word is important to me. Can that functionality be achieved manually somehow, through a subroutine or function? I was thinking that it MIGHT be possible if the byte were converted somehow to a string, and then toggling the "bits", using the string functions. Maybe I'm over-thinking...
Maybe these are small issues, that I'll learn to live with, but right now they seem pretty big! I'm hoping to get the thoughts of others on these.
|
|
|
Post by Rod on Aug 7, 2021 10:59:40 GMT -5
Have no concerns, the bit byte thing is easy you can merge bits to bytes and so characters that are sent via serial. That’s all pretty basic byte manipulation that can be assisted by AND OR
You are missing out on a whole bunch of fun by holding back.
You will find that not having to bother “typing” hundreds of variables turns out to be a bonus.
|
|
|
Post by Rod on Aug 7, 2021 11:03:21 GMT -5
Why not post a bit byte manipulation you would like to make and see how our forum users would code it.
|
|
|
Post by Brandon Parker on Aug 7, 2021 16:24:55 GMT -5
You can do pretty much anything you would like to with Liberty BASIC!
For bit twiddling on positive integers ONLY (and Zero), just use "Or" for adding a bit and "And" for removing a bit at 2^bitNumber.
Print addByBit(0, 8)
Print removeByBit(7936, 8) End
Function addByBit(addByBit, bitNumber) If ((addByBit < 0) Or (bitNumber < 0)) Then Exit Function addByBit = (addByBit Or (2^bitNumber)) End Function
Function removeByBit(removeByBit, bitNumber) If ((removeByBit < 0) Or (bitNumber < 0)) Then Exit Function removeByBit = Max(0, removeByBit - (removeByBit And (2^bitNumber))) End Function
LB is not suited for all tasks, but since LB is a general-purpose language, your imagination is normally the limit for what you can do.
If you are interested in some longer version stuff where you can actually get a string representation of the bits just let me know. I have a few functions that you might be interested in.
{:0)
Brandon Parker
|
|