I tried var = (integer)variablethatis10
doesn't seem to work.
Thanks in advance

These forums are CLOSED. Please visit the new forums HERE
Quick question |
|
Chase Bravo
Junior Member
Join date: 18 Jun 2004
Posts: 13
|
06-21-2004 16:50
if I have the Text "10" and I want to load it into an integer varible as the "number" 10. How do I do it?
I tried var = (integer)variablethatis10 doesn't seem to work. Thanks in advance ![]() |
Chase Bravo
Junior Member
Join date: 18 Jun 2004
Posts: 13
|
06-21-2004 17:07
nvm
![]() |
Catherine Omega
Geometry Ninja
![]() Join date: 10 Jan 2003
Posts: 2,053
|
06-21-2004 17:53
For those of you who were hoping someone would give Chase an answer, see the badgeometry page on explicit typecasting.
_____________________
|
Chase Bravo
Junior Member
Join date: 18 Jun 2004
Posts: 13
|
06-21-2004 18:03
oops sorry, actually it worked the way I originally had it. It was a silly syntax error LOL.
intRange = (integer)llGetSubString(mes,5,6); |
Azelda Garcia
Azelda Garcia
Join date: 3 Nov 2003
Posts: 819
|
06-21-2004 19:07
Offtopic warning: theres a bug in the LSL compiler if you dont put spaces around "-" signs.
I understand you're not using "-" signs here, but I'm sure you will be ![]() Azelda |
Eggy Lippmann
Wiktator
![]() Join date: 1 May 2003
Posts: 7,939
|
06-21-2004 19:43
No there isnt. Something like total-1 generates a syntax error now, instead of LSL thinking its a variable.
_____________________
|
Strife Onizuka
Moonchild
![]() Join date: 3 Mar 2004
Posts: 5,887
|
06-21-2004 23:30
if you've been out of the loop, you haven't been able to use "-" in variable names for a while, else i would have.
![]() _____________________
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 |
wizzie Baldwin
Registered User
![]() Join date: 23 May 2004
Posts: 52
|
not a good idea
07-14-2004 00:58
Hi everyone,
I just wanted to put in my 2.4898658848 cents on this topic I may not be an expert in Linden Script, but I have been around the block more than once with about 11 other languages. I have found that a prudent approach to programming is forming good habits with respect to variable names. The C programming language ignores white spaces when a compiler parses the source code. You would not be allowed to use the expersson a-b=5; any more than you could use max-distance = 10; it is (and this is just my opionion from many many many years of practice in this field) a bad idea to frame variable names using math operators. Would you have a variables like: avitar*name? or fist/pos? or last+location? if not why would anyone think that "this-variable" is acceptable? Why not consider several diffrent approaches like: ThisVariable, LastPos, MaxDistance or this_variable, last_pos, max_distance as examples. On very large complex (over 10 million lines of code) systems, that i have been involved with, we had rules for naming conventions (a must when there are over 65 gung_ho software engineers chomping away at all of this code) For myself, i use, depending upon the complexity of the program nameing conventions that make sense to me I used to program in Fortran so i,j,k,l,m,n,o are integers to me and sometimes i use them like that .. for simple structured loops etc. But most of the time I like to create variables that have an almost self documenting aspect to them. (NOT quite as self_documenting_as_COBOL.) i take a lot of short cuts for a lot of things but in production code i usually do something similar to this (using simple c syntax) char strMsg[40]; int intCounter; double dblCurrentTotal; bool bFlag; long lngBigVariable; char cSingleChar; int iarr[10]; double darr[20]; float farr[10][2]; register rIndex; etc. Linden script ... vector vPos; key kId; etc. something along those lines .. all of this can translate into Linden script, visual basic, C++, Pascal, PHP almost any language. Sometimes I use underscores also. For me this practice makes sense for several reasons, it makes me think about the kinds of variables i'm using (if memory constraints are an issue ... less and less problematic these days with machines haveing 2 to 3 Gig) and it keeps me sane on what that variable expects to contain. Everybody has their own style of programming and that's a wonderful thing. There is, essentially, no "correct" way to program. A program is a finite set of instructions that performs a specific task. If any given program performs the task without failing then that's acceptable. But, and this is a big BUT, what can be said about the program? Is it maintainable? Is it readabe? Can it be understood by anyone other than the original author? Can it be easily modified? Is it a performance hog? Does it have modularity? etc., etc., etc. With an almost infinite number of ways to write code, you can save your self a lot of headaches if you keep the KISS principle formost in your mind when coding. Plus a clear way to describe variables used that can be used with almost any language and environment regards, wizzie |
Enkil Prototype
Junior Member
Join date: 7 Jul 2004
Posts: 7
|
07-14-2004 08:37
I get what you are saying there, wizzie.
Im 2 years from my BA in programmin(still a student), and the oly thing that ever relly changes between programming languages is the way functions are named. the logic is almost always the same: do-while, if-else.. etc. llSay is a lot like cout<< and its never possile to stress enough the importance of readabitlity. if you had a dog object, would you name it 'cat'? |
wizzie Baldwin
Registered User
![]() Join date: 23 May 2004
Posts: 52
|
name for doggie
07-14-2004 19:50
i have a flying dog that loos even worse than Dilberts. I call it the flyingDoggieGadget
hehe =) |