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 Professional Discussion / Output to text file and new line?

Author
Message
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 10th Jun 2013 13:20
I would like to output some text to a .txt file.

What command would I write a line with? And how do I make a new line?

I use OPEN TO WRITE 1,mytextfile.txt and then what?



The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 10th Jun 2013 13:42
If you use write string it will automatically put a line break after each string (I believe that is the only delimiter between the strings so you can not write a string with line breaks in it or you would have to read it back in as several strings. Also if you then read the strings back in in binary mode I don't think they are zero-terminated).
If you on the other hand write your string manually, you would write the characters with the corresponding ASCII values 13 (carriage return) and 10 (line feed).


"Why do programmers get Halloween and Christmas mixed up?"
hank
13
Years of Service
User Offline
Joined: 10th Feb 2013
Location: Kentucky, USA
Posted: 10th Jun 2013 14:16
I use the matrix1 utility plugin for this. Here is an example.





Something like that. OPEN DATAFILE TO APPEND opens a file for either read or write.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 10th Jun 2013 17:17


This will output the following to your text file:


You can insert line breaks with the following code:



This will output the following to your text file:


For a reference of all ASCII characters, you can refer to the ASCII table here: http://www.asciitable.com/index/asciifull.gif

You can see in the image that 10 and 13 are used to create new lines on Windows. Unix operating systems only need a new line feed without the carriage return (probably not so relevant).

TheComet


Yesterday is History, Tomorrow is a Mystery, but Today is a Gift. That is why it is called "present".
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 12th Jun 2013 10:37
Thank you guys! All the info I need is here

@TheComet:
Quote: "Unix operating systems only need a new line feed without the carriage return (probably not so relevant)."

Haha, no, it ain't I do not intend to use Unix Does it still exist??

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 12th Jun 2013 15:08
Everything is unix based these days, even android and blackberry.

This is my current project, check it out! [href]forum.thegamecreators.com/?m=forum_view&t=204576&b=8[/href]
This is my website, check it out! [href]http:\\www.TeamDefiant.co.uk[/href]
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 12th Jun 2013 18:17 Edited at: 12th Jun 2013 18:18
Quote: "Does it still exist??"


Pretty much everything that isn't Microsoft is Unix based. Mac, Linux, Android, Raspberry, Blackberry...

Microsoft really is the odd one out when it comes to software development. They just have to do everything differently, even with simple things like carriage returns, or backslashes instead of forward slashes...

TheComet


Yesterday is History, Tomorrow is a Mystery, but Today is a Gift. That is why it is called "present".
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 13th Jun 2013 14:38
Okay Maybe I should read a little about Unix some day

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...

Login to post a reply

Server time is: 2026-07-08 01:55:14
Your offset time is: 2026-07-08 01:55:14