Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Outputting strings containing " marks to a file

Author
Message
Sock of Eternity
18
Years of Service
User Offline
Joined: 5th Jun 2006
Location:
Posted: 5th Jun 2006 23:45
Hi. Hopefully a quick question... how can I have the " character as part of a string without DB seeing it as the end of the string?

I'm trying to output the following to a file:
strcpy(GameData[1].back, "bob");

The quote marks are giving me trouble though as in DB the line I use looks like:
WRITE STRING 1,"strcpy(GameData[1].name, "bob");"

It's worse though... bob is actually a variable called name$, so ultimately I think I need something like:
WRITE STRING 1,"strcpy(GameData[1].name, ""+name$+"");"

Needless to say... it doesn't seem to work. Is there a way to do this?
master programmer
19
Years of Service
User Offline
Joined: 30th May 2005
Location: 3D Space
Posted: 6th Jun 2006 10:48
There are I think 3 ways that I know of.

1. Use something like this:
write string 1,"strcpy(GameData[1].name, \""+name$+"\");"
Which inserts "\" or it might be "/" not too sure.
2. Use the character code
I'm not too sure what the code is off the top of my head, but use the ASCII of the " and use the chr command.
3. On some versions of DB you can just use ""+name$+"" and it will work fine. It does in mine.

I hope I helped -- I'll try to find the character code for the "

Sock of Eternity
18
Years of Service
User Offline
Joined: 5th Jun 2006
Location:
Posted: 6th Jun 2006 21:11
It's 034, I found an ACII table. Thanks for that, option 2 worked brilliantly. So I ended up with this:

WRITE STRING 1,"strcpy(GameData[1].name, "+CHR$(034)+name$+CHR$(034)+");"

Thanks for the help. (:

Login to post a reply

Server time is: 2025-05-25 01:39:17
Your offset time is: 2025-05-25 01:39:17