2 registered members (AndrewAMD, 7th_zorro),
1,285
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
txt_load/file_str_read - lines with #[number]
#205174
05/04/08 18:08
05/04/08 18:08
|
mercuryus
OP
Unregistered
|
mercuryus
OP
Unregistered
|
(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:
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:
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: Spirit]
#206101
05/11/08 08:23
05/11/08 08:23
|
mercuryus
OP
Unregistered
|
mercuryus
OP
Unregistered
|
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: jcl]
#206421
05/13/08 12:56
05/13/08 12:56
|
mercuryus
OP
Unregistered
|
mercuryus
OP
Unregistered
|
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: jcl]
#206693
05/15/08 02:23
05/15/08 02:23
|
Joined: Oct 2003
Posts: 702
zazang
User
|
User
Joined: Oct 2003
Posts: 702
|
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: Serbanus]
#206784
05/15/08 18:00
05/15/08 18:00
|
mercuryus
OP
Unregistered
|
mercuryus
OP
Unregistered
|
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);
}
|
|
|
|