Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, dr_panther), 834 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Read a text file line by line #342590
09/29/10 15:24
09/29/10 15:24
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline OP
Serious User
PadMalcom  Offline OP
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Hi, I have a text file and want to read one line after another into a String. The lines will contain characters like "\n" etc. Any ideas?

Re: Read a text file line by line [Re: PadMalcom] #342604
09/29/10 16:15
09/29/10 16:15
Joined: Dec 2002
Posts: 616
Austria
Stromausfall Offline
User
Stromausfall  Offline
User

Joined: Dec 2002
Posts: 616
Austria
hmmm file_str_readto seems to do what you want ! it even has a delimiter -> which you can set to '\n' !


get the C# wrapper:
for A7.85.4 and A8.30.4, Version 2.3.9
at http://acknexwrapper2.matthias-auer.net/ or visit the thread
Re: Read a text file line by line [Re: Stromausfall] #342606
09/29/10 16:24
09/29/10 16:24
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
Why not use txt_load(TEXT*,STRING* filename) and then iterate through the strings and fill thim into one string?


~"I never let school interfere with my education"~
-Mark Twain
Re: Read a text file line by line [Re: Germanunkol] #342617
09/29/10 17:50
09/29/10 17:50
Joined: May 2009
Posts: 445
Peine, Germany
Razoron Offline
Senior Member
Razoron  Offline
Senior Member

Joined: May 2009
Posts: 445
Peine, Germany
Write a DLL and use getline().

Re: Read a text file line by line [Re: Razoron] #342630
09/29/10 18:25
09/29/10 18:25
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Originally Posted By: Razoron
Write a DLL and use getline().

And I thought Lite Foundation would be the overkill, but your solution beats everything oO


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Read a text file line by line [Re: WretchedSid] #342632
09/29/10 18:34
09/29/10 18:34
Joined: May 2009
Posts: 445
Peine, Germany
Razoron Offline
Senior Member
Razoron  Offline
Senior Member

Joined: May 2009
Posts: 445
Peine, Germany
STL vs. Lite-C
STL wins!

Re: Read a text file line by line [Re: Razoron] #342633
09/29/10 18:39
09/29/10 18:39
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
No, the shortest and easiest way to achieve your target wins. You solution is neither short nor easy.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Read a text file line by line [Re: WretchedSid] #342634
09/29/10 19:10
09/29/10 19:10
Joined: May 2009
Posts: 445
Peine, Germany
Razoron Offline
Senior Member
Razoron  Offline
Senior Member

Joined: May 2009
Posts: 445
Peine, Germany
But it has the best performance.

Re: Read a text file line by line [Re: Razoron] #342636
09/29/10 19:14
09/29/10 19:14
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
No, it doesn't. Mapping the DLL into the memory, calling the function etc. will cost much more than reading those few lines directly through Gamestudio.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Read a text file line by line [Re: WretchedSid] #342701
09/30/10 09:08
09/30/10 09:08
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline OP
Serious User
PadMalcom  Offline OP
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
I agree, the point that I want to write such a function is to avoid using DLLs which would be no problem but not pretty nice.

@Stromausfall: Problem is that one line might contain "\n" in between not only at the end.

@Germanunkol: I think your solution is the best even if it is not as beautiful as I wanted.

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1