Author Topic: Why can't you use C#/C++ commands in QB64  (Read 7907 times)

0 Members and 1 Guest are viewing this topic.

Offline Zeppelin

  • Newbie
  • Posts: 43
    • View Profile
    • Zeppelin Games ItchIo
Why can't you use C#/C++ commands in QB64
« 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
+[--->++<]>+.+++[->++++<]>.[--->+<]>+.-[---->+<]>++.+[->+++<]>+.+++++++++++.----------.[--->+<]>----.+[---->+<]>+++.---[->++++<]>.------------.+.++++++++++.+[---->+<]>+++.+[->+++<]>++.[--->+<]>+.[->+++<]>+.++++++++++.+.>++++++++++.

Offline Fifi

  • Forum Regular
  • Posts: 181
    • View Profile
    • My small QB64 contribution
Re: Why can't you use C#/C++ commands in QB64
« Reply #1 on: September 10, 2018, 05:18:23 am »
Because this would not be the BASIC language anymore. ;)
It's better to look like an idiot for a short time while asking something obvious to an expert than pretending to be smart all your life. (C) Me.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Why can't you use C#/C++ commands in QB64
« Reply #2 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.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Why can't you use C#/C++ commands in QB64
« Reply #3 on: September 10, 2018, 11:27:17 am »
Zeppelin, is that Brainf**k code in your tag line?
In order to understand recursion, one must first understand recursion.

FellippeHeitor

  • Guest
Re: Why can't you use C#/C++ commands in QB64
« Reply #4 on: September 10, 2018, 11:39:22 am »
Ha! It is. And I've just run it: https://copy.sh/brainfuck/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Why can't you use C#/C++ commands in QB64
« Reply #5 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.

  [ You are not allowed to view this attachment ]  


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 ;
« Last Edit: September 10, 2018, 01:07:13 pm by bplus »

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Why can't you use C#/C++ commands in QB64
« Reply #6 on: September 10, 2018, 12:57:41 pm »
In order to understand recursion, one must first understand recursion.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Why can't you use C#/C++ commands in QB64
« Reply #7 on: September 10, 2018, 01:02:12 pm »
Are those Unicode characters and do I need a larger Type variable to contain the values?

FellippeHeitor

  • Guest
Re: Why can't you use C#/C++ commands in QB64
« Reply #8 on: September 10, 2018, 01:10:14 pm »
The result is at the bottom: "My real name is Mark ;"

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Why can't you use C#/C++ commands in QB64
« Reply #9 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!
« Last Edit: September 10, 2018, 01:33:11 pm by bplus »

Offline Fifi

  • Forum Regular
  • Posts: 181
    • View Profile
    • My small QB64 contribution
Re: Why can't you use C#/C++ commands in QB64
« Reply #10 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
It's better to look like an idiot for a short time while asking something obvious to an expert than pretending to be smart all your life. (C) Me.

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: Why can't you use C#/C++ commands in QB64
« Reply #11 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.
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline Omerta7486

  • Newbie
  • Posts: 33
  • √𝜋²
    • View Profile
Re: Why can't you use C#/C++ commands in QB64
« Reply #12 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
The knowledge that's seeking the favor of another means the murder of self.

Latest version of my game, here  Omertris: Invasion

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Why can't you use C#/C++ commands in QB64
« Reply #13 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.

https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Why can't you use C#/C++ commands in QB64
« Reply #14 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?