ArraySearch question

Started by oradba4u, February 27, 2015, 06:49:19 AM

Previous topic - Next topic

oradba4u

Greetings: I am using Winbatch 2008C, and I am trying to use the ArraySearch function. My code blows up, so I copied one of the example programs from the WIL reference Manual and still got the same error.
3052: Uninitialized variable, undefined function, or unquoted string:
on line 6
result = ArraySearch( arrList, value, 0, 0, 0, ArrInfo(arrList,1)-1)
When I click "More error info", It says:
uninitialized variable or undefined function:
arraysearch

Here is the cut & pasted code:

strList = 'a b c A B C 1 0 -1'
value = 'C' ; (uppercase letter C)
; Create an array to search
arrList = Arrayize( strList, ' ' )
; Search the array
result = ArraySearch( arrList, value, 0, 0, 0, ArrInfo(arrList,1)-1)
; Display results ( expect 5 )
Pause('ArraySearch of value: ':value, 'Element number:':result)

You can imagine my surprise that this code would not work, and then I thought perhaps my version doesn't support ArraySearch. So, I have three questions:
1-) Is ArraySearch supported in my version (2008C) of winbatch?
2-) How can I tell (and where can I look to find this information myself) what my version of WinBatch supports/doesn't support? (I know, tall order)
3-) If it isn't supported, does someone have a binary search algorithm/code that can be adapted to my version of WinBatch?

As always, any/all help would be appreciated

td

Quote from: oradba4u on February 27, 2015, 06:49:19 AM
Greetings: I am using Winbatch 2008C, and I am trying to use the ArraySearch function. My code blows up, so I copied one of the example programs from the WIL reference Manual and still got the same error.
3052: Uninitialized variable, undefined function, or unquoted string:
on line 6
result = ArraySearch( arrList, value, 0, 0, 0, ArrInfo(arrList,1)-1)
When I click "More error info", It says:
uninitialized variable or undefined function:
arraysearch

Here is the cut & pasted code:

strList = 'a b c A B C 1 0 -1'
value = 'C' ; (uppercase letter C)
; Create an array to search
arrList = Arrayize( strList, ' ' )
; Search the array
result = ArraySearch( arrList, value, 0, 0, 0, ArrInfo(arrList,1)-1)
; Display results ( expect 5 )
Pause('ArraySearch of value: ':value, 'Element number:':result)

You can imagine my surprise that this code would not work, and then I thought perhaps my version doesn't support ArraySearch. So, I have three questions:
1-) Is ArraySearch supported in my version (2008C) of winbatch?

No. The function was not added until 2011A.

Quote
2-) How can I tell (and where can I look to find this information myself) what my version of WinBatch supports/doesn't support? (I know, tall order)

Look it up in your help file.  If it isn't documented then you can't use it.

Quote
3-) If it isn't supported, does someone have a binary search algorithm/code that can be adapted to my version of WinBatch?

Look in the Tech Database.  Search on the key word 'array'.  There are examples using ADO, a third party array extender and WIL script implementations.  These version all have their strengths and weaknesses most are much slower or lack the flexibility of the native function.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

Neglected to mention that you can also go to our web site and example the What's new section to view the changes to WinBatch since the release of the version you are using.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade