Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Storing and retrieving 3-D arrays in/from workbook names

The following two procedures (1) save the elements of a 3-D array in
workbook names, and (2) Load a 3-D array from the workbook names in
which they were stored. They depend on other functions in the freely
downloadable file at http://home.pacbell.net/beban, but have not yet
been uploaded to that file.

Alan Beban

Sub Save3DInNames(inputArray, arrayName)
'This procedure stores the values from
'a 3-D array into workbook names. Visualizing
'the 3-D array as a rectangular solid
'sitting on the xy-plane (analogous to the
'rows and columns plane of a worksheet),
'the contents of the two-D arrays in the xy-plane
'and the planes parallel to it at each level of the
'third dimension are stored in workbook names
'from where they can be retrieved after the procedure
'has ended. E.g., if the array name were "myArray", the
'planes would be stored in myArrayPlaneXY0,
'myArrayPlaneXY1, etc., where the number at the end
'of the name refers to the offset of the respective plane
'from the xy-plane.

Dim i As Long

'Insure that the first input parameter refers to an array
If Not TypeName(inputArray) Like "*()" Then
MsgBox "This procedure requires that the first " & _
"input parameter refer to an array"
Exit Sub
End If

'And insure that is 3-D
If Not ArrayDimensions(inputArray) = 3 Then
MsgBox "The array must be three-dimensional"
Exit Sub
End If

'Store the planes
For i = 0 To UBound(inputArray, 3) - LBound(inputArray, 3)
Names.Add Name:=arrayName & "PlaneXY" & i, _
RefersTo:=TwoD(inputArray, "xy", i)
Next
End Sub

Function Load3DFromNames(Base As Boolean, _
arrayName As String, firstPlane)
'This function loads a 3-D array from where
'it was stored in workbook names. It is called like
'w = Load3DFromNames(0, "myArray", [myArrayPlaneXY0])

Dim iName, x As String, k As Long

'Insure that 3rd input parameter is an array
If Not TypeName(firstPlane) Like "*()" Then
MsgBox "The third input parameter must be an array"
Exit Function
End If

'And that it is 3-D
If Not ArrayDimensions(firstPlane) = 2 Then
MsgBox "The third input parameter must be a 3-D array"
Exit Function
End If

k = 0 '<----Counter for relevant names
For Each iName In Names
If iName.Name Like arrayName & "Plane*" Then k = k + 1
Next

If k = 0 Then
MsgBox "There are no workbook names " & _
"like """ & arrayName & "" & "Plane*"""
Exit Function
End If

'Convert xy-plane to 3D
p1 = ThreeD([firstPlane])

'Add other level parallel xy-planes
For i = 1 To k - 1
AddPlane p1, Evaluate(arrayName & "PlaneXY" & i)
Next

'Insure that loaded 3-D array has the specified base
ConvertBase p1, -Base, -Base, -Base

'Return loaded 3D array
Load3DFromNames = p1
End Function
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Storing and retrieving 3-D arrays in/from workbook names

??

--

Regards,
Nigel




"Alan Beban" wrote in message
...
The following two procedures (1) save the elements of a 3-D array in
workbook names, and (2) Load a 3-D array from the workbook names in which
they were stored. They depend on other functions in the freely
downloadable file at
http://home.pacbell.net/beban, but have not yet been
uploaded to that file.

Alan Beban

Sub Save3DInNames(inputArray, arrayName)
'This procedure stores the values from
'a 3-D array into workbook names. Visualizing
'the 3-D array as a rectangular solid
'sitting on the xy-plane (analogous to the
'rows and columns plane of a worksheet),
'the contents of the two-D arrays in the xy-plane
'and the planes parallel to it at each level of the
'third dimension are stored in workbook names
'from where they can be retrieved after the procedure
'has ended. E.g., if the array name were "myArray", the
'planes would be stored in myArrayPlaneXY0,
'myArrayPlaneXY1, etc., where the number at the end
'of the name refers to the offset of the respective plane
'from the xy-plane.

Dim i As Long

'Insure that the first input parameter refers to an array
If Not TypeName(inputArray) Like "*()" Then
MsgBox "This procedure requires that the first " & _
"input parameter refer to an array"
Exit Sub
End If

'And insure that is 3-D
If Not ArrayDimensions(inputArray) = 3 Then
MsgBox "The array must be three-dimensional"
Exit Sub
End If

'Store the planes
For i = 0 To UBound(inputArray, 3) - LBound(inputArray, 3)
Names.Add Name:=arrayName & "PlaneXY" & i, _
RefersTo:=TwoD(inputArray, "xy", i)
Next
End Sub

Function Load3DFromNames(Base As Boolean, _
arrayName As String, firstPlane)
'This function loads a 3-D array from where
'it was stored in workbook names. It is called like
'w = Load3DFromNames(0, "myArray", [myArrayPlaneXY0])

Dim iName, x As String, k As Long

'Insure that 3rd input parameter is an array
If Not TypeName(firstPlane) Like "*()" Then
MsgBox "The third input parameter must be an array"
Exit Function
End If

'And that it is 3-D
If Not ArrayDimensions(firstPlane) = 2 Then
MsgBox "The third input parameter must be a 3-D array"
Exit Function
End If

k = 0 '<----Counter for relevant names
For Each iName In Names
If iName.Name Like arrayName & "Plane*" Then k = k + 1
Next

If k = 0 Then
MsgBox "There are no workbook names " & _
"like """ & arrayName & "" & "Plane*"""
Exit Function
End If

'Convert xy-plane to 3D
p1 = ThreeD([firstPlane])

'Add other level parallel xy-planes
For i = 1 To k - 1
AddPlane p1, Evaluate(arrayName & "PlaneXY" & i)
Next

'Insure that loaded 3-D array has the specified base
ConvertBase p1, -Base, -Base, -Base

'Return loaded 3D array
Load3DFromNames = p1
End Function


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Storing and retrieving 3-D arrays in/from workbook names

Nigel wrote:
??

I'd be happy to try to respond, but I don't understand the question.

Alan Beban
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Storing TextBox info in cells, then retrieving on next load-up jlroper[_2_] Excel Programming 2 September 2nd 05 06:09 AM
Storing TextBox info in cells, then retrieving on next load-up T-®ex[_48_] Excel Programming 0 August 31st 05 07:51 AM
Storing values to arrays for subsequent use Peter Rooney Excel Programming 3 July 29th 05 09:00 AM
Retrieving the sheet names of another workbook Aidy[_2_] Excel Programming 1 June 25th 04 07:29 PM
Storing and Retrieving Variables Question JasonSelf Excel Programming 2 January 23rd 04 03:12 PM


All times are GMT +1. The time now is 10:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"