Forum in READ ONLY mode! All questions and discussions on Discord official server, invite link: https://discord.gg/VxsGzJ7

where the error?

Ask for help
Post Reply
-k-
Neophyte
Neophyte
Posts: 41
Joined: 23.01.2012 0:22

where the error?

Post by -k- »

When i run this script, no recorded all in tiles_tree.txt, only "1000,", nothing more
code
Program WriteTXT;
var
x, y : integer;

procedure WriteToFile(filepath: string; coord: string);
var
file: TFileStream;
begin
try
file := TFileStream.Create(filepath,fmOpenReadWrite);
file.seek(0, soFromEnd);
except
file := TFileStream.Create(filepath,fmCreate);
end;
file.WriteBuffer(coord,Lenght(coord));
file.Free;
end;

Begin
X := 1000;
y := 9999;
WriteToFile('D:\progs\uo\txts\tree_tiles.txt', IntToStr(x)+ ',' +IntToStr(y)+ '-');
End.
Last edited by -k- on 23.07.2014 20:12, edited 1 time in total.
-k-
Neophyte
Neophyte
Posts: 41
Joined: 23.01.2012 0:22

Re: where the error?

Post by -k- »

i found the error, but i dont understand. when i put "file.WriteBuffer(coord,Lenght(coord));", the script write only "1000,", but when i put "file.WriteBuffer(coord,Lenght(coord)*2);", the script write all in .txt
drabadan
Expert
Expert
Posts: 730
Joined: 13.12.2012 17:35
Contact:

Re: where the error?

Post by drabadan »

maybe try to initialize the string earlier;

Code: Select all


Begin
X := 1000;
y := 9999;
string1 := IntToStr(x) +',' + IntToStr(y) + '-';
WriteToFile('D:\progs\uo\txts\tree_tiles.txt', s);
End.
can ask you - why you need this, what is it for? Maybe there is another solution of your task?
-k-
Neophyte
Neophyte
Posts: 41
Joined: 23.01.2012 0:22

Re: where the error?

Post by -k- »

i use for mark respaw tree. =]]

Procedure Search(Tile, X, Y, Z: Integer);
Var
end : boolean;
Begin
if InJournal('elf') <> -1 then
begin
WriteToFile('D:\progs\uo\txts\elf.txt', IntToStr(Tile) +' ' +IntToStr(x) +' ' +IntToStr(y) +' ' +IntToStr(z) + #13#10);
end:=true;
clearjournal;
wait(100);
end;
end;


Search(TreesArray.Tile, TreesArray.X, TreesArray.Y, TreesArray.Z);
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: where the error?

Post by Vizit0r »

-k- wrote:i found the error, but i dont understand. when i put "file.WriteBuffer(coord,Lenght(coord));", the script write only "1000,", but when i put "file.WriteBuffer(coord,Lenght(coord)*2);", the script write all in .txt
just unicode, 1 char = 2 bytes. in old version 1 char = 1 byte.
thats mean your "WriteToFile" was outdated.
here - http://stealth.od.ua/forum/viewtopic.php?f=6&t=995 - its already changed and explained.
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: where the error?

Post by Vizit0r »

-k- wrote:i use for mark respaw tree. =]]

Procedure Search(Tile, X, Y, Z: Integer);
Var
end : boolean;
Begin
if InJournal('elf') <> -1 then
begin
WriteToFile('D:\progs\uo\txts\elf.txt', IntToStr(Tile) +' ' +IntToStr(x) +' ' +IntToStr(y) +' ' +IntToStr(z) + #13#10);
end:=true;
clearjournal;
wait(100);
end;
end;


Search(TreesArray.Tile, TreesArray.X, TreesArray.Y, TreesArray.Z);



oh shi.
use "clearjournal;" - bad way. really bad. injection\EUO-style.
use "injournalbetweentimes"
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
-k-
Neophyte
Neophyte
Posts: 41
Joined: 23.01.2012 0:22

Re: where the error?

Post by -k- »

hehe, thx man.
i gonna use betweentimes, thx so much
kovalevserg
Posts: 1
Joined: 30.06.2015 14:58
Location: Страна
Contact:

where the error

Post by kovalevserg »

this is for andrexia the shard scripter. i have noticed that magic reflection items moonstone does not come up on the .myinfo prot list. only magic immunity.
k
Post Reply