K
K
Kostylev20212021-06-03 16:13:45
PHP
Kostylev2021, 2021-06-03 16:13:45

How to remove unwanted lines?

You need to delete everything from the rezult file that is for 10.01 and write the cleared line back
. The line in the rezult file: 1 888 10.01 "SOPHY CINNAMON" Board Ch HSK
here is the code

var a,str2:string;
 i,y:integer;
 rezult: text ;
begin 
   AssignFile(rezult,'c:\way\rezult.txt');
   reset(rezult);
   
 while not EOF(rezult) do
   
   
 begin
    readln(rezult,str2);
    i:=length(str2);
    y:=pos('10.01',str2);
    delete(str2,y,i);
    Writeln(rezult,str2);
 end;
end.

writes the file is not open for writing.
How to fix it ?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Artyom Belousov, 2019-02-11
@kamisarlapsha

Ternary operator. What is before the colon will be returned if the expression is true, otherwise the operator will return what is after the colon.
php.net/manual/en/language.operators.comparison.php

R
Rsa97, 2019-02-11
@Rsa97

Ternary operator

L
leni_m, 2019-02-11
@leni_m

this is a shorthand for if else

K
Kostylev2021, 2021-06-03
@Kostylev2021

Decided by myself

var a,str2,str3:string;
 i,y:integer;
 rezult,rezult2: text ;
begin 
   AssignFile(rezult,'c:\way\rezult.txt');
    AssignFile(rezult2,'c:\way\rezult2.txt');
  
    reset(rezult);
    rewrite(rezult2);
 while not EOF(rezult) do
   
   
 begin
   
    readln(rezult,str2);
    i:=length(str2);
    y:=pos('10.01',str2);
    delete(str2,y,i);
   writeln(rezult2,str2);


 end;
 close(rezult); close(rezult2);
end.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question