|
Post by (X) on May 29, 2023 10:49:10 GMT 1
Collections are nice.
How about a collection of collections?
Code Listing:
'################################################################################# ' ' DISCLAIMER: THIS CODE IS OFFERED AS IS FOR EDUCATIONAL PURPOSES. ' YOU ARE FREE TO USE, COPY AND DISTRIBUTE. ' THE USE OF THIS CODE IS AT YOUR OWN RISK. ' I ACCEPT NO LIABILITY NOR MAKE ANY CLAIM OF ' CORRECTNESS OR SUITABILITY IN PART OR IN WHOLE. ' '################################################################################# ' ' FILENAME Demo Collection of Collections.G32 ' ' DESCRIPTION Collections are nice. A Collection of collections? ' Well that's just peachy! ' ' AUTHOR (X) ' EMAIL xman.gb32@gmail.com ' WEBSITE https://gfabasic32.blogspot.com/ ' FORUM https://gb32.proboards.com/ ' STARTED 2023-05-29 ' UPDATED <ISO date> ' ' $ManifestOff $Library "GfaWinX" $Library "UpdateRT" UpdateRuntime Mode Date "-"
Dim c1 As New Collection Dim c2 As New Collection Dim c3 As New Collection
c2.Add "test1", "key_test1" c2.Add "test2", "key_test2" c1.Add c2, "c2"
Set c3 = c1!c2
Trace c1!c2 Trace c3(1) Trace c3(2)
Debug output:
|
|
|
Post by (X) on May 29, 2023 16:08:21 GMT 1
My initial enthousiasm was short lived. Once I found out I cannot get/enumerate the key used to create a collection item. I would have to resort to maintaining a separate key list or else embed the key in the value assigned to the item. For example: "street:Main St", which would require a function to extract the 'key' or 'value' based on the ':' separation character. The 'hash table' might be a better choice.
|
|
|
Post by dragonjim on May 29, 2023 20:25:01 GMT 1
Or you could try an array of Variant Type; that way you can embed an array into any element if you need to store more details on some records.
|
|
|
Post by (X) on May 30, 2023 20:34:48 GMT 1
Or you could try an array of Variant Type; that way you can embed an array into any element if you need to store more details on some records. Would this be hard coded? Or, can we dynamically add and remove from an array of variants?
|
|
|
Post by dragonjim on May 30, 2023 23:33:44 GMT 1
As long as you use the Variants library included with GB32, then Arrays of Variants can be as dynamic as GFA arrays. All the commands and functions are covered by the help file.
I'll try and create a small example tomorrow if I get time.
|
|
|
Post by dragonjim on May 31, 2023 14:20:11 GMT 1
This is a short example of how to start creating an address database and the flexibility of Variants
$Library "C:\Program Files (x86)\GFABASIC32\Include\variants.lg32"
Local n% Local a As Variant : a = Array(10) As Variant // Create an Array inside a Variant Variable VarReDim a, 10 // Redim the array to have 10 elements (0 to 9) Local b As Variant : b = a // Create another array of the same type b(1) = "[Address]" : b(2) = "[Email]" // Create two default values For n% = 0 To 9 // Run through the elements in array a... VarArraySet a, n%, b // ...and set element 1 (the 2nd element)... Next n% // ...to be an 11 element array as well Trace a(1)(2) // Prints "[Email]" VarArraySet a, 1, 2, "gfa@gfa.com" // Change that value to a specific email address Trace a(1)(2) // Print "gfa@gfa.com" Trace a(2)(2) // Still contains the default "[Email]" Local e As Variant e = Array("1st Email", "2nd Email") As Variant // Create another array which can hold two emails VarArraySet a, 3, 2, e // Assign that array to a(3,2) VarArraySet a, 3, 2, 0, "gb32@gfa.com" // Set the two email addresses in element 3 VarArraySet a, 3, 2, 1, "god@gfa.com" VarArraySet a, 5, 2, e // Assign that array to a(5,2) Trace a(3)(2)(0) Trace a(3)(2)(1) Debug VarPrint(a, VARPRINT_ARRAYINFULL) // Draws the whole array in the Debug Window Debug.Show
|
|
|
Post by (X) on May 31, 2023 17:28:49 GMT 1
Cool! Let's say I have 10 elements in a VarArray and I need to remove element 8, to end up with 9 elements in the VarArray.
I imagine a procedure called VarArrayElementRemove(OriginalVarArray, ElementIndexToRemove%)
I imagine being able to copy elements from the original VarArray to a temp VarArray (size 9) and copy the temp over the original?
|
|
|
Post by dragonjim on May 31, 2023 19:19:48 GMT 1
That would be the general principle. I will look into writing an equivalent to Insert and Delete for the library but for now the best method would be (if you want to delete element 5, let's say):
1. Create a new Variant variable and copy the sub array to that. 2. Move the value of elements 6 onwards down one. 3. Redim the sub array using VarReDim. 4. Copy the sub array back into main array.
I would include an example but I am not near a PC at the moment.
|
|
|
Post by dragonjim on Jun 1, 2023 13:16:38 GMT 1
Let's say I have 10 elements in a VarArray and I need to remove element 8, to end up with 9 elements in the VarArray. The following is an updated Variants Library with the new VarDelete command. Variants.lg32 (21.76 KB) (Updated from original one posted which suffered from a bug or two) Copy this into your Include folder of GFABASIC. The format for the command is: VarDelete array, element[, options] The command will only handle a simple array (due to the problem of passing embedded arrays ByRef) so you will need to separate embedded arrays before passing them to this routine. The command works exactly like the Delete command for GFA arrays except when the option VARDELETE_REDUCE is passed, in which case the array is reduced by one after the deletion. The following code can be used to test this new command: $Library "Variants"
Local a = Array(10, Array(2, 5) As Byte, 5, 10) // Create an array with an embedded Byte array Local b = a(1) // Extract the byte array... VarDelete b, 1, VARDELETE_REDUCE // ...delete the element number 1 (the second one)... a(1) = b // ...and reinsert the amended byte array Trace VarPrint(a, VARPRINT_ARRAYINFULL) // Output the new array to the Debug screen Debug.Show
|
|
|
Post by (X) on Jun 1, 2023 13:48:09 GMT 1
That sounds great! I'll check this out asap.
Q: What happens if you don't use the option VARDELETE_REDUCE? A:? If you don't use VARDELETE_REDUCE then, the value is deleted and the dimension stays the same?
Like I say, I will check this out...
By the way, 'when the student is ready..." definitely applies here because when you submitted Variants.LG32 library in 2017, I was clueless.
Thanks for this!
|
|
|
Post by (X) on Jun 1, 2023 15:12:58 GMT 1
Here is my confirmation that without the VARDELETE_REDUCE the element value is emptied/nulled/zeroed and the element remains... '$Library "gfawinx" $Library "UpdateRT" UpdateRuntime ' Patches GfaWin23.Ocx
$Library "Variants"
Local a = Array(10, Array(2, 5) As Single, 5, 10) // Create an array with an embedded Byte array Trace VarPrint(a, VARPRINT_ARRAYINFULL) // Output the new array to the Debug screen
Local b = a(1) // Extract the byte array... VarDelete b, 1, VARDELETE_REDUCE // ...delete the element number 1 (the second one)... a(1) = b // ...and reinsert the amended byte array Trace VarPrint(a, VARPRINT_ARRAYINFULL) // Output the new array to the Debug screen
b = a(1) VarReDim b, 2 VarArraySet b, 1, "3.14" VarDelete b, 1 a(1) = b Trace VarPrint(a, VARPRINT_ARRAYINFULL) // Output the new array to the Debug screen
Debug.Show
Debug Window
|
|
|
Post by (X) on Jun 1, 2023 16:38:29 GMT 1
These seems to work for getting the size of the variant array and for inserting a variant element into a variant array after the specified index. I still need to work out how to insert before the specified index.
Function VarSize(ByRef v As Variant) As Long Dim L% = LBound(v) Dim U% = UBound(v) Return ((U - L) + 1) EndFunc
Proc VarInsert(ByRef v As Variant, i As Long, vi As Variant) Dim LB% = LBound(v) : Trace LB Dim UB% = UBound(v) : Trace UB Trace VarSize(v) Dim v_new = Array(0) VarReDim v_new, VarSize(v) + 1 Trace VarSize(v_new) If (i < LB) i = LB If (i > UB) i = UB Trace i Dim j%, k% For j = LB To LB + i VarArraySet v_new, j, v(j) Trace j Trace v_new(j) Next j Trace j VarArraySet v_new, j, vi Trace v_new(j) If (j <= UB) For k = j + 1 To UB VarArraySet v_new, k, v(k) Trace k Trace v_new(k) Next k EndIf v = v_new Trace VarPrint(v, VARPRINT_ARRAYINFULL) EndProc
|
|
|
Post by dragonjim on Jun 1, 2023 19:28:00 GMT 1
Hi,
I am working on a VarInsert routine. What would you like to see?
At the moment it has the same parameters as yours (array, element, value) plus an options. For the latter I had planned to allow the array to be increased in size rather than losing the last value; another option would be to allow a value to be added after rather than before (default) the element quoted: this would allow greater flexibility as well as allowing for the array to be ReDim-ed and a value added at the end.
Any other thoughts?
Edit: Sorry, forgot to add: nothing wrong with the routine you wrote, it looks good. The only difference between our two routines (barring options) would probably just be speed of execution.
|
|
|
Post by dragonjim on Jun 1, 2023 23:14:35 GMT 1
The new VarInsert is now added; in addition, I have taken the liberty to include your VarSize routine (with appropriate acknowledgement  ) I have included the two options discussed previously: to increase the array by one on insertion; and the option to insert AFTER the stated element number rather than before. The new library is here: Variants.lg32 (21.76 KB) (It includes a bug fix for VarDelete as well) And the text to test it is... $Library "Variants"
Local a = Array(10, Array(2, 5) As Word, 5, 10) Local b, c = Array("Hello", 24), ie As Object Set ie = CreateObject("InternetExplorer.Application")
Trace VarPrint(a, VARPRINT_ARRAYINFULL) // Show the structure of the array
b = a(1) // Move sub array to b... VarDelete b, 0 // ...delete element 0, but keep the array the same length... VarArraySet a, 1, b // ...then replace the sub array into the main array
VarInsert a, 3, c, VARINSERT_INCREASE // Insert sub array c into element 3 of the array and increase the array by one to accomodate
Trace VarPrint(a, VARPRINT_ARRAYINFULL) // Show the structure of the amended array
b = a(3) // Move new sub array to b... VarInsert b, 1, ie, VARINSERT_INCREASE | VARINSERT_INSERTAFTER // ...insert an IE object AFTER element one and increase the sub-array to accomodate... VarDelete b, 1, VARDELETE_REDUCE // ...then remove the value in element one and reduce the size of the sub-array by one... VarArraySet a, 3, b // ...then replace the sub array into the main array
Trace VarPrint(a, VARPRINT_ARRAYINFULL) // Show the structure of the amended array NOTE: There may be an error if this is run on Windows 11 as Internet Explorer is not included in that OS (although I have been told that it opens Edge in IE mode...); if you do have an error, change ie to a TextBox or any other object... Please let me know if you find any bugs.
|
|
|
Post by (X) on Jun 2, 2023 0:41:12 GMT 1
You are making great strides!
I'm sure you are well aware. If we try to insert at index 1: Array(2, 5), We get an Allocation error...
If this project works out, it will definitely become indispensible!
This could lead to the effortless dynamic storage, creation, retrieval, editing, annotation and modification (SCREAM) of a tree of knowledge!
|
|
|
Post by dragonjim on Jun 2, 2023 11:13:01 GMT 1
Well spotted and thanks for testing. All fixed now, with other behind the scene updates to try and catch future errors. I have updated all the other links but here is the newest version of the library: Variants.lg32 (21.76 KB) To test, use this code (very similar to the last): $Library "variants"
Local a = Array(10, Array(2, 5) As Byte, 5, 10) Local b, c = Array("Hello", 24), d, ie As Object Set ie = CreateObject("InternetExplorer.Application")
Trace VarPrint(a, VARPRINT_ARRAYINFULL) // Show the structure of the array
b = a(1) // Move sub array to b... VarDelete b, 0 // ...delete element 0, but keep the array the same length... VarArraySet a, 1, b // ...then replace the sub array into the main array
VarInsert a, 1, c, VARINSERT_INCREASE // Insert sub array c into element 3 of the array and increase the array by one to accomodate
Trace VarPrint(a, VARPRINT_ARRAYINFULL) // Show the structure of the amended array
d = a(1) // Move new sub array to b... VarInsert d, 1, ie, VARINSERT_INCREASE | VARINSERT_INSERTAFTER // ...insert an IE object AFTER element one and increase the sub-array to accomodate... VarDelete d, 1, VARDELETE_REDUCE // ...then remove the value in element one and reduce the size of the sub-array by one... VarArraySet a, 1, d // ...then replace the sub array into the main array
Trace VarPrint(a, VARPRINT_ARRAYINFULL) // Show the structure of the amended array Debug.Show
If you find any other bugs, please let me know.
|
|
|
Post by (X) on Jun 2, 2023 11:44:28 GMT 1
How about creating a set of commands to insert at the beginning or end of the variant array with auto increment?
Var_Prepend(VA, Element) // Add to beginning Var_Append(VA, Element) // Add to end
|
|
|
Post by (X) on Jun 2, 2023 12:56:59 GMT 1
Take this example,
It would be nice if the name of the variant would appear in the debug output.
$Library "variants"
Local VA_NB = Array("Niels Bohr", 1885, "Atomic Model") Local VA_AE = Array("Albert Einstein", 1879, "E=mc²") Local VA_MC = Array("Marie Curie", 1867, "Radioactivity(shared), Radium & Polonium") Local VA_HB = Array("Henri Becquerel", 1896, "Radioactivity") Local VA_hdr = Array("NAME", "DOB", "DISCOVERY" ) Local VA_scientists = Array(VA_hdr, VA_AE, VA_MC, VA_NB, VA_HB) Local VA_new = Array("Werner Heisenberg", "1901", "Uncertainty Principle") VarInsert(VA_scientists, 3, VA_new, VARINSERT_INCREASE)
Trace VarPrint(VA_scientists, VARPRINT_ARRAYINFULL)
|
|
|
Post by dragonjim on Jun 2, 2023 13:32:55 GMT 1
This is certainly possible now.
Var_Prepend is VarInsert va, 1, value, VARINSERT_INCREASE
Var_Append is VarInsert va, lastelement, value, VARINSERT_INCREASE | VARINSERT_INSERTAFTER
It would certainly make the code tidier having two shorter, more accurately descriptive shell commands.
However, did you mean appending more than one value at the beginning or end? This would be slightly more complex...
|
|
|
Post by dragonjim on Jun 2, 2023 13:39:01 GMT 1
Sadly, at the moment I have no way to programmatically obtain the variable names from within a running program; Sjouke has managed to do so through an extension to the Trace command in the IDE for User-Defined Types but this is not available for Variants.
|
|
|
Post by (X) on Jun 2, 2023 16:48:39 GMT 1
So close and yet so far...
CODE: Trace TypeName(VA_disc)
DEBUG OUTPUT: TRACE:(2):TypeName(VA_disc) = Variant()
|
|
|
Post by dragonjim on Jun 2, 2023 16:52:34 GMT 1
The other problem would be that, once the variant sub-array is added to the main array, its name will change from VA_NB() to VA_Scientists(0)(); the main array name will be displayed by the Trace statement.
|
|
|
Post by (X) on Jun 2, 2023 16:59:34 GMT 1
I'm off on a tangent trying to see if we can redirect the information passed to the Debug window. Chatgpt is talking about keyboard hooks. I'm not sure that's the solution.
|
|
|
Post by dragonjim on Jun 2, 2023 18:30:44 GMT 1
So I have a better idea of what you mean, what are you hoping to achieve by diverting the output?
The Debug window handle is available (Debug.hWnd) and, as far as I can tell, the output is displayed in a large, multiline textbox, so it should be possible to not just extract the information, but to actually write more...
But, at the end of the day, all information written to the Debug window - barring the IDE error and LG32 Library information - is passed by the running program, so I would think it would be easier to redirect the output from within the program rather than extract it after it has been sent to the Debug window.
For example: in the Variants Library, the Variant tree is a string which can be output through Trace (as in the example), Print or written to a file...
|
|
|
Post by (X) on Jun 2, 2023 18:39:41 GMT 1
I'm in a "I'll try anything that might work!" mode to try to get the variant array name. Having that name in hand, for example Dim VA_email = Array("a@b.com","c@d.com"), I could print a list of the variant arrays knowing that they are emails by looking at the variant array name. This is absent in the current VAR_Print() output.
|
|
|
Post by (X) on Jun 2, 2023 18:40:38 GMT 1
I am also revising GFA_Vars offerings...
|
|
|
Post by (X) on Jun 2, 2023 23:22:17 GMT 1
A tinkering that might lead to something useful... The idea is that having a Variant_Array type: T_VA might offer up a descriptive name for the variant array.
$Library "variants"
Type T_VA va As Variant -String*40 name EndType
Dim ve1 As T_VA ve1.va = Array("wh@sci.com") ve1.name = "E-mail"
Dim ve2 As T_VA ve2.va = Array("ae@sci.com") ve2.name = "E-mail"
Dim vd1 As T_VA vd1.va = Array("Uncertainty Principle") vd1.name = "Discovery"
Dim vd2 As T_VA vd2.va = Array("General Relativity") vd2.name = "Discovery"
Dim s1 As T_VA s1.va = Array(vd1.va, ve1.va) s1.name = "Werner Heisenberg"
Dim s2 As T_VA s2.va = Array(vd2.va, ve2.va) s2.name = "Albert Einstein"
Dim vs As T_VA vs.va = Array(s1.va, s2.va) vs.name = "Scientists"
Trace VarPrint(vs.va, VARPRINT_ARRAYINFULL)
Debug vs.name, VarPrint(vs.va, VARPRINT_ARRAYINFULL) Debug s1.name, VarPrint(s1.va, VARPRINT_ARRAYINFULL) Debug s2.name, VarPrint(s2.va, VARPRINT_ARRAYINFULL)
Debug Output...
|
|
|
Post by (X) on Jun 2, 2023 23:30:20 GMT 1
Another line of investigation revealed how to get the variant array names to print in the Debug Output window.
'################################################################################# ' ' DISCLAIMER: THIS CODE IS OFFERED AS IS FOR EDUCATIONAL PURPOSES. ' YOU ARE FREE TO USE, COPY AND DISTRIBUTE. ' THE USE OF THIS CODE IS AT YOUR OWN RISK. ' I ACCEPT NO LIABILITY NOR MAKE ANY CLAIM OF ' CORRECTNESS OR SUITABILITY IN PART OR IN WHOLE. ' '################################################################################# ' ' FILENAME GFA_EX_V__GFA_Vars.G32 ' ' DESCRIPTION A GLL (GFA IDE Linked Library) that outputs the program ' variables and UDTs (User Defined Types) to the Debug window. ' ' AUTHOR (X) ' EMAIL xman.gb32@gmail.com ' WEBSITE https://gfabasic32.blogspot.com/ ' FORUM https://gb32.proboards.com/ ' STARTED 2023-06-02 ' UPDATED <ISO date> ' ' Sub Gfa_Ex_V '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' This subroutine will output all the juicy variable information that GFA can ' muster. ' Debug Debug "GFA_Ex_V__GFA_Vars.GLL" Debug "(N.B.: Syntax Check (Shift-F5) Updates the latest entries.)" Gfa_DoCompile // Does a syntax check and compile which automatically takes new edition into account. Global t As Gfa_Type Global vl As Gfa_Var Global vg As Gfa_Var Global C_vl As Gfa_Vars // Collection of vars Global C_vg As Gfa_Vars // Collection of vars ' LOCALS... Set C_vl = Gfa_Vars("-") // Locals ' GLOBALS... Set C_vg = Gfa_Vars("") // Globals P_Show_Types P_Show_Globals P_Show_Locals EndSub
Proc P_Notes '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' GFA_VARS COLLECTION ' ' SYNTAX ' Dim vs As Gfa_Vars ' Set vs = Gfa_Vars(subcol$) ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' DESCRIPTION ' The Gfa_Vars collection object represents all or part of the variables used ' in an application. A Gfa_Vars collection consists of Gfa_Var items. A Gfa_Var ' item contains the properties that allow you to get information about the ' variable like its name, type, location, and value. ' ' The only way to obtain a Gfa_Vars collection object, is by invoking the ' function Gfa_Vars(subcol$) that returns a Gfa_Vars collection as specified ' in the function's parameter value. For instance: ' ' Dim globalvars As Gfa_Vars ' Set globalvars = Gfa_Vars("") // the global variables ' ' ' The parameter designates the sub collection of variables. The parameter is of ' type Variant and can be one of the following values: ' ' PARAMETER RETURNS A GFA_VARS COLLECTION OBJECT WITH ALIAS ' "" All global variables.. Gfa_Globals ' "-" All local and static variables of the main program. ' "Procname" All local and static variables of the specified procedure. The name ' is case sensitive! Gfa_Vars!Procname ' "1" or 1 All local and static variables of the current procedure. Available ' in Gfa_Tron and Gfa_TronBook proc only. Gfa_Vars1 or Gfa_Vars!1 ' "2" or 2 All local and static variables of the caller of the current procedure. ' Available in Gfa_Tron and Gfa_TronBook procedures only. Gfa_Vars2 or Gfa_Vars!2 ' "3" or 2…n All local and static variables of the caller (of the caller …) of ' the caller of the current procedure. Available in Gfa_Tron and Gfa_TronBook ' proc only. Gfa_Vars3, Gfa_Vars4, …, Gfa_Vars9 or Gfa_Vars!n ' ' When the parameter is the empty string "", a dash "-", or an explicit procedure ' name, the collection of variables can be created anywhere in the GLL. However, ' the numbered Gfa_Vars collections are relative to the stack and are available only ' in the Gfa_Tron or Gfa_TronBook procedures. ' ' Note: To obtain variables at a depth level of more than 9, then you must use the ' variant that takes a parameter: Gfa_Vars("12"). ' ' Each instance of a Gfa_Vars collection has the following properties: ' ' PROPERTY DESCRIPTION ' PName The name of the procedure that is specified as the parameter in the Gfa_Vars() ' function. This property most interesting for the stack based collections to obtain ' the name of the procedure that is being executed. ' ' Count The number of items in the collection. ' Item() A Gfa_Var object for the specified variable. ' Proc P_Show_Types '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' DESCRIPTION ' A Gfa_Type item contains the properties that allow you to get information ' about a user-defined type like its name, elements, and their type. ' ' PROPERTY DESCRIPTION ' Count Returns the number of elements of the type. ' Name(n) The name of the element n in the user-defined type. Name(0) ' returns the name of the Type itself. ' Index(e$) Returns the index of element e$. ' Size(n) Returns the memory size of element n in bytes. ' Type(n) A value indicating the type of element n (basInt, basFixedString, etc) ' TypeName(n) A string describing the type of element n (Integer, String) ' Offset(n) Returns the offset from the start of element n in bytes ' BitSize(n) Returns the memory size element n in bits ' BitOffset(n) Returns the offset of element n from the beginning of the type in bits. ' TypeObj(n) Returns a Gfa_Type object for the element when Type(n) > 65535. ' IsArray(n) Returns True when the element is an array. False for a Variant ' containing an array. ' LBound(n) Returns the smallest available subscript for the specified ' dimension of the array ' UBound(n) Returns the largest available subscript for the specified ' dimension of the array ' ArrSize(n) The allocated memory for the array in bytes. ' ' Obtaining type information is important when you develop a custom debugger. ' However, the type information can be obtained at design time as well. The ' following example shows all user defined types currently in use in your ' program. If you perform a syntax check before pressing App + T, the Gfa_Types ' collection provides the type elements as well. ' ' Gfa_Types is a collection containing Gfa_Type items. A Gfa_Type item contains ' information about a user-defined type. ' ' The Gfa_Types collection allows you to enumerate over all types defined in the program. ' ' Dim t As Gfa_Type ' For Each t In Gfa_Types ' Debug t.Name(0) ' Next ' Debug Debug "SHOW TYPES" Try Dim i% For Each t In Gfa_Types Debug "Type's name: ";t.Name(0),"// Element count:";t.Count For i = 1 To t.Count Debug " ";t.Name(i); If t.IsArray(i) Then Trace t.IsArray(i) Debug "(";t.LBound(i);"..";t.UBound(i);")"; EndIf Debug " As ";t.TypeName(i),"// Type#: ";t.Type(i) Next Debug "EndType" Next Catch Trace Err$ EndCatch EndProc
Proc P_Show_Globals Try Debug Debug "SHOW GLOBALS" For Each vg In C_vg Debug "Global Variable_Name: ";vg.Name," as ";vg.TypeName,"Type: "; vg.Type Next Catch Trace Err$ EndCatch EndProc
Proc P_Show_Locals Try Debug Debug "SHOW LOCALS" For Each vl In C_vl Debug "Local Variable_Name: ";vl.Name," as ";vl.TypeName,"Type:"; vl.Type Next Catch Trace Err$ EndCatch EndProc
You'll need to compile this to a GLL file and add it to your GFA IDE GLLs via the Extra->Extension Manager menu section (Ctrl-M)
'Shift-Ctrl-V' will send whatever variables it finds to the Debug Output Window. This might give us enough to work with if we wanted to include the variant array variable names in the VarPrint() procedure.
|
|
|
Post by dragonjim on Jun 2, 2023 23:42:09 GMT 1
The only way is to have two separate mirrored arrays, one holding the element names, the other holding the values. Then you could list the two next to each other.
Another option is to create your own variant style variable which has an additional value field for a name, similar to User Defined Types.
|
|
|
Post by (X) on Jun 4, 2023 18:03:38 GMT 1
Here is yet another option: Use the 0 index to hold the descriptor of the rest of the data elements
$Library "variants" '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Another way of entering the Variant Array information: ' Make the first element (0) the header name or descriptor of the following data. '
Dim card0 = Array("P.I. Card", _ Array("Name", "Robert Oppenheimer"), _ Array("Title", "Director"), _ Array("From:", "Berkley"), _ Array("ID", "K-6"))
Dim name1 = Array("Name", "R.P. Feynman") Dim title1 = Array("Title", "Grp Lead - Theo. Phy. Div.") Dim from1 = Array("From:", "Princeton") Dim id1 = Array("ID", "I-11") Dim card1 = Array("P.I. Card", name1, title1, from1, id1)
Dim v = Array("Manhattan Project Members", card0, card1 ) Trace VarSize(v) Debug v(0) Debug "|-";v(1) (0) Debug "||-";v(1) (1) (0);": ",v(1) (1) (1) Debug "||-";v(1) (2) (0);": ",v(1) (2) (1) Debug "||-";v(1) (3) (0);": ",v(1) (3) (1) Debug "||-";v(1) (4) (0);": ",v(1) (4) (1)
Debug "|-";v(2) (0) Debug "||-";v(2) (1) (0);": ",v(2) (1) (1) Debug "||-";v(2) (2) (0);": ",v(2) (2) (1) Debug "||-";v(2) (3) (0);": ",v(2) (3) (1) Debug "||-";v(2) (4) (0);": ",v(2) (4) (1)
'Debug VarPrint(v, VARPRINT_ARRAYINFULL)
|
|