It is currently Sun Nov 17, 2019 3:43 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: DebugStructure() Macro
PostPosted: Thu Oct 24, 2019 7:20 am 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4411
Location: Germany
Since it is easier to find I create an own topic here.

Code:
EnableExplicit

Macro DebugStructure(variable_, structure_)
 
  CompilerIf #PB_Compiler_Debugger
   
    CompilerIf Not Defined(DebugStructure_JSON, #PB_Variable)
      Define DebugStructure_JSON.i
    CompilerEndIf
   
    DebugStructure_JSON = CreateJSON(#PB_Any)
    If DebugStructure_JSON
      InsertJSONStructure(JSONValue(DebugStructure_JSON), @variable_, structure_)
      Debug ComposeJSON(DebugStructure_JSON, #PB_JSON_PrettyPrint)
      FreeJSON(DebugStructure_JSON)
    EndIf
   
  CompilerEndIf
 
EndMacro


Structure test
  a.s
  b.f
  c.i
  d.d
  e.s
  f.i
EndStructure

Define t.test

t\a = "Test"
t\b = 1.1
t\c = 3
t\d = 1.2345678
t\e = "blabla"
t\f = 2

DebugStructure(t, test)


Last edited by infratec on Thu Oct 24, 2019 10:26 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: DebugStructure() Macro
PostPosted: Thu Oct 24, 2019 9:47 am 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4525
Location: Lyon - France
Yes, really good idea :wink:
Thanks for sharing 8)

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: DebugStructure() Macro
PostPosted: Thu Oct 24, 2019 12:15 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3703
Location: Berlin, Germany
Very cool, thanks for sharing!

I've added a link to this topic to my "Small tricks with JSON" thread.

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: DebugStructure() Macro
PostPosted: Thu Oct 24, 2019 4:28 pm 
Offline
Addict
Addict

Joined: Fri Nov 09, 2012 11:04 pm
Posts: 1689
Location: Uttoxeter, UK
@infratec,
Thank you for your clever macro.

@Little John,
Thank you for placing the code in your JSON repository.

_________________
DE AA EB


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye