Rockbox Development > Starting Development and Compiling
Writing to a file, will not create new line.
Jazz00006:
i have tried using code
rb->lcd_setfont("Unifont");
or other similar ones, rb->lcd_setfont(Unifont); , rb->lcd_setfont(Font_Unifont);
but it gives me a small error, any ideas on this?
Jazz00006:
^^ dont worry about the above, new question
how would i write to a file, but with each write, make a new line? (I am only having trouble with the new line part)
In my file i have something similar to
--- Code: ---fd = rb->open(Temp_Data,O_RDWR | O_CREAT);
while(rb->read_line(file,buffer1,100) != NULL)
{
char* pos = rb->strcasestr(buffer1,word);
if(pos != 0)
{
rb->fdprintf(fd, buffer1, sizeof(buffer1));
rb->yield();
}
}
rb->close(fd);
--- End code ---
but with every time it does a search and write it only writes continusly, no gaps or spaces, only continous words.
Any help will be greatly apreciated, thankyou
bluebrother:
--- Quote from: Jazz00006 on October 14, 2006, 04:30:26 AM ---
--- Code: ---fd = rb->open(Temp_Data,O_RDWR | O_CREAT);
while(rb->read_line(file,buffer1,100) != NULL)
{
char* pos = rb->strcasestr(buffer1,word);
if(pos != 0)
{
rb->fdprintf(fd, buffer1, sizeof(buffer1));
rb->yield();
}
}
rb->close(fd);
--- End code ---
--- End quote ---
fdprintf prints a formatted text, so you need a formatter string. Why don't you use write instead?
--- Code: ---rb->write(fd, buffer, sizeof(buffer));
--- End code ---
should do it. You may also want to write only the amount of bytes read by read_line.
Jazz00006:
nope, that still gives me continous text,
heres a sample of what i get from it.
#!Translate Output File###Searching for: window ###==Begin File==# window: Fenster ühlen ) raße (f) ve] - igkeit ie Kühe nach Hause kommen ..) ] ichkeit[Noun] window: Fenster (n) n ) raße (f) ve] - igkeit ie Kühe nach Hause kommen ..) ] ichkeit[Noun] window glass: Fensterglas (n) (f) ve]
heres what i would like to see
#!Translate Output File#
#
#Searching for: window
#
#==Begin File==#
window: Fenster ühlen
window: Fenster (n)
window glass: Fensterglas (n) (f)
I understand some things are my fault, but the new line part isnt.
thanks for any help you wish to give
bluebrother:
--- Quote from: Jazz00006 on October 15, 2006, 07:01:26 PM ---nope, that still gives me continous text,
heres a sample of what i get from it.
--- End quote ---
You are using read_line. From the comments of the read_line function (in apps/misc.c) you can find that all line ending characters are stripped. So you either need to read the lines a different way or add a line ending character after each line you wrote.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version