Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 20:05
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, 7th_zorro), 1,285 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
txt_load/file_str_read - lines with #[number] #205174
05/04/08 18:08
05/04/08 18:08

M
mercuryus OP
Unregistered
mercuryus OP
Unregistered
M



(A7 7.07.6 / lite-c [maybe c-script])

txt_load and file_str_read can't read lines starting with a '#' followed by a number (the read line is empty).


The script:
 Code:
TEXT*	txt_text = {
	
	strings=10;
	flags=VISIBLE;
	
}

void main(){
	
	video_set(800,600,32,2);
	level_load(NULL);
	
	txt_load(txt_text, "simple.txt");
	
}


with simple.txt like this:

 Code:
1. line
#2. line
3. line
#4. line
5. line
##6. line
7. line
#8. line
9. line
0. line


reads this:

1. line

3. line

5. line
##6. line
7. line

9. line
0. line

Re: txt_load/file_str_read - lines with #[number] [Re: ] #206021
05/10/08 15:34
05/10/08 15:34
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
The # and a number at beginning of a string means number of empty spaces.

Re: txt_load/file_str_read - lines with #[number] [Re: Spirit] #206101
05/11/08 08:23
05/11/08 08:23

M
mercuryus OP
Unregistered
mercuryus OP
Unregistered
M



Thats ok for string definitions (STRING* str_mystr = "#255";) but makes no sense reading/writing plain ascii-files. (\n is also not evaluated in ascii-files)
(but thanks for the hint...)

Re: txt_load/file_str_read - lines with #[number] [Re: ] #206392
05/13/08 11:15
05/13/08 11:15
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
The "#n" syntax also applies for strings in TEXT definitions, including when you preset the strings from a file. It might make no sense in your case, but that's the way it's implemented.

Re: txt_load/file_str_read - lines with #[number] [Re: jcl] #206421
05/13/08 12:56
05/13/08 12:56

M
mercuryus OP
Unregistered
mercuryus OP
Unregistered
M



Originally Posted By: jcl
The "#n" syntax also applies for strings in TEXT definitions, including when you preset the strings from a file. It might make no sense in your case, but that's the way it's implemented.


then please be consistent and include the cr/lf (\n) in the expected way.

Re: txt_load/file_str_read - lines with #[number] [Re: ] #206425
05/13/08 13:43
05/13/08 13:43
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
You don't understand. \n is just a convention of the C compiler. The string does not really contain a "\n". Within a string, a new line is the hexadecimal character sequence 0d0a and not "\n".

The "#n" on the other hand is unrelated to the programming language. It is interpreted by the string generator, and thus always causes an empty string no matter if the string is initialized in C code or from a text file.

Hope this helps.


Re: txt_load/file_str_read - lines with #[number] [Re: jcl] #206693
05/15/08 02:23
05/15/08 02:23
Joined: Oct 2003
Posts: 702
Z
zazang Offline
User
zazang  Offline
User
Z

Joined: Oct 2003
Posts: 702
Originally Posted By: jcl
You don't understand. \n is just a convention of the C compiler. The string does not really contain a "\n". Within a string, a new line is the character sequence 0d0a and not "\n".


I have a question on this.

Lets say my string is "start 0d0a end"
Then I write this string into a txt file.
When I open the txt file then will it look like this :-

start
end

thanks
zazang



I like good 'views' because they have no 'strings' attached..
Re: txt_load/file_str_read - lines with #[number] [Re: zazang] #206714
05/15/08 08:49
05/15/08 08:49
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
if your string looks like start \0x0d\0x0a end, yes.

Re: txt_load/file_str_read - lines with #[number] [Re: Joey] #206766
05/15/08 16:16
05/15/08 16:16
Joined: Sep 2006
Posts: 17
Romania
S
Serbanus Offline
Newbie
Serbanus  Offline
Newbie
S

Joined: Sep 2006
Posts: 17
Romania
Hello guys!

I've been trying the info above but I get not the expected result ... hmmmm

THE GOAL: make a .txt file that looks like this:

start
end

------------------------------------------------------------------

var fHandle; STRING* sSave = " ";
...
function fSave{

fHandle = file_open_write("test.txt");
str_cpy(sSave,"start \0x0d\0x0a end"); file_str_write(fHandle,"sSave"); //1.
str_cpy(sSave,"start 0d0a end"); file_str_write(fHandle,"sSave"); //2.

file_close(fHandle);
}

I get no error but also not the expected result.

Please, someone try it out and explain what am I missing and, if possible, the solution.

:-) THANKS ! :-)

Re: txt_load/file_str_read - lines with #[number] [Re: Serbanus] #206784
05/15/08 18:00
05/15/08 18:00

M
mercuryus OP
Unregistered
mercuryus OP
Unregistered
M



Code:
var fHandle; 

...
function fSave{

  fHandle = file_open_write("test.txt");

  file_str_write(fHandle, "start"); //1......
  
  file_asc_write(fHandle, 13);  // cr
  file_asc_write(fHandle, 10);  // lf

  file_str_write(fHandle, "end"); //2......

  file_asc_write(fHandle, 13);  // cr
  file_asc_write(fHandle, 10);  // lf

  file_close(fHandle);
}


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