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 / writing " (") " to files

Author
Message
mido
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 13th Jan 2006 23:12
how can i write this (") to files because for example when i write this


i will get an syntax error
so how can i do it (please help)

M25
Dodic
19
Years of Service
User Offline
Joined: 6th Nov 2005
Location: SNM (Serbia&Montenegro)
Posted: 14th Jan 2006 07:08 Edited at: 14th Jan 2006 07:09
Ahm..simple

just add this :

q$=chr$(34)

and then like :

write string 1,q$
close file


and if you want some text adn then " then like this :

write string 1,"your text"+q$
close file


that should work perfectly.

for more infos , click here :

http://forum.thegamecreators.com/?m=forum_view&t=69105&b=10


SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 14th Jan 2006 14:08
Don't even need the q$, you can just put
write string 1,chr$(34)

...maybe one day I'll finish a project
UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 14th Jan 2006 14:21 Edited at: 14th Jan 2006 14:27
You should search on the forum google search first. Here is a very recent thread (still on first page of this board ):
http://forum.thegamecreators.com/?m=forum_view&t=69105&b=10
I have gotten help a few times this way for a few of my questions.


Hippopotomonstrosesquippedaliophobia-Fear of long words
Dodic
19
Years of Service
User Offline
Joined: 6th Nov 2005
Location: SNM (Serbia&Montenegro)
Posted: 14th Jan 2006 22:12
Quote: "Don't even need the q$, you can just put
write string 1,chr$(34)"



it is easier with a string , easier to write , less confuzing , and quicker


mido
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 15th Jan 2006 00:14
thanks alot

M25
master programmer
19
Years of Service
User Offline
Joined: 30th May 2005
Location: 3D Space
Posted: 15th Jan 2006 10:25 Edited at: 15th Jan 2006 10:26
Quote: "it is easier with a string , easier to write , less confuzing , and quicker"


You mean using
q$=chr$(34)
write string 1,q$
is easier than using
write string 1,chr$(34)
???????

It's like 11 characters longer

Dodic
19
Years of Service
User Offline
Joined: 6th Nov 2005
Location: SNM (Serbia&Montenegro)
Posted: 15th Jan 2006 12:12
yeah it`s easier if you make any program , not if you make only ONE LINE.

And usally people make something LONGER then one line...

it is easier later like :
q$=chr$(34)
write string 1,q$
write string 1,q$ + "ha , we did it ! "
write string 1,q$ + "IT WORKS.."
write string 1,+ "yeah it "+q$+"DOES !"
------------------------------------
there`s what i thought
------------------------------------


Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 15th Jan 2006 12:15
Dodic's manner is also faster too.

you make the pc calculate the character " only once. Instead from doing it multiple times.
Altough it isn't a major slowdown, it does save a few milliseconds.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Dodic
19
Years of Service
User Offline
Joined: 6th Nov 2005
Location: SNM (Serbia&Montenegro)
Posted: 15th Jan 2006 12:17
Quote: "Dodic's manner is also faster too."


i don`t really know what that means..



No i`m cool with everything here , that was just my advice , you can all advice what ever you like - it doesn`t bother me eaven if you said "your idea is stupid.." and you didn`t , so everything is cool !


Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 15th Jan 2006 12:24 Edited at: 15th Jan 2006 20:38
Explanation:

Everyone knows that doing this:



is slower than



Why? Because in the first example, you let the computer calculate the ascii character from 34, 500000 times. In the second, you store the variable, and use that value. Or with other words, you calculate the ascii character only 1 time, and use the stored value 500000 times instead of calculating it each loop.

This technique is also mentioned in the "how do I speed my game up?" thread.
All things that have to be calculated only once, do it outside(before) the loop. It will save your pc from calculating the same thing over and over again every loop.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 15th Jan 2006 12:59
shouldn't your second snippet example have a$ in the for-next as opposed to another chr$(34)?

...maybe one day I'll finish a project
smallg
Valued Member
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 15th Jan 2006 13:00
@sven B revise your second bit of code please....
it's clear that u mean this

but just so no-one misunderstands i corrected it for you.

life's one big game
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 15th Jan 2006 18:03
The speed difference is negligble; if you think about it it's not 'generating' a character; it's just writing one byte to memory and then reading it again, only as an ASCII character instead of a number.

With a string it'd also have to read how long the following string is about to be, so i'm not sure if there *is* a speed difference at all.

Support the AAANJL by doing nothing! Visit teh site below..
mido
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 15th Jan 2006 18:49
i have another proplem
when i try to write the color information to a file i get the red,green,blue = 0 i don't know why





i have attached the image

M25

Attachments

Login to view attachments
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 15th Jan 2006 20:38
Quote: "@sven B revise your second bit of code please...."


You're right. My apologies. I must've type too fast.
Thx for pointing it out.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 15th Jan 2006 22:07 Edited at: 15th Jan 2006 22:09
Quote: "i have another proplem
when i try to write the color information to a file i get the red,green,blue = 0 i don't know why"


It's because when you use a sprite any reading/writing from/to the screen only works under the sprite. You need to paste the image to the screen to see it with the "point" command.

Also there's no need to create extra variables for things like parentheses and theres no need to add a single space to a string with the + sign when you can add it to the string before it.




Dodic
19
Years of Service
User Offline
Joined: 6th Nov 2005
Location: SNM (Serbia&Montenegro)
Posted: 15th Jan 2006 23:09
Yeap , that code works , i tryed it (i mean grog grueslayer`s..)




p.s. do you like my randomized avatar ? - every time you open a page with my avatar on it , avatar will be different , a php thing..


mido
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 15th Jan 2006 23:35
now it works
thanks grog

M25
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 16th Jan 2006 03:07
@ Dodic
I always test out code before I post. I've have seen several of your messages and I only see the bouncing smile.

@ mido
Np.


Dodic
19
Years of Service
User Offline
Joined: 6th Nov 2005
Location: SNM (Serbia&Montenegro)
Posted: 16th Jan 2006 03:32
no , my randomizer works perfectly , try again or something , you`l HAFE to see the changes , the code IS tested , and it`s so simple that it`s VERY HARD THAT ANYTHING`S WRONG with it...


(it changes when you refresh the page , and when you quit the page and enter it again , or enter another , at least i think..)


Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 16th Jan 2006 03:56
You probably just need more pictures. I refreshed several times and have seen the bouncing smile 2 times the alien 4 times and now a smile that doesn't bounce.


Dodic
19
Years of Service
User Offline
Joined: 6th Nov 2005
Location: SNM (Serbia&Montenegro)
Posted: 16th Jan 2006 04:47
oh , it`s ok , i won`t use more picture , it doesn`t need to be much randomized , it only needs to be well , different...


Login to post a reply

Server time is: 2025-05-22 23:46:17
Your offset time is: 2025-05-22 23:46:17