problem with XDATA variable

General discussion on mikroPascal PRO for 8051.
Post Reply
Author
Message
Waldo
Posts: 9
Joined: 08 Dec 2016 09:29

problem with XDATA variable

#1 Post by Waldo » 08 Dec 2016 10:29

Hello community, I have a problem with XDATA variable ...
I hope you can help me.
An example:

Test;

Var s1: string [5]; Xdata;
S2: string [5];
L1, l2: word;

Begin
S1: = '1234';
S2: = 1234 ';
L1: = strlen (s1); // res = 0
L2: = strlen (s2); // res = 4
end.

// 8951mlk File:
<XDATA> Min 0x0000, Max 0x3fff

Why are the results not the same?

User avatar
lana.arsic
mikroElektronika team
Posts: 1715
Joined: 15 Jan 2016 12:50

Re: problem with XDATA variable

#2 Post by lana.arsic » 09 Dec 2016 14:31

Hi Waldo,

Welcome to the MikroE forum.

I'm sorry for the inconvenience caused by this issue,
I have reported it to our developers.

Meanwhile, when string is located in xdata space you can try to use this function:

Code: Select all

function strlen_xdata (str : ^xdata char) : byte;
   var len : byte;
begin
  len :=0;
   while (str^ <> 0) do
   begin
       Inc(str);
       Inc(len);
   end;
   result := len;
end;
Best regards,
Lana

Post Reply

Return to “mikroPascal PRO for 8051 General”