Before I ask, it has been fun as it seems that a few others are on the same path... recent questions have been relevant toward where I am at in my learning PureBasic. Actually, I have a new program well underway, my pre-compiler is already doing its job and things are progressing nicely.
Okay, the question here is what is the best way to "reset" an array and/or structure ?
For arrays, I'm just doing a for i = 1 to arraySize ( myArray ( ) ) and for structures, define a clearData.myStructure and overwriting my data myData = clearData.
Are there any concerns if I have arrays with structures in my structures ? Stuff like record(1)\filelist[1]\filename ?
I'll leave it that. The technique seems to work. Below is a simplified sample of what I've using just in case anyone spots anything I'm doing that is not advisable.
Code: Select all
     structure _playlistrecords
          filename.s
          description.s
          duration.i
     endStructure
     structure _record
          description.s
          playlistrecords.i
          playlist._playlistrecords [ 101 ]
     endStructure
     define s.s, i.i, j.i
     define dim record._record ( 500 )
     record(1)\description = "First record"
     record(1)\playlistrecords = 3
     record(1)\playlist[1]\filename = "First record, First item"
     record(1)\playlist[2]\filename = "First record, Second item"
     record(1)\playlist[3]\filename = "First record, Third item"
     record(2)\description = "Second record"
     record(2)\playlistrecords = 2
     record(2)\playlist[1]\filename = "Second record, First item"
     record(2)\playlist[2]\filename = "Second record, Second item"
     for i = 1 to 2
          s = s + str(i) + ":" + record(i)\description + chr(13) + chr(10)
          for j = 1 to record(i)\playlistrecords
               s = s + "   " + str(i) + "," + str(j) + ":" + record(i)\playlist[j]\filename + chr(13) + chr(10)
          next
          s = s + chr(13) + chr(10)
     next
     s = s + "----- CLEARING -----" + chr(13) + chr(10)
     define clearRecord._record
     for i = 0 to arraySize ( record ( ) )
          record(i) = clearRecord
     next
     for i = 1 to 2
          s = s + str(i) + ":" + record(i)\description + chr(13) + chr(10)
          for j = 1 to record(i)\playlistrecords
               s = s + "   " + str(i) + "," + str(j) + ":" + record(i)\playlist[j]\filename + chr(13) + chr(10)
          next
          s = s + chr(13) + chr(10)
     next
     messageRequester ( "TEST", s )
;    messageBox results captured using ^c
;
;    ---------------------------
;    TEST
;    ---------------------------
;    1:First record
;       1,1:First record, First item
;       1,2:First record, Second item
;       1,3:First record, Third item
;
;    2:Second record
;      2,1:Second record, First item
;      2,2:Second record, Second item
;
;    ----- CLEARING -----
;    1:
;
;    2:
;
;
;    ---------------------------
;    OK
;    ---------------------------

