Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,767 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Please help to write a program that removes the found string. #315962
03/20/10 14:00
03/20/10 14:00
Joined: Mar 2010
Posts: 26
S
Sergmodern Offline OP
Newbie
Sergmodern  Offline OP
Newbie
S

Joined: Mar 2010
Posts: 26
Please help to write a program that removes the found string in the file, and deletes the row. I can not, please ask.

Re: Please help to write a program that removes the found string. [Re: Sergmodern] #315965
03/20/10 14:19
03/20/10 14:19
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
What have you got accomplished so far? Show us your attempt.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Please help to write a program that removes the found string. [Re: Superku] #315972
03/20/10 14:37
03/20/10 14:37
Joined: Mar 2010
Posts: 26
S
Sergmodern Offline OP
Newbie
Sergmodern  Offline OP
Newbie
S

Joined: Mar 2010
Posts: 26
Here is my text of the program, but it deletes all the contents of the file.
Code:
function delete_tov()
{
var temp;
STRING* esc;
fihandle = file_open_read("strings1.dll"); // ôàéë ñîäåðæèò: j
j=file_var_read(fihandle); // òåïåðü j
file_close(fihandle);
fhandle = file_open_write("Tovar.txt"); // test.txt ñîäåðæèò "this,was,a,test"
inkey_active=0;inkey(mul);
for(i=0;i<j;i++)
{              
   file_seek(fhandle,temp,0);
   file_str_write(fhandle,"                    ");
//   delete.alpha=0; 	
//	delete1.alpha=100;
wait(1);
}
file_str_read(fhandle,acc1);
}



And it is looking for a line in the file.

Code:
function search_tov()
{
var temp1;
fhandle = file_open_read("strings1.dll"); // ôàéë ñîäåðæèò: j
j=file_var_read(fhandle); // òåïåðü j
file_close(fhandle);
fhandle = file_open_read("Tovar.txt"); // test.txt ñîäåðæèò "this,was,a,test"
inkey_active=0;inkey(mul);
temp1 = file_find(fhandle,mul);
if (temp1<0) str_cpy(ac,"Ñòðîêà íå íàéäåíà"); else
str_cpy(ac,"Íàéäåíà ñòðîêà:");
for(i=0;i<j;i++)
{              
   file_str_read( fhandle, acc);
   break;   
wait(1);
}
file_close(fhandle);
delete_tov();
}



Re: Please help to write a program that removes the found string. [Re: Sergmodern] #316053
03/21/10 03:02
03/21/10 03:02
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Check THIS THREAD out. It may be able to do the job for you.
Otherwise its inner-workings may point you in the right direction.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Please help to write a program that removes the found string. [Re: EvilSOB] #316061
03/21/10 07:35
03/21/10 07:35
Joined: Mar 2010
Posts: 26
S
Sergmodern Offline OP
Newbie
Sergmodern  Offline OP
Newbie
S

Joined: Mar 2010
Posts: 26
Good text program. But I do not understand how to turn it on to record a line in the file?
That operator: function file_open_RW (STRING * filename). I wrote a STRING * filehandle = "Tovar.txt". Accordingly, the main function will be so: file_open_RW (filehandle). But this statement does not create a new file Tovar.txt. And how to use the file_close_RW (when there file type var?) I'm writing so file_close_RW (filehandle), and an error occurs.

Re: Please help to write a program that removes the found string. [Re: Sergmodern] #316067
03/21/10 08:29
03/21/10 08:29
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Could you be more specific about the requirements of the code?

- What does your file look like?
- Does one row equal one search string or can also be searched for a part of a row but still the whole row has to be removed?

Re: Please help to write a program that removes the found string. [Re: Xarthor] #316073
03/21/10 09:43
03/21/10 09:43
Joined: Mar 2010
Posts: 26
S
Sergmodern Offline OP
Newbie
Sergmodern  Offline OP
Newbie
S

Joined: Mar 2010
Posts: 26
my file is a text, and it looks like this:

Article Name Model Price
1234 Washing Machine Indesit $ 450
1222 Iron Tefal $ 100

I need to find there a string the code of item, and to remove it is this line, but not all the data from the file.

Re: Please help to write a program that removes the found string. [Re: Sergmodern] #316080
03/21/10 10:58
03/21/10 10:58
Joined: Sep 2009
Posts: 1,032
Budapest
Aku_Aku Offline
Serious User
Aku_Aku  Offline
Serious User

Joined: Sep 2009
Posts: 1,032
Budapest
I am afraid, you can not delete one (or more) line with Lite-C or C-Script.
AFAIK to do that, you have to make a loop to read the file, line by line, and write out those line what you want to keep into a new file.
Here is a pseudo code:
open for input(original file)
open for write(temporary file)
loop while(not EOF)
read from(original)
if(we need that line)
write to(temporary)
end if
end loop
close(original file)
close(temporary file)
delete(original file)
rename(temporary to original)

Last edited by Aku_Aku; 03/21/10 11:18.
Re: Please help to write a program that removes the found string. [Re: Aku_Aku] #316081
03/21/10 11:15
03/21/10 11:15
Joined: Mar 2010
Posts: 26
S
Sergmodern Offline OP
Newbie
Sergmodern  Offline OP
Newbie
S

Joined: Mar 2010
Posts: 26
Nice algorithm, but please? tell me how may i write the code by this algorithm?
I don't understand how? The language of programming Lite-c has only 3 operators works with files,but the Pascal language has more operators, for example: Truncate,EOF,etc.

Re: Please help to write a program that removes the found string. [Re: Aku_Aku] #316083
03/21/10 11:22
03/21/10 11:22
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
This is the best I can think of, as I havent been near my file-handling code in a while.
And Im not in a very "coding" frame of mind ATM, so following your code isnt working.

Can your code find the data you want to remove, and its length in bytes?
If so, then follow these steps with my code to remove that 'chunk' of data.
Code:
// Close the file in your code.
   var LENGTH = [the number of bytes to remove];
   var START  = [the position of first byte to remove];
   // ( the number of bytes from the start of the file ) //
   var fhandle = file_open_RW(filename);
   file_bytes_remove(fhandle, LENGTH, START, 0);
   file_close_RW(fhandle);





"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Page 1 of 3 1 2 3

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1