Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Some "array" commands and functions...

Post new topic   Reply to topic Forum Index -> Visual DialogScript 5 Units
View previous topic :: View next topic  
Author Message
Admin Team

Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sat Apr 10, 2004 11:48 am    Post subject: Some "array" commands and functions... Reply with quote


I needed a kind of array commands and functions in my scripts when I wrote a little program. That's why I made an (includable) script of it which can be freely used. Only the basic things are in, like creating an array and filling it with items, and a function to get the value of an item. I hope the rem lines explain enough, otherwise please ask... Smile

# ----------------------------------------------------------------------------------- #
#                                                                                     #
#  Commands:                                                                          #
#  - array create,<array/list number>                                                 #
#  - array clear,<array number>                                                       #
#  - array close,<array number>                                                       #
#  - array set,<array number>,<first value>,<second value>,<thirth value>,<etc...>    #
#                                                                                     #
#  Functions:                                                                         #
#  - @array(set,<array number>,<first value>,<second value>,<thirth value>,<etc...>)  #
#                                                                                     #
# ----------------------------------------------------------------------------------- #

#define command,array
#define function,array

# Create the array, just like you do with lists.
array create,1

# You can set array items with "array set". You can separate values by using commas. You can
# also just use another method, like the one below.
array set,1,[Amsterdam][Kalverstraat][162],D. Utchman
array set,1,[London][Buckingham Palace Road][7a],Ms. Q.U. Een
array set,1,[London][Buckingham Palace Road][7b],H. Ouskeeper
array set,1,[London][Buckingham Palace Road][7c],H.I.S. Neighbour

# Retrieve the data from the array.
info "In London, Buckingham Palace Road 7b lives "@array(value,1,[London][Buckingham Palace Road][7b]).

# Clear the array items.
array clear,1

rem All combinations somebody can make with two dices:
array set,1,1,1,two
array set,1,1,2,three
array set,1,1,3,four
array set,1,1,4,five
array set,1,1,5,six
array set,1,1,6,seven
array set,1,2,1,three
array set,1,2,2,four
array set,1,2,3,five
array set,1,2,4,six
array set,1,2,5,seven
array set,1,2,6,eight
array set,1,3,1,four
array set,1,3,2,five
array set,1,3,3,six
array set,1,3,4,seven
array set,1,3,5,eight
array set,1,3,6,nine
array set,1,4,1,five
array set,1,4,2,six
array set,1,4,3,seven
array set,1,4,4,eight
array set,1,4,5,nine
array set,1,4,6,ten
array set,1,5,1,six
array set,1,5,2,seven
array set,1,5,3,eight
array set,1,5,4,nine
array set,1,5,5,ten
array set,1,5,6,eleven
array set,1,6,1,seven
array set,1,6,2,eight
array set,1,6,3,nine
array set,1,6,4,ten
array set,1,6,5,eleven
array set,1,6,6,twelve

# Get the numbers that were trown.
%%Dice1 = @input("What was the number of the first dice? (1-6)")
%%Dice2 = @input("What was the number of the second dice? (1-6)")

# And show the sum of them
info Than you got @array(value,1,%%Dice1,%%Dice2) points!

# Another way to achieve the same:
# array set,1,2,two
# array set,1,3,three
# array set,1,4,four
# array set,1,5,five
# array set,1,6,six
# array set,1,7,seven
# array set,1,8,eight
# array set,1,9,nine
# array set,1,10,ten
# array set,1,11,eleven
# array set,1,12,twelve
# %%Dice1 = @input("What was the number of the first dice? (1-6)")
# %%Dice2 = @input("What was the number of the second dice? (1-6)")
# info You got @array(value,1,@sum(%%Dice1,%%Dice2)) points!

array close,1


if @equal(%1,create)
  list create,%2,sorted
if @equal(%1,close)
  list close,%2
if @equal(%1,clear)
  list clear,%2
if @equal(%1,set)
  %%temp = @trim(%3@chr(0)%4@chr(0)%5@chr(0)%6@chr(0)%7@chr(0)%8@chr(0)%9)
  if @greater(@count(%2),0)
    list seek,%2,0
  if @match(%2,@chr(0)@chr(0)%%temp)
    list put,%2,@chr(0)@chr(0)%%temp
    list add,%2,@chr(0)@chr(0)%%temp
if @equal(%1,value)
  %%temp = @trim(%3@chr(0)%4@chr(0)%5@chr(0)%6@chr(0)%7@chr(0)%8@chr(0)%9)
  if @greater(@count(%2),0)
    list seek,%2,0
  if @match(%2,@chr(0)@chr(0)%%temp)
    %%temp = @trim(@item(%2))
    %%temp2 =
      %%temp2 = @substr(%%temp,1,1)%%temp2
      %%temp = @strdel(%%temp,1,1)
    until @equal(%%temp,)
    if @greater(@pos(@chr(0),%%temp2),0)
      %%temp2 = @trim(@substr(%%temp2,1,@pos(@chr(0),%%temp2)))
      %%temp = @substr(%%temp2,1,1)%%temp
      %%temp2 = @strdel(%%temp2,1,1)
    until @equal(%%temp2,)
    exit %%temp
    rem No matches, return nothing?

[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Forum Index -> Visual DialogScript 5 Units All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group