Rhinoscript:primitive data types
From ksteinfeWiki
The term “data types” refers to the kinds of variables which may exist in the rhinoscript world.
Contents |
boolean
Datatype for the Boolean values true and false. It is common to use boolean values with control statements to determine the flow of a program.
blnSuccess = true;
blnFinished = false;
integer
Datatype for integers, numbers without a decimal point. Integers can be as large as 2,147,483,647 and as low as -2,147,483,648. They are stored as 32 bits of information.
intAmount = -3;
intNumberOfPeaks = 500;
double
Datatype for numbers that have a decimal point. Doubles are often used to approximate analog and continuous values because they have greater resolution than integers. They can be as large as 1.8E+308 and as low as -5.0E324. They are stored as 32 bits of information.
dblPercentage = 0.1;
dblPie = 3.14159;
string
A string is a sequence of characters. The class String includes methods for examining individual characters, comparing strings, searching strings, extracting parts of strings, and for converting an entire string uppercase and lowercase. Strings are always defined inside double quotes ("Abc").
strGoodAtHockey = "CCCP"
Rhino.Print(strGoodAtHockey) ‘’Prints "CCCP" to the command line
Because strings are, technically speaking, a composite data type (meaning that they are actually a collection of a more basic data type, chars), dealing with them is a bit more tricky.
a = "Apfelstrudel" >> Apfelstrudel
a = "Apfel" & "strudel" >> Apfelstrudel
a = "4" & " " & "Apfelstrudel" >> 4 Apfelstrudel
a = "The square root of 2.0 = " & Sqr(2.0) >> The square root of 2.0 = 1.4142135623731
null
Visual Basic contains a special data type which does, well, nothing. This may seem like a useless waste of a data type, but in fact is quite a useful feature. You can assign variables to be null, and also certain functions will return the null type when they fail. This makes testing for the null type a useful way of error checking your code.
Also, take note of the handy in-built function isNull(). We’ll be talking more about functions later, but for now look at the following example, and see if you can work out what’s happening:
curve = Rhino.AddLine(Array(0,0,0), Array(somenumber,0,0))
If IsNull(curve) Then
Rhino.Print "Something went terribly wrong!"
End If
