Mod Tool: Difference between revisions

693 bytes added ,  22 October 2012
m
no edit summary
mNo edit summary
mNo edit summary
Line 461: Line 461:




  ' '''[1] making an array'''
  ' '''[1] creating and extending an array'''
' make some object, select them and run the code
   
   
dim y
y = selection.count
   
   
  redim x (y - 1)
  ' creating an array
' () sets the number of array items
' () sets the number of array items
' use dim for an integer value
redim nums (3)
' use redim if () contains a variable
  for i = 0 to 3
 
  nums(i) = (i)
  for i = 0 to y - 1
  x(i) = selection(i).fullname
logmessage x(i)
  next
  next
   
   
  logmessage "counted objects: " & y
  logmessage "output all items"
for each n in nums
logmessage n
next
logmessage "first array item holds: " & lbound(nums)
logmessage "last array item holds: " & ubound(nums)
logmessage "-------------------------------------"
' extending an array
' use "preserve" to keep the old content
' find next higher value
plus_one = ubound(nums) + 1
redim preserve nums (plus_one)
nums(plus_one) = 4
for each n in nums
logmessage n
next
logmessage "first array item holds: " & lbound(nums)
logmessage "last array item holds: " & ubound(nums)
' INFO : output all items
' INFO : 0
' INFO : 1
' INFO : 2
' INFO : 3
' INFO : first array item holds: 0
' INFO : last array item holds: 3
' INFO : -------------------------------------
' INFO : 0
' INFO : 1
' INFO : 2
' INFO : 3
' INFO : 4
' INFO : first array item holds: 0
' INFO : last array item holds: 4




8,452

edits