​Nope, this one is:
     SELECT   Tea
     FROM     teaInStock
     ORDER BY "Last Used" DESC
     LIMIT    5
     ;
​


then $teaChoices contains three elements for each row returned by the
query. The first of each set of three is the "tea", the second the "last
used" value and the third the "location". So:

   set teaChoices [db eval $getTeasToDrinkStr]
   for {t last_used loc} $teaChoices {
     puts $t
   }

will print the list of teas.

​This gives:
wrong # args: should be "for start test next command"
     while executing
"for {t last_used loc} $teaChoices {
     puts $t
}

Sorry - [for] should be [foreach].

So with your query as above, you want:

  set teaChoices [db eval $getTeasToDrinkStr]
  foreach t $teaChoices {
    puts $t
  }

There is something going wrong, because:
     puts [llength teaChoices]
gives:
     1
while it should give:
     5​

Missing $ sign. Should be:

  puts [llength $teaChoices]

Without the $, it's returning the length of the literal "teaChoices" - one element. Not the length of the list contained in the variable named "teaChoices".

Dan.


_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to