SRL Archive - General

Quick Question:


WT-Fakawi

2006-09-30 18:38:02

how do I check newline in a string?

The loop below reads a character off a file, inserts it into string line. It needs to stop upon character reaching newline (keycode 13)

file:=OpenFile('C:/test.txt',False);
repeat
ReadFileString(file,character,1);
count:=count+1;
insert(character,line,count);
writeln(regel);
until(character= ''); // <- CHECK UNTIL NEWLINE

Never done that before. Its prolly very simple, only I dont know how, and I dont want to look it up….

I am using it for a autoer-to-autoer private chat routine.

Starblaster100

2006-09-30 18:49:32


Procedure WriteNews(HowMany: Integer);
Var
i, x, y: integer;
News : Array of String;
New, TheNews : String;
Begin
SetArrayLength(News, HowMany+1);
TheNews := Getpage('');
x := 0;
y := 1;
For i := 1 to HowMany do
Begin
repeat
x := x + 1;
new := copy(TheNews, x, x+1);
until(copy(new, 1, 1) = ',');
news[i]:= copy(TheNews, y, (x-y));
y := x + 1;
AddToReport(' :: '+news[i]);
end;
end;

from stress miner. this keeps on copying characters until it meets a comma ',' it will then write the characters it has copied and start again. it will repeat this 'howmany' times
i.e. if i wanted to display 5 pieces of news, 'howmany' would be 5.

Format to write out news:

hello my name is starblaster100,blah blah blah,this is an example for fawki
would appear like this in scar:

hello my name is starblaster100
blah blah blah
this is an example for fawki

not sure if this is what ur looking for but you can modify it to fit your needs im sure :)

WT-Fakawi

2006-09-30 18:51:32

chr(13):duh: :duh: :duh:

lardmaster

2006-10-18 20:01:31

or do
untill
getkeycode(string)=13 :):):)

Pyro

2006-10-19 15:01:55

Ahhh not sure if its the same with files but star is right. I had to do the same thing when using getpage. I think it returned god awful characters if i used spaces and then tried to return them. Atleast i think so.