PRINT the " symbol in QBasic

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

flytape8490

Thread Starter
Joined
Oct 7, 2003
Messages
703
I'm making a graphics demo in QBasic, and I'm having some troubles making it display some text I want.
So, I want to display this
The "place-read" mode has been turned on.
To do this, one would assume just do this.
Code:
PRINT "The "place-read" mode has been turned on."
But that doesn't work, because then QB assumes that place-read is a arithmatic string 'cuz the "s surrounding it make it a variable/command string. So, how do I display "s without ostracising what they surround from normal text?


... and yes, I am proud that I only know QB and HTML scripting. I don't mind being oldschool.
 
Joined
Jul 29, 2004
Messages
6,650
Just try this :
Code:
[SIZE=3][B]
LET Q$ = CHR$(34)
LET T$ = "The " + Q$ + "place-read" + Q$ + " mode has been turned on."
PRINT T$[/B][/SIZE]
34 is the decimal value of the ASCII code of "
 

IMM

Joined
Feb 1, 2002
Messages
3,257
Alternate way (if you aren't doing it too often)

PRINT "The ";CHR$(34);"place-read";CHR$(34);"mode has been turned on."
 
Joined
Sep 26, 2005
Messages
12
Your original problem was caused by the qbasic interpreter assuming that the second " (the one at the beginning of 'place-read') signified the end of the string. In newer languages there's an escape character, usually \, that makes it ignore the following character, but in basic you have to call the ascii character instead of entering it directly.

BTW, qBASIC was my first language -- I started learning it when I was 12, and it hooked me on programming. That language first pulled me in, and I still enjoy it - although I can't say I use it for anything productive now.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top