SRL Archive - OSR Help

Help with a proggy printout Type Mismatch error


Lama

2013-03-02 01:08:59

==SOLVED==

Hi, I have been modifying a buggy script, and decided to add a proggy. To do this, I looked at proggy code of another script, and applied logic.

However, I have run into an un-forseen snag and seek guidance.


Here's declaring proggy variables:

var // proggy variables
TimeGone, lapXP, laps, XPPerhour, TotalXP, LapsPerhour:Double;

Now I do mention that I don't know all the Simba variable types, but 'Double' doesn't seem to give errors. (I'm more versed in Java)

Heres the entire proggy procedure that I made:

procedure proggy;
begin
lapXP := 87.5;
ClearDebug;
TimeGone:=(GetTimeRunning/1000);
XPPerhour :=(3600.0 * (laps * lapXP));
TotalXP := lapXP * laps;
LapsPerhour :=(3600*(laps))/((TimeGone));
begin
Writeln('|------------------------ Proggy for the player: ' + P07_PlayerName + '-------------------------|');
Writeln('| You have gone: ' + IntToStr(laps) + ' laps. Thats ' + IntToStr(LapsPerhour) + ' laps per hour! |');
Writeln('| Overall, you have gained: ' + IntToStr(TotalXP) + ' xp. Thats ' + IntToStr(XPPerhour) + ' xp/h! |');
Writeln('|------------------------------------------------------------------------------|');
end;
end;


[Error] C:\Users\@#$%@\Downloads\Script_Iam_Fixing .simba(151:116): Type mismatch at line 150
Compiling failed.

I tested with commenting out the 2nd and 3rd proggy lines (the ones with variables in them), script compiles and runs fines, and it prints out fine when I tell it to, but it obviously lacks the information.

And other than this error, everything runs fine (with my fixes and enhancements) with the commented out proggy ^ lines ^, or without a proggy at all.

As you can see, there is a type mismatch compiling error, but I swear that all variables are similarly declared, and have been IntToStr'inged (as is visible).

What do?

Runehack123

2013-03-02 01:13:19

Show code in Simba tags otherwise I can't help. :o

Might be the case that you're using Int instead of Extended for some of your progress report values/calculation. That's all I can say about this based on what you're giving me.

Lama

2013-03-02 01:20:02

From: Runehack123
Show code in Simba tags otherwise I can't help. :o

Might be the case that you're using Int instead of Extended for some of your progress report values/calculation. That's all I can say about this based on what you're giving me.


Here's declaring proggy variables:

var // proggy variables
TimeGone, lapXP, laps, XPPerhour, TotalXP, LapsPerhour:Double;

Now I do mention that I don't know all the Simba variable types, but 'Double' doesn't seem to give errors. (I'm more versed in Java)

Heres the entire proggy procedure that I made:

procedure proggy;
begin
lapXP := 87.5;
ClearDebug;
TimeGone:=(GetTimeRunning/1000);
XPPerhour :=(3600.0 * (laps * lapXP));
TotalXP := lapXP * laps;
LapsPerhour :=(3600*(laps))/((TimeGone));
begin
Writeln('|------------------------ Proggy for the player: ' + P07_PlayerName + '-------------------------|');
Writeln('| You have gone: ' + IntToStr(laps) + ' laps. Thats ' + IntToStr(LapsPerhour) + ' laps per hour! |');
Writeln('| Overall, you have gained: ' + IntToStr(TotalXP) + ' xp. Thats ' + IntToStr(XPPerhour) + ' xp/h! |');
Writeln('|------------------------------------------------------------------------------|');
end;
end;


I tested with commenting out the 2nd and 3rd proggy lines (the ones with variables in them), script compiles and runs fines, and it prints out fine when I tell it to, but it obviously lacks the information.

And other than this error, everything runs fine (with my fixes and enhancements) with the commented out proggy ^ lines ^, or without a proggy at all.

Lama

2013-03-02 01:42:03

From: bob_saget
unless your your using decimals or possibly very large numbers you should declare your variables as an integer or extended


Well, as you can see… lapXP is indeed a decimal. Causing everything else to be a decimal as well.

The Mayor

2013-03-02 03:01:44

You may just have to use 87 as the xp per lap. You will probably only lose less than 50xp per hour. Also shouldn't your xp per hour be:

XPPerhour := ((3600 * TotalXP) / TimeGone); 

Runehack123

2013-03-02 06:21:09

Declare variables as integer or extended if decimal numbers. Don't declare as double.

Lama

2013-03-02 11:22:26

From: Runehack123
Declare variables as integer or extended if decimal numbers. Don't declare as double.


From: bob_saget
i didn't see that:duh:

try the toStr() function
http://docs.villavu.com/simba/scriptref/string.html

intToStr shouldn't work for doubles


Thanks to both of these answers, I seemed to have figured it out, thanks all. (I declared everything as Extended, then used the toStr function in the proggy printout)