QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: Zeppelin on September 10, 2018, 03:20:16 am
-
Hey,
Why in QB64 if you want to add to a variable you have to type:
var=var+1
Why is it that we can't use shortcuts like:
var++
Or
var+=1
I've tried creating a function that does something like this, but you still have to set the function (var=func(var)).
Thanks,
Zeppelin
-
Because this would not be the BASIC language anymore. ;)
-
You can using all c++ statements in H file, which is then declared in BAS file as external library. But this :-D as write Fifi, really it is difference between BASIC and C syntax.
-
Zeppelin, is that Brainf**k code in your tag line?
-
Ha! It is. And I've just run it: https://copy.sh/brainfuck/
-
So Fellippe, could you translate it to a message?
I tried for some time this morning but don't recognize the giant numbers both plus and minus.
[ This attachment cannot be displayed inline in 'Print Page' view ]
append: https://copy.sh/brainfuck/
About
A Brainfuck editor & optimizing interpreter, written in JavaScript. The code is converted to JavaScript code and then run in a web worker, which speeds up execution at lot (try this for example).
Have fun! :-)
You can add special chars to the input field:
Decimal: \65 (same as "A")
Hexadecimal: \x7E (same as "~")
Control characters: \r \n \t
For any kind of feedback, toss me a mail to
--[----->+<]>---.++++++++++++.+.+++++++++.+[-->+<]>+++.++[-->+++<]>.++++++++++++.+.+++++++++.-[-->+++++<]>++.[--->++<]>-.-----------.
Links:
Wikipedia on Brainfuck
The Brainfuck archive
Brainfuck snippets
Text generator
BF code compressor
Options
Cell size (Bits): 8 16 32
Dynamic (infinite) Memory:
Memory size:
30000
Memory overflow behaviour:
undefined (fast) wrap abort
End of input: no change char:
\n
Dump Memory at char:
#
Count instructions
1.
++[---------->+<]>.-[++++>---<]>.-[---->+<]>++.---[----->++<]>.-------------.----.+++++++++++.[++>---<]>--.+[----->+<]>+.-------------.++++++++++++.--------.--[--->+<]>-.-[--->++<]>-.++++++++++.+[---->+<]>+++.++++++[->++<]>+.-[------>+<]>-.--[--->+<]>---.-------.-[++>---<]>+.--[->++<]>-.+[--->++<]>+
Finished in 16 ms.
My real name is Mark ;
-
Ha! It is. And I've just run it: https://copy.sh/brainfuck/
LOL, cool.
-
Are those Unicode characters and do I need a larger Type variable to contain the values?
-
The result is at the bottom: "My real name is Mark ;"
-
The result is at the bottom: "My real name is Mark ;"
Yes, got that and it even applies to me also. :)
But these are not ASCII numbers being used. So I am guessing Unicode that I just learned is two chars wide which explains why some values are neg. That, and now that I see it translated I know it was not a secret code, so Unicode is my guess.
Append Aha!
-
Hi Petr,
You can using all c++ statements in H file, which is then declared in BAS file as external library. But this :-D as write Fifi, really it is difference between BASIC and C syntax.
That's just a question I've asked several times without any answer:
"where may I found a very short sample code that declare the basic stdio.h library in order to use the printf() function?"
This would really help me to understand how C libraries work with QB64 but, sorry, I need a tiny sample code.
T.I.A.
Fifi
-
It's right here Fifi,
https://www.qb64.org/forum/index.php?topic=418.msg3195#msg3195
but just the same day you've posted that you messed up your new linux installation. Now finally, I guess your system is running again, but you forgot about our discussion. Finally now also my standard libs work with 64 bit builds of QB64.
-
Zeppelin, is that Brainf**k code in your tag line?
I noticed it, too! Lol.
"My real name is Mark ;"
Hey! Mine, too! B)
Why in QB64 if you want to add to a variable you have to type:
var=var+1
Why is it that we can't use shortcuts like:
var++
Or
var+=1
I've asked myself the same thing on multiple occasions. At least, why there aren't increment/decrement functions, like :
_INC var, +step and _DEC var, -step
Or, better yet: _INC var, (+/-)step
Example:
I've seen all of those in one form or another in most BASIC syntaxes, and I find it sadly missing from this one. Oh, well. It's not hard to type:
Because this would not be the BASIC language anymore. ;)
See above suggestion. Lol
-
I = I + 2 is a total of 5 letters typing (not counting spaces, which will auto format themselves).
_INC I, 2 is 7 letters typing...
I don't see any improvement here. In many cases it's not saving any typing. It's not as BASIC to read/understand. Even in cases with long variable names, it saves very little time/work (just copy/paste the variable name to the other side of the equal sign if needed).
What I'd love to see is an ANY type for SUBS/FUNCTIONS, then you could do this easily yourself:
INC I, 2
SUB INC (var AS ANY, amount)
var = var + amount
END SUB
With var defined AS ANY, it'll pass values back regardless to what data type you send to it, allowing for easy creation of such routines for those who want them.
-
I = I + 2 is a total of 5 letters typing (not counting spaces, which will auto format themselves).
_INC I, 2 is 7 letters typing...
I don't see any improvement here. In many cases it's not saving any typing. It's not as BASIC to read/understand. Even in cases with long variable names, it saves very little time/work (just copy/paste the variable name to the other side of the equal sign if needed).
What I'd love to see is an ANY type for SUBS/FUNCTIONS, then you could do this easily yourself:
INC I, 2
SUB INC (var AS ANY, amount)
var = var + amount
END SUB
With var defined AS ANY, it'll pass values back regardless to what data type you send to it, allowing for easy creation of such routines for those who want them.
Nice! Is it possible?
-
What I'd love to see is...
-
I = I + 2 is a total of 5 letters typing (not counting spaces, which will auto format themselves).
_INC I, 2 is 7 letters typing...
I don't see any improvement here. In many cases it's not saving any typing. It's not as BASIC to read/understand. Even in cases with long variable names, it saves very little time/work (just copy/paste the variable name to the other side of the equal sign if needed).
What I'd love to see is an ANY type for SUBS/FUNCTIONS, then you could do this easily yourself:
INC I, 2
SUB INC (var AS ANY, amount)
var = var + amount
END SUB
With var defined AS ANY, it'll pass values back regardless to what data type you send to it, allowing for easy creation of such routines for those who want them.
I've proposed something similar a while back in the development section on [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there], which is gone now. The improvement comes when your variable is not just one letter but a longer name or even a user type variable:
eg: cnt% = cnt% + 1 or MyType.counter = MyType.counter + 1