|
1 members (Russ),
10,950
guests, and
1,516
robots. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
S |
M |
T |
W |
T |
F |
S |
|
|
|
1
|
2
|
3
|
4
|
5
|
|
6
|
7
|
8
|
9
|
10
|
11
|
12
|
|
13
|
14
|
15
|
16
|
17
|
18
|
19
|
|
20
|
21
|
22
|
23
|
24
|
25
|
26
|
|
27
|
28
|
29
|
30
|
31
|
|
|
|
|
This is another custom island. This one could be used for ads. This spot is one of the best places for ads on your site to be placed. This can be enabled/disabled on a per forum basis.
|
|
|
|
Joined: Dec 1999
Posts: 30,868
Master Elite Member
|
SArr_Reverse() - Reverse the order of elements in a string arrayThis function is specifically designed to be a METHOD in an object. Objects cannot be passed string arrays because PowerBasic objects are COM objects, and COM objects can't accept string arrays as parameters. The way to work around this is to use Variants. In the following function, a variant is used to receive the incoming string array, and a variant is used to return the string array.
METHOD SArr_Reverse(BYVAL MyArr AS VARIANT) AS VARIANT
'Purpose
' Used to reverse the order of elements in a string array.
'Parameters
' MyArr (Variant String Array) = The array we're working with.
'Return (Variant String Array)
' Returns the specified string array (MyArr) with all elements reversed.
'Note
' This is only designed to work with zero-based arrays.
' If the LBOUND() of the array is not zero, this function will fail.
'Version History
' 1.0 2010.09.11 Tested by Russ Tanner on PB/CC 5.05.
'---
DIM i AS LONG 'Iterator.
DIM a() AS STRING : REDIM a(0) 'Source buffer.
DIM b() AS STRING 'Destination buffer.
'Convert the variant string array into a native string array.
a() = MyArr
'Create a buffer array with enough elements to hold the original array.
REDIM b(UBOUND(a))
'Iterate the original array and transfer elements into the buffer array.
FOR i = 0 TO UBOUND(a)
b(UBOUND(a)-i) = a(i)
NEXT i
'Now, simply return the new array, which has the elements reversed.
METHOD = b()
END METHOD
|
|
|
|
|