User Types
Forums
I was recently reviewing the IDEAScript training material for a class I am giving in a few weeks and came across the user type "variable". This is something I don't usually use but probably should. What it does is allow you to group different variable types into one grouping. Also within the grouping the variable types are not limited to the same type, so you can mix them up. I good example would be obtaining information from a database, you create a type that contains the different fields and define the variables so that it matches up with the information in the database. The example below is for a three field database in which the first field is character, the second is a number with no decimals and the third is a number with decimals. The code shows how to set the variables and read them. After you set-up the type you have to Dim it in order to use it. I have also found that you can use the type as an array, so that can also be useful.
So does anyone use types in their scripts? If so I would be interested to hear how you use them.
'First define the type, this type can hold three different variables
Type myDatabase
firstField As String
secondField As Integer
thirdField As Double
End Type
Sub Main
'you have to Dim the user type before you can use it
Dim myFile As myDatabase
myFile.firstField = "First field"
myFile.secondField = 10
myFile.thirdField = 11.34
MsgBox myFile.firstField
MsgBox myFile.secondField
MsgBox myFile.thirdField
End Sub