Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How to use an integer?

Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
03-05-2006 14:55
I keep getting a syntax error on this:

CODE
llInstantMessage(llGetOwner(),"Amount: L$" +ival+ "  Product: " + sval);


ival is the amount in Linden.

I thought I was supposed to use:
CODE
llInstantMessage(llGetOwner(),"Amount: L$" +integer ival+ "  Product: " + sval);

but that does not work either.
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
03-05-2006 15:07
CODE

llInstantMessage(llGetOwner(),"Amount:" + (string)ival + "L$" + " Product: " + sval);
Kayla Stonecutter
Scripting Oncalupen
Join date: 9 Sep 2005
Posts: 224
03-05-2006 15:08
You need to typecast the integer into a string for the message, like so:
CODE
llInstantMessage(llGetOwner(), "Amount: L$" + (string)ival + " Product: " + sval);
The (string) tells SL to treat the variable as a string, but it won't change it.
_____________________
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
03-05-2006 16:56
From: Kayla Stonecutter
You need to typecast the integer into a string for the message, like so:
CODE
llInstantMessage(llGetOwner(), "Amount: L$" + (string)ival + " Product: " + sval);
The (string) tells SL to treat the variable as a string, but it won't change it.


Actualy the (string) tells SL to take the integer and build a string containing a decimal representaion of the integer. A suttle difference that indicates how LSL works internaly. Mostly nitpicking.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
03-06-2006 07:58
From: Strife Onizuka
Actualy the (string) tells SL to take the integer and build a string containing a decimal representaion of the integer. A suttle difference that indicates how LSL works internaly. Mostly nitpicking.
Mostly nitpicking in LSL - but if I could get my C++ colleagues to understand the difference between casting and converting, my life would be a lot easier :)