Posted by
| Nick Gammon
Australia (22,973 posts) bio
Forum Administrator |
Message
| You really need a table within a table (or an array within an array).
Effectively you have: <array of names>
Now for each name you need <array of IP addresses>
(Or, for each IP address: <array of names>).
One way of going about that would be to use a comma-delimited string for each IP address. Thus the value (per IP address) might be:
Key: 12.345.678.90
Value: Bob,Bobby,Bruce
Now to add to that you first need to get Bob,Bobby,Bruce into another array. If you want to use the Array functions in MUSHclient, you need key/value pairs, but in this case you don't care about the values (the presence of the key is enough).
Thus it would really be:
Key: 12.345.678.90
Value: Bob,,Bobby,,Bruce,
You could import that into an array like this:
names = "Bob,,Bobby,,Bruce," ' original names
' make an array to hold the current names
ArrayCreate "names"
ArrayImport "names", names, ","
' our new name
newname = "Nick"
' add to array
ArraySet "names", newname, ""
' export back out
names = ArrayExport ("names", ",")
' see result
Note (names) ' --> Bob,,Bobby,,Bruce,,Nick,
Now this new list of names would be stored in the other array as the value for IP address 12.345.678.90. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|