Author Topic: What is the point of DRAW "x" and PLAY "x" ?  (Read 5534 times)

0 Members and 1 Guest are viewing this topic.

Offline zigzag

  • Newbie
  • Posts: 5
    • View Profile
What is the point of DRAW "x" and PLAY "x" ?
« on: June 18, 2018, 10:33:40 am »
Both QBasic, and QB64, accept any string with the DRAW or PLAY command. So, what is the point of:

Code: QB64: [Select]
  1. DRAW "x"+VARPTR$(A$)

when one can just use

Code: QB64: [Select]
  1. DRAW A$

that is much clearer?

FellippeHeitor

  • Guest
Re: What is the point of DRAW "x" and PLAY "x" ?
« Reply #1 on: June 18, 2018, 10:55:52 am »
Retrocompatibility with GWBASIC.

Offline zigzag

  • Newbie
  • Posts: 5
    • View Profile
Re: What is the point of DRAW "x" and PLAY "x" ?
« Reply #2 on: June 18, 2018, 11:35:37 am »
Gwbasic, too, allowed the simpler syntax. And the use of x was different,  since it was followed by the variable's name

FellippeHeitor

  • Guest
Re: What is the point of DRAW "x" and PLAY "x" ?
« Reply #3 on: June 18, 2018, 11:47:08 am »
I don't know then.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: What is the point of DRAW "x" and PLAY "x" ?
« Reply #4 on: June 18, 2018, 11:53:36 am »
Hi zigzag, welcome to forum!

Now you got me curious: http://qb64.org/wiki/VARPTR$ ' <<< the $ is not picked up in link sorry...

"X" + VARPTR$(value) can draw another substring.

Here is sample from Wiki:
Code: QB64: [Select]
  1.  
  2. WIND$ = "r10 d7 l10 u7 br20"   'create draw string to be read by function
  3. ROW$ = "x"+VARPTR$(WIND$)+"x"+VARPTR$(WIND$)+"x"+VARPTR$(WIND$)+" x"+VARPTR$(WIND$)+"bl80 bd11"
  4. LINE (100, 50)-(200, 160), , B
  5. DRAW "bm 115,52"
  6. FOR I = 1 TO 10
  7.     DRAW "x" + VARPTR$(ROW$)
  8.  

It looks to be a way to repeat drawing.
« Last Edit: June 18, 2018, 12:04:41 pm by bplus »

FellippeHeitor

  • Guest
Re: What is the point of DRAW "x" and PLAY "x" ?
« Reply #5 on: June 18, 2018, 12:02:37 pm »
Truth is I always used STR$() for numeric variables and the variable itself for strings, even back in QBasic days. VARPTR has always been a mystery to me.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: What is the point of DRAW "x" and PLAY "x" ?
« Reply #6 on: June 18, 2018, 12:10:42 pm »
Yep! This does same:
Code: QB64: [Select]
  1. WIND$ = "r10 d7 l10 u7 br20" 'create draw string to be read by function
  2. ROW$ = WIND$ + WIND$ + WIND$ + WIND$ + "bl80 bd11"
  3. LINE (100, 50)-(200, 160), , B
  4. DRAW "bm 115,52"
  5. FOR I = 1 TO 10
  6.     DRAW ROW$
  7.  
Thus,
Draw "X" + varptr$(var) 
is waste of time, don't use it. ;D

Ha! neither use screen 2! come join the brave new world with _NewImage
« Last Edit: June 18, 2018, 12:13:02 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: What is the point of DRAW "x" and PLAY "x" ?
« Reply #7 on: June 18, 2018, 12:19:06 pm »
But then again wiki has another example:

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: What is the point of DRAW "x" and PLAY "x" ?
« Reply #8 on: June 18, 2018, 12:23:06 pm »
But then again, that sample doesn't even work without throwing an error!

So it looks like you have to be careful moving with negative values.
« Last Edit: June 18, 2018, 12:25:24 pm by bplus »

Offline zigzag

  • Newbie
  • Posts: 5
    • View Profile
Re: What is the point of DRAW "x" and PLAY "x" ?
« Reply #9 on: June 18, 2018, 03:09:09 pm »
Interesting. I see no one knows what was the purpose of the x command. Unfortunately, QBASIC guide is not clear, and many people believed it was necessary to use that weird syntax. But actually, on older versions of Microsoft Basic, there is a clue: on MSX Basic (that is pretty similar to GWBasic), the x command was supposed to be used like:

Quote
DRAW "xa$;"

https://www.msx.org/wiki/DRAW

It made no sense at all neither in GWBasic, nor in QBASIC... but after more than 30 years it's still here, because too many people don't know there is no need for it

FellippeHeitor

  • Guest
Re: What is the point of DRAW "x" and PLAY "x" ?
« Reply #10 on: June 18, 2018, 04:50:10 pm »
So at some point BASIC did allow a variable name to be embedded inside a string, so it does make sense that VARPTR would have to be used later, when doing the same was no longer allowed, so that you could still point to an existing variable (though, even back then, it would still probably have been easier to just concatenate the strings, but who knows?).

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: What is the point of DRAW "x" and PLAY "x" ?
« Reply #11 on: June 18, 2018, 05:55:05 pm »
So zigzag,

Are you presently engaged in any projects using Draw string$. I ask because I have a version in JB I've been meaning to translate to QB64. Last I looked, it had some interesting features like 3 digit RGB for 1000 colors, a Repeat function so you don't have to say string$ + string$ +... 10 times just R10String$, circle and circle fill, box and box fill that could do boxes at angles and a built in variable you could reset and increment. Everything letter and then digits, syntaxically, I think even decimals worked.

Offline zigzag

  • Newbie
  • Posts: 5
    • View Profile
Re: What is the point of DRAW "x" and PLAY "x" ?
« Reply #12 on: June 18, 2018, 06:01:41 pm »
Currently, no, I have a project that might involve PLAY, instead. Can I see that version of Draw you are talking about?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile