LabelGUI display function results (SOLVED)

Started by Sam., Sun 30/01/2005 14:11:02

Previous topic - Next topic

Sam.

I have a code that returns an integer value. Unfortunatley i want this to be displayed on a gui. the only way i could think was a GUI label and use the setlabeltext function. unfortunatley it oes not accept integer values. is there a way to put an integer value onto a gui?

EDIT: See my last post
Bye bye thankyou I love you.

Rui 'Trovatore' Pires

string quickie;
StrFormat(quickie, "%d", integervalue);
lblGUILabel.SetText(quickie);

(if you don't have the beta, replace that last line with the one that is actually used)

BTW, I'm sure this is in the manual. Look in the entry for converting STRING TO INT.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Sam.

you win. it IS in the manual, i didn't look hard enough. cheers.
Bye bye thankyou I love you.

Rui 'Trovatore' Pires

Heh. Didn't mean to sound like a bully or like a competitor. ;)
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Sam.

This was supposed to be a secret but it just won't work. I want a label on my gui which diplays the roman numerals of an integer. Below are my funcitons for this code. How can i get what these return to display in a gui label as a string?

Code: ags
// In local script where you want to print the numerals or in the script setting the label (for the label you should probably use a string that would store the whole number and set that as the label).

/*
** Print numbers fron 1 to 25 as Roman numerals.
*/

Ã,  Ã,  Ã,  Ã,  int x = 1;
Ã,  Ã,  Ã,  Ã,  Display("This program prints out Roman Numerals.");
Ã,  Ã,  Ã,  Ã,  while (x <= 25)Ã,  {
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  roman (x);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  x = x + 1 ;
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  Display("I hope you liked it!");
// In global script

/*
** Display the character c as many times as there are
** j's in the number i, then return i minus the j's
*/
function romanize (int i,int j,char c) {

Ã,  Ã,  Ã,  Ã,  while (i>=j)
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Display("%c", c);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  i = i - j;
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  return i;
}


// In global script

/*
** Print an Arabic number in Roman numerals.
*/
function roman (int number) {
int arabic = number;
Ã,  Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  arabic = romanize(arabic,1000,'m');
Ã,  Ã,  Ã,  Ã,  arabic = romanize(arabic,500,'d');
Ã,  Ã,  Ã,  Ã,  arabic = romanize(arabic,100,'c');
Ã,  Ã,  Ã,  Ã,  arabic = romanize(arabic,50,'l');
Ã,  Ã,  Ã,  Ã,  arabic = romanize(arabic,10,'x');
Ã,  Ã,  Ã,  Ã,  arabic = romanize(arabic,5,'v');
Ã,  Ã,  Ã,  Ã,  arabic = romanize(arabic,1,'i');
Ã,  Ã,  Ã,  Ã,  romanize(arabic,1,'i');
Ã,  Ã,  Ã,  Ã,  Display(" ");
Ã,  Ã,  Ã,  Ã,  }

// In global script

/*
** Display the character c as many times as there are
** j's in the number i, then return i minus the j's
*/
function romanize (int i,int j,char c) {

Ã,  Ã,  Ã,  Ã,  while (i>=j)
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Display("%c", c);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  i = i - j;
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  return i;
}

// In script header (of you want to use the functions in local scripts, or for convenience:

import function romanize (int i,int j,char c);
import function roman (int number);
Bye bye thankyou I love you.

Pumaman

Well, there seems to be something funny with your braces for a start. What exactly is the problem you're having?

Sam.

basically, I found a C code to convert arabic numbers to roman numerals, i asked ginny to convert it to AGS script, she cam back with this. I then HAve an integer variable called MyScore. I the want to set a gui label to MYScroe as roman so i call

SetLabelText(8,2, roman(Myscore));

but i get an error message telling em there is a type mismatch so i use the strformat to change it to a string.

StrFormat(BUffer,"%d", Myscore));
SetLabelText(8,2,roman (Buffer));

Still no joy. i get the same mismatch error
Bye bye thankyou I love you.

Pumaman

StrFormat(BUffer,"%d", roman(Myscore));
SetLabelText(8,2,Buffer);

is what you want

Takara

I have to admit I haven't looked at your code, but if you check out this thread: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=18915.0 then I made some functions yesterday which convert the current score into a roman numeral.

Takara.

Sam.

sorry Takara, i didn't read what your code did but now i understand and it works great. thanks very much.
Bye bye thankyou I love you.

SMF spam blocked by CleanTalk