Prefilling a List

Just starting out? Need help? Post your questions and find answers here.
User avatar
DeanH
Enthusiast
Enthusiast
Posts: 274
Joined: Wed May 07, 2008 4:57 am
Location: Adelaide, South Australia
Contact:

Re: Prefilling a List

Post by DeanH »

ebs wrote: Thu Dec 28, 2023 4:21 pm This works fine:

Code: Select all

set.s = "[1,2,3,4,5,8,9,11,15,17,19,45,65,78]"

NewList myset()

Procedure MakeList(List mylist(), set.s)
  CreateJSON(0)
  ParseJSON(0, set)
  ExtractJSONList(JSONValue(0), mylist())
  FreeJSON(0)
EndProcedure

MakeList(myset(), set)

ForEach myset()
  Debug myset()
Next
Absolutely correct. I had a "Homer Simpson" moment. I forgot to add the square brackets on either side of the string of numbers in the set string. Duh-oh! The JSON approach is way better than my very old-fashioned approach.

Every programmer has their own style. I chose PureBasic over Power Basic 15 years ago because PureBasic allowed me to code in the style I wanted and did not force me into something else. I did a lot of DOS programming in the 90's using ZBasic, and in the 80's had over 50 published programs on 8-bit systems. Pure Basic allows a variety of approaches as demonstrated by this thread.
Post Reply