MMB MX4, VTFT and MP32

General discussion on mikroPascal PRO for PIC32.
Post Reply
Author
Message
janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: MMB MX4, VTFT and MP32

#4 Post by janni » 20 Jun 2011 01:03

Well, concatenation with + seems to work well (at least in simulator) and I see two problems in your code. First, the FloatToStr procedure requires a string of at least 11 chars (plus terminating char). Help examples notwithstanding :wink: .
Whatever follows the string parameter in memory will have first byte (or more, for large numbers) overwritten, if the string is declared as string[10].

Second, when forming temp_str, there's no terminating char added, so concatenation can go wrong depending on what was previously held in memory space assigned to temp_str. This goes with your description
The space between celcius appear ok the first time, after the second press of the button, or the pic freeze or random char appear in the space...
Note also that changing code frequently means rearranging variables in RAM, so while your code runs now, it may stop again after another change.

Please try to correct your code by declaring tmp_str as string[11] and adding terminating char to temp_str after copying first four chars from tmp_str (temp_str[4]:=0;), and it should work with both concatenation ways.

BTW,

Code: Select all

strcat2(ButtonRound1_Caption,temp_str,' Celcius');
is not functionally equivalent to

Code: Select all

ButtonRound1_Caption := ButtonRound1_Caption + temp_str + ' Celcius';
but rather to

Code: Select all

ButtonRound1_Caption := temp_str + ' Celcius';
That's probably a mistake while you tried to restore the old code, but I thought it'd be better to point this out in case you were going to head my advice :wink: and try with the old code.

piort
Posts: 1379
Joined: 28 Dec 2005 16:42
Location: Laval,Québec,Canada,Earth... :-)
Contact:

Re: MMB MX4, VTFT and MP32

#5 Post by piort » 20 Jun 2011 11:59

thx Janni,
i'm sure the prob was the forgotten end termination of the created string :oops:
That happens when i switch between Delphi and MP too often in the same day :roll:
I will change the list accordantly
Thx again to pointing it :wink:

Post Reply

Return to “mikroPascal PRO for PIC32 General”