QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Zeppelin on September 10, 2018, 03:20:16 am

Title: Why can't you use C#/C++ commands in QB64
Post 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
Title: Re: Why can't you use C#/C++ commands in QB64
Post by: Fifi on September 10, 2018, 05:18:23 am
Because this would not be the BASIC language anymore. ;)
Title: Re: Why can't you use C#/C++ commands in QB64
Post by: Petr on September 10, 2018, 10:52:39 am
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.
Title: Re: Why can't you use C#/C++ commands in QB64
Post by: TerryRitchie on September 10, 2018, 11:27:17 am
Zeppelin, is that Brainf**k code in your tag line?
Title: Re: Why can't you use C#/C++ commands in QB64
Post by: FellippeHeitor on September 10, 2018, 11:39:22 am
Ha! It is. And I've just run it: https://copy.sh/brainfuck/
Title: Re: Why can't you use C#/C++ commands in QB64
Post by: bplus on September 10, 2018, 12:56:20 pm
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/
Quote
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 ;
Title: Re: Why can't you use C#/C++ commands in QB64
Post by: TerryRitchie on September 10, 2018, 12:57:41 pm
Ha! It is. And I've just run it: https://copy.sh/brainfuck/
LOL, cool.
Title: Re: Why can't you use C#/C++ commands in QB64
Post by: bplus on September 10, 2018, 01:02:12 pm
Are those Unicode characters and do I need a larger Type variable to contain the values?
Title: Re: Why can't you use C#/C++ commands in QB64
Post by: FellippeHeitor on September 10, 2018, 01:10:14 pm
The result is at the bottom: "My real name is Mark ;"
Title: Re: Why can't you use C#/C++ commands in QB64
Post by: bplus on September 10, 2018, 01:22:07 pm
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!
Title: Re: Why can't you use C#/C++ commands in QB64
Post by: Fifi on September 10, 2018, 04:15:35 pm
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
Title: Re: Why can't you use C#/C++ commands in QB64
Post by: RhoSigma on September 10, 2018, 06:28:35 pm
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.
Title: Re: Why can't you use C#/C++ commands in QB64
Post by: Omerta7486 on September 10, 2018, 11:47:23 pm
Quote from: TerryRitchie
Zeppelin, is that Brainf**k code in your tag line?

I noticed it, too! Lol.

Quote
"My real name is Mark ;"

Hey! Mine, too! B)

Quote from: Zeppelin
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:
Code: QB64: [Select]
  1.  
  2. _INC i,2
  3.  
  4. LOOP UNTIL i=10000

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:

Code: QB64: [Select]
  1. i=i+1

Quote from: Fifi
Because this would not be the BASIC language anymore. ;)

See above suggestion. Lol
Title: Re: Why can't you use C#/C++ commands in QB64
Post by: SMcNeill on September 11, 2018, 12:06:16 am
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.

Title: Re: Why can't you use C#/C++ commands in QB64
Post by: bplus on September 11, 2018, 12:28:40 am
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?
Title: Re: Why can't you use C#/C++ commands in QB64
Post by: FellippeHeitor on September 11, 2018, 12:42:34 am
What I'd love to see is...
Title: Re: Why can't you use C#/C++ commands in QB64
Post by: RhoSigma on September 11, 2018, 11:48:30 am
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