Author Topic: Reading a file till reaching a certain symbol/letter  (Read 570 times)

Is this possible, cause i try while's and if's and even for's like this
While(getSubStr(%file,0,%a) !$= Letter){%a++;}
But it always crashes me

while(!%file.isEOF()){

Silly me.
« Last Edit: December 09, 2009, 09:55:51 PM by rkynick »

while(!%file.isEOF()){
not that im talking for it to stop till it reaches a certain symbol like | or <

Try something like
while(!%file.isEOF() && !%stop){
if([check for letter, probably strpos or char or something]){
%stop=1;
}

Try something like
while(!%file.isEOF() && !%stop){
if([check for letter, probably strpos or char or something]){
%stop=1;
}
Will try that i did do this
%a = 1;
while(1 == 1){if(getStrPos(%thethingtillreach|, 0, %a) !$= "|"){%a++;}
but i will try that
would this possibly work?
while(!%file.isEOF || !%stop){if(getSubStr(%thethingtillreach|, %lol, 1) !$= "<"){%lol++;}}
« Last Edit: December 09, 2009, 10:58:29 PM by Pah1023 »

Tom

Please write your code so people can read it better.
That won't work because it looks like will check the lines like this (red = char being checked)

xxxxxx
xxxxxx
xxxxxx

What I think you'll have to do is have a loop for each line, and go though all the chars. (note: this may get laggy)
Or use strPos (I think, im a little rusty on my string functions) in some way.

It would be much easier if you just made it stop at a line the says "<END>", if it would work for what your doing.

Code: [Select]
while(!%file.isEOF())
{
   %line = %file.readLine();
   if(strPos(%line,"char") >= 0)
      break;
}

Code: [Select]
while(!%file.isEOF())
{
   %line = %file.readLine();
   if(strPos(%line,"char") >= 0)
      break;
}
Will try that.
EDIT: I need to know like how many char. till it reaches the Char.
« Last Edit: December 10, 2009, 04:47:07 PM by Pah1023 »

Tom

That would need loops in a loop and that would be extremely inefficient.

EDIT: Just had another idea that might work better.
Maybe expand on Ephialtes'. If the char is in the line, have it loop though the whole line. If its not, have it go onto the next line.
« Last Edit: December 10, 2009, 06:32:29 PM by Tom »

Will try that.
EDIT: I need to know like how many char. till it reaches the Char.
Just gonna edit Ephi's code here
Code: [Select]
%charcount = 0;
while(!%file.isEOF())
{
%line = %file.readLine();
if((%pos = strPos(%line, "char")) >= 0)
%charcount+= %pos;
break;
else
%charcount+= strLen(%line);
}
echo(%charcount);