ListMaker

Post Reply
User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

ListMaker

Post by rbytes »

This is the shell of a program I want to develop much further on SPL. It is based on the Listful program I created in Smart Basic. For now, it shows the potential of multi-selection lists, and can actually be used to make a grocery shopping list.

You build a grocery list by tap-selecting items from the master list, as in the first screenshot. You unselect a selected item by tapping it again. I used the master list items from Listful - all 245 of them! These are contained in the attached file "Groc1Clean.txt" which you need to download and place at the same location as the program. Each item selected in the master list will appear in the grocery list.

While shopping, tap items in the grocery list to select them as you add them to your cart. If you remove an item from the cart, tap it again in the grocery list to unselect it. When your shopping trip is over, you can see what items were not purchased, and perhaps add them to the next list.

Eventually I will add clear, new, add, edit, search, sort, load and save functions. There will also be export and import functions, so that lists can be easily transferred between Windows devices. I will also enhance the visual design of the program.

You are not limited to grocery lists. I currently have lists on Listful for shopping, to-do, camping and many other activities.

Code: Select all

''
ListMaker by rbytes
October 2017
''

#.scrclear(1,1,1)

' load a master list array of grocery items 
  >  t, 1..245
    c[t] = #.readline("Groc1Clean.txt")
  <

temp3 = ""
sz = #.size(c,1)

' draw title
#.fontsize(30)
#.drawtext(555,50,"ListMaker")
#.fontsize(20)

' make listbox 1 for master list
a = #.listbox
a.height = 450
a.width = 300
a.x = 250
a.y = 200
a.source = c
#.drawrect(248,198,552,652)

' make listbox 2 for grocery list
b = #.listbox
b.height = 450
b.width = 300
b.x = 700
b.y = 200
#.drawrect(698,198,1002,652)
#.show(a,b)

' make list labels
#.drawtext(346,160,"Master List")
#.drawtext(750,160,"  Grocery Shopping")

' main program loop
>
  ? a.index > 0
    temp3 = ""
    in = a.index
    a.index = 0
    temp = c[in]
    temp2 = #.mid(temp,1,1)
    
    ' toggle checkmark
    ? temp2 = " "
      c[in] = "✓ " + #.mid(temp,4,#.size(temp))
    !
      c[in] = "  " + #.mid(temp,2,#.size(temp))
    .
    a.source = c
    > t, 1..sz
      ? #.mid(c[t],1,1) = "✓"
        temp3 += "  "+#.mid(c[t],2,50) + #.lf
      .
    <
    d = #.split(temp3,#.lf)
    b.source = d
  .

  ? b.index > 0
    temp4 = ""
    in = b.index
    b.index = 0
    temp = d[in]
    temp2 = #.mid(temp,1,1)
    
    ? temp2 = " "
      d[in] = "✓ " + #.mid(temp,4,#.size(temp))
    !
      ? temp2 != ""
        d[in] = "  " + #.mid(temp,2,#.size(temp))
      .
    .
    b.source = d
  .

  #.relax()
<
Attachments
Groc1Clean.txt
(11.99 KiB) Downloaded 300 times
Screenshot (116).png
Screenshot (116).png (66.61 KiB) Viewed 2740 times
Screenshot (117).png
Screenshot (117).png (68.3 KiB) Viewed 2740 times
The only thing that gets me down is gravity...

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: ListMaker

Post by rbytes »

Mr. K., there seems to be a hesitation when an item in the master list (left side) is selected, before it shows or hides the checkmark and the item appears in or disappears from the grocery list (right side). Is there anything I can do in my code to make that action more efficient?

Thanks.
The only thing that gets me down is gravity...

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: ListMaker

Post by Mr. Kibernetik »

On my notebook your program works fast, I would say immediate.

Post Reply