Access Violation while trying to make a FloatInStr Function.
Was compiling exactly this, and i'm getting: Error: Access violation at line 27.
What's happening?
Code looks ugly, was playing around trying different things to get it working >.<.
Simba Code:
program FloatInStr;
var
i: integer;
j: integer;
txt: String;
tmpInt: Integer;
dotFound: Boolean;
newInt: array of Integer;
breakit:Boolean;
begin
txt := 'lo 21.3da';
j := 0;
dotFound := false;
breakit := false;
for i := 1 to Length(txt) do
begin
tmpInt := ord(txt[i]);
writeln(tmpInt);
if (tmpInt >= 48) then
begin
if (tmpInt <= 57) then
begin
//while (tmpInt >= 48 and tmpInt <= 57 or tmpInt = 46 and dotFound = false) do
repeat
newInt[j] := ord(txt[i+j]);
writeln('rwr ' + inttostr(j));
j := j +1;
until (j >= 4 and j>5 );
breakit := true;
end;
end;
if breakit then
break;
{
if (txt[i] == '1' or txt[i] =='2' or txt[i] =='3' or txt[i] =='4' or txt[i] =='5' or txt[i] =='6' or txt[i] =='7' or txt[i] =='8' or txt[i] =='9' or txt[i] =='0') then
begin
while (txt[i+j] = '1' or txt[i+j] ='2' or txt[i+j] ='3' or txt[i+j] ='4' or txt[i+j] ='5' or txt[i+j] ='6' or txt[i+j] ='7' or txt[i+j] ='8' or txt[i+j] ='9' or txt[i+j] ='0' or txt[i+j] ='.') do
newTxt[j] := txt[i];
end;
}
end;
end.