Hey.
I have a problem with displaying my magic points in the GUI.
Here is the code I have -
function repeatedly_execute() {
String magic;
String.Format(magic, "%d", GetGlobalInt(2));
lbla.Text=String.Format(0, 4, magic));
}
The error message I am given says -
Type Mismatch : cannot convert 'int' to 'const string'
Help a noobie plz?
This is what you'll want to do:
function repeatedly_execute() {
lbla.Text = String.Format("Magic: %d", GetGlobalInt(2));
}
thank you so much!
thats sorted the problem out.
Quote from: Diji1 on Thu 17/01/2008 15:42:11
lbla.Text=String.Format(0, 4, magic));
While the solution has already been given by Pablo, the problem is in the line above. The first and second arguments to String.Format need to be strings, not integers.
If by the "0, 4" stuff you wanted to display leading zeros, here's the proper way (with the corrected intermediate step):
function repeatedly_execute() {
String magic;
magic = String.Format("%04d", GetGlobalInt(2));
lbla.Text= magic;
}
But, as was shown, using a variable isn't necessary here.