String length

General discussion on mikroPascal for AVR.
Post Reply
Author
Message
LJStefan
Posts: 90
Joined: 17 Feb 2006 16:47
Location: Austria

String length

#1 Post by LJStefan » 14 Apr 2006 16:25

Hi All,

Can anybody tell me whats the error is?

Code: Select all

procedure GText(sText : string[40];X,Y: byte);
var
  b : byte;
  l : byte;
begin
  l := Length(stext); // <----Error
  for b := 1 to l-1 do
    begin

    end;

end;
130:20 9 Error in ASM code: Address is out of range "LDI R16, @basicfunc_gtext_param_stext (69)" BasicFunc.apas

Thanks in advance,
Stefan

anton
Posts: 807
Joined: 23 Sep 2004 09:16
Location: South-Africa
Contact:

#2 Post by anton » 15 Apr 2006 07:52

Hi LJStefan,

Try changing the code like this

Code: Select all

procedure GText(var sText : string[40];X,Y: byte); // pass by address !!!
var
  b : byte;
  l : byte;
begin
  l := Length(stext); // <----Error
  for b := 0 to l-1 do // Run from 0 to length - 1 
    begin

    end;

end; 
Anton
Another proud user of LV 24-33A Development System and mikroPascal PRO for dsPIC :)
PortA not working? Add CMCON := 7; PortD not working? Add ADCON1 := 6;
To paste code on the forum, please use the [b] Code [/b] button !! ;)

LJStefan
Posts: 90
Joined: 17 Feb 2006 16:47
Location: Austria

#3 Post by LJStefan » 15 Apr 2006 09:31

Hello Anton,

Thanks for your answer.

Now it Works.

vanja
mikroElektronika team
Posts: 253
Joined: 27 Jan 2005 15:13
Contact:

#4 Post by vanja » 18 Apr 2006 07:48

String is always sent by reference (always put var before string parameter).

Post Reply

Return to “mikroPascal for AVR General”