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

whats wrong with this script?

Ask for help
Post Reply
01101011
Neophyte
Neophyte
Posts: 21
Joined: 17.01.2019 0:19

whats wrong with this script?

Post by 01101011 »

Code: Select all

Program Test;
Var
fx, fy : integer;

const
x0 = 0;
x1 = 10;
y0 = 0;
y1 = 10;

procedure Find;
begin
    for fy := 0  to ((y1 - y0) / 5) do
    begin
        for fx := 0  to ((x1 - x0) / 5) do
        begin              
            addtosystemjournal(fx + ' - ' + fy);
        end; 
    end;
end;


Begin    
    Find;
End.
00:00:00:000 [name]: Compiler: [Error] (C:\Stealth\Scripts\test.sc at 13:37): Type mismatch
00:00:00:000 [name]: Compiling failed
ty for att =]]]]
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: whats wrong with this script?

Post by Vizit0r »

operand / returns number with floating point (single, extended, double)
operant div returns whole number (integer, word and other integral types)

float types cant be used in "for to do" cycles condition

Code: Select all

Program Test;
Var
fx, fy : integer;

const
x0 = 0;
x1 = 10;
y0 = 0;
y1 = 10;

procedure Find;
begin
    for fy := 0 to ((y1 - y0) div 5) do
    begin
        for fx := 0  to ((x1 - x0) div 5) do
        begin             
            addtosystemjournal(IntToStr(fx) + ' - ' + IntToStr(fy));
        end;
    end;
end;


Begin   
    Find;
End.
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
01101011
Neophyte
Neophyte
Posts: 21
Joined: 17.01.2019 0:19

Re: whats wrong with this script?

Post by 01101011 »

ty bro =]
Post Reply