Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ VBscript
➜ ReDim, UBound & LBound on World [array] Variables.
ReDim, UBound & LBound on World [array] Variables.
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1
2
Posted by
| Poromenos
Greece (1,037 posts) Bio
|
Date
| Reply #15 on Mon 23 Jun 2003 09:50 PM (UTC) |
Message
| OK, let me contribute a bit to this thread... I didn't read all of it, because, I'm too lazy, but I think this'll help :P
I made a script to count EQ damage a while ago. Uses two-dimensional VBScript global variables to store the data and then loads/saves them in MC variables when it's done.
Here is a general example of arrays in VB:
Dim varArray(2)
Dim varDamage()
varArray(1) = "Test"
varArray(2) = "Test 2"
Sub AddItem(strItem)
Redim Preserve varDamage(UBound(varDamage) + 1)
varDamage(UBound(varDamage)) = "Store this"
End Sub
That way, you can initialise and resize a variable at runtime. There are many functions to search, store and load arrays to MC variables in my script, ready to be used.
I'm pasting a few because the script is no longer online:
Sub subSaveArray
Dim intCounter
Dim strContents
Dim intArrayCounter
For intCounter = 0 to UBound(strEQTable, 2)
strContents = strEQTable(0, intCounter)
For intArrayCounter = 1 to constTableItems
strContents = strContents & "|" & strEQTable(intArrayCounter, intCounter)
Next
world.SetVariable "EQHit_Item_" & intCounter, strContents
Next
End Sub
Function fnFindItem (strItemName)
Dim intCounter
For intCounter = 0 to UBound(strEQTable, 2)
If UCase(strEQTable(0, intCounter)) = UCase(strItemName) Then
fnFindItem = intCounter
Exit Function
End IF
Next
fnFindItem = -1
End Function
The function to load the array was a bit huge due to script-specific stuff, but I'm sure you can reverse the save one.
VB is a bit hazy when it comes to arrays. I still don't know to this day what the lower bound of a VB array is. I.e. if i declare varArray(7), is the lower bound 0, or 1? and is the high bound 7, or 6? Confusing... Anyway, I hope I helped. |
Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it! | Top |
|
Posted by
| Shadowfyr
USA (1,790 posts) Bio
|
Date
| Reply #16 on Tue 24 Jun 2003 12:12 AM (UTC) |
Message
| Well, in scripting:
"The lower bound of an array is always zero."
However, in Visual Basic you can change the lbound for all arrays used, though the default in that is 1. This is for reverse compatibility with earlier Basic programs that used 1 as the first index, but allows you to instead use 0 as the first one when you want to. As far as I know, VBScript forces you to use the 0 -> (size - 1) version, like most other languages and you can't change it. | Top |
|
Posted by
| Poromenos
Greece (1,037 posts) Bio
|
Date
| Reply #17 on Tue 24 Jun 2003 11:42 AM (UTC) |
Message
| Maybe you can use "Option Base 1", like in VB? Haven't tried it though... I just assume the base is one, and fix any bounds errors that might come up :P |
Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it! | Top |
|
Posted by
| Shadowfyr
USA (1,790 posts) Bio
|
Date
| Reply #18 on Tue 24 Jun 2003 08:35 PM (UTC) |
Message
| Nope. You can't change the base for the range under VBScript. No such command exists. The only reason, as I said, that VB allows it is to make conversion of older Basic programs to VB easier by allowing you to use the exsiting array structures in such a program. | Top |
|
Posted by
| Norbert
USA (61 posts) Bio
|
Date
| Reply #19 on Thu 26 Jun 2003 10:53 AM (UTC) |
Message
| Well what I was trying to do was to make a alignment bar for my info bar, because my character gets better attacks when he is neutral, and I wanted to use an array instead of a switch since an array would just be one line of code. I know in LPC there is searcha that would search an array for an element, and I've been told that PERL has a similar function, so I'm just going to convert my script to PERL.
Thanks for the help though. |
Norbert
-Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens
It's a dumb question... skip it.
| Top |
|
Posted by
| Poromenos
Greece (1,037 posts) Bio
|
Date
| Reply #20 on Thu 26 Jun 2003 01:43 PM (UTC) |
Message
| I just gave you a function that will search for an item |
Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it! | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
70,644 views.
This is page 2, subject is 2 pages long:
1
2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top