|
Post by (X) on Dec 19, 2021 23:20:40 GMT 1
I am open to ideas for the following:
Wouldn't it be nice to have a side-bar in treeview format that would display all your variables and data type members in real-time, even keep track of changes with a time-stamped 'history' of past values? Even a graphical plot of values with optional auto scale on the x and y axis...
|
|
|
Post by (X) on Dec 20, 2021 14:38:29 GMT 1
Here is a clue:
Sub Show_All_Global_Vars Dim v As Gfa_Var, GlobVars As Gfa_Vars Set GlobVars = Gfa_Vars("") For Each v In GlobVars Debug "Global Var: " & v.Name, v.Type, v.TypeName Next EndSub
|
|
|
Post by (X) on Dec 20, 2021 16:26:06 GMT 1
A bit more...
'################################################################### ' ' DISCLAIMER: THIS CODE IS OFFERED AS IS. ' IT IS INTENDED FOR EDUCATIONAL PURPOSES. ' ' I ACCEPT NO LIABILITY AND MAKE NO CLAIM ' FOR IT'S CORRECTNESS OR SUITABILITY ' IN PART OR IN WHOLE. ' ' THE USE OF THIS CODE IS AT YOUR OWN RISK. ' '################################################################### ' ' Filename Demo Show GFA_Vars.G32 ' ' Description A demonstration of how to show the variables in your code. ' Ideally this could lead to a practical tool that will ' help troubleshoot if not actively participate in program execution. ' ' Author X-man ' Email xman.gb32@gmail.com ' Web-site https://gb32.proboards.com/ ' Started 2021.12.20 ' Updated <ISO date> ' '
P_Main
Proc P_Main P_Init Show_All_Global_Vars Show_All_Local_Vars Show_All_Proc_Vars Do Sleep Until Me Is Nothing Proc P_Init Mode Date "-" Global a As Int = 1 Local s$ = "local_string" Type T_UDT -String*40 name EndType Dim udt As T_UDT udt.name = "udt name" Show_All_Proc_Vars Sub Show_All_Global_Vars Debug Debug "Global Vars..." Dim v As Gfa_Var, GlobVars As Gfa_Vars Set GlobVars = Gfa_Vars("") For Each v In GlobVars Debug F_Var_Info_Str(v) Next Show_All_Proc_Vars EndSub
Sub Show_All_Local_Vars Debug Debug "Local Vars..." Dim v As Gfa_Var, LocalVars As Gfa_Vars Set LocalVars = Gfa_Vars("-") For Each v In LocalVars Debug F_Var_Info_Str(v) Next EndSub
Sub Show_All_Proc_Vars Debug Debug "Proc Vars..." Dim v As Gfa_Var, ProcVars As Gfa_Vars Dim p$ = F_Proc_Name_From_CallTree(CallTree(2)) ': Trace #34 & p$ & #34 Set ProcVars = Gfa_Vars(p$) Debug "Curr Proc: ";p$ For Each v In ProcVars Debug F_Var_Info_Str(v) Next EndSub
Function F_Var_Info_Str(v As Gfa_Var) As String Try Return "Type Code:" & "0x" & Hex(v.Type, 8) & ", " & v.TypeName & ", " & v.Name & ", " & F_HexDec(v.Value) Catch Return "Type Code:" & "0x" & Hex(v.Type, 8) & ", " & v.TypeName & ", " & v.Name EndCatch Function F_HexDec(v As Variant) As String If IsNumeric(v) Return "0x" & Hex(v, 8) & ":(" & v & ")" Else Return v EndIf Function F_Proc_Name_From_CallTree(p$) As String Return Mid$(p$, 5)
|
|
|
Post by (X) on Dec 21, 2021 11:52:05 GMT 1
The following handles the case when CallTree(2) returns parameters if and when passed.
Function F_Proc_Name_From_CallTree(p$) As String ' ' CallTree(2) returns a string containing the type ' of the calling code such as: Sub, Proc or Function ' followed by the name of specified code grouping ' followed by any parameters passed. ' ' The following returns only the second 'space separated' string ' while ignoring the first and any following. ' Dim hs As Hash String Split hs[] = p$, " " Return hs[% 2]
|
|