Any insight would be it appears the problem is with a duplication of a structure(s) as a side-effect of the use of MoveMemory(). In many cases if there are multiple items the same it will remove all of them in one swoop (without being told to do so).Ĭan anyone offer an explanation or point out where the program logic is flawed? I don't need a way to accomplish the task another way (thanks anyway ), I am just trying to narrow down a possible bug. Code updated for 5.20 (better to use ClearStructure(), especially when the structure contains strings, array, list or map which have been allocated internally by PureBasic) Hi, A little piece of code: Code: Select all Structure mystruc field1.s field2.l field3.q field4.f field5. Occasionally ClearStructure() produces odd and soon to be fatal results, especially when items are being removed from the end of the collection. This procedure clears the structure of matching items and then either overwrites them with the remaining items using movememory() or adjusts the count of items if it is the last item being removed. The removing occurs in the procedure removeOnes(). The code repeatedly creates a random collection of items and then removes items from the collection until a fault occurs. RandomSeed(12) for results that are reproducable If i < 1], SizeOf(item) * (*collection\Size - i)) no problems here Procedure removeOnes(*emCollection)ĭebug " Clearing item #" item) has a problem hereĭebug " clear struc " showit(*collection) It mangles the contents of the collection on occasion. This procedure seems to be malfunctioning (notice all the debugs ) ) If i *collection\Size: output$ ", ": EndIf learning examples tutorials learn-to-code purebasic Resources. Output$ Chr(34) *collection\items\enum Chr(34) return a string containing the contents of collection in a comma delimeted list The addition of the Sentry PM solutions offers cloud-based, purpose-built portfolio management technology to create optimum investment workflow efficiency for portfolio managers, investment analysts, risk professionals, and operations teams. fill the first 7 items of collection with either a "1" or "0" EnableExplicit Structure BookList List BookNames() EndStructure Structure SeriesList List Series.BookList() EndStructure Structure Details List Authors. Added to zero based count of items present In many cases if there are multiple items the same it will remove all of them in one swoop (without being told to do so).Ĭan anyone offer an explanation or point out where the program logic is flawed? I don't need a way to accomplish the task another way (thanks anyway ), I am just trying to narrow down a possible bug. ![]() ![]() If i *collection\Size: output$ ", ": EndIf ![]() return a string containing the contents of collection in a comma delimeted list fill the first 7 items of collection with either a "1" or "0"
0 Comments
Leave a Reply. |