default.txt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?LassoScript
  2. /* Lasso 8 */
  3. local('query' = 'SELECT * FROM `'+var:'table'+'` WHERE `id` > 10
  4. ORDER BY `Name` LIMIT 30');
  5. Inline: -Username=$DBuser, -Password=$DBpass, -Database=$DBname, -sql=#query;
  6. var("class1.name" = (found_count != 0 ? "subtotal" | "nonefound"),
  7. "total_amount" = found_count || "No results");
  8. records;
  9. output: "<tr>"loop_count"</tr>";
  10. /records;
  11. /Inline;
  12. ?><div class="[$class1.name]">[$total_amount]</div>
  13. <?lasso
  14. /* Lasso 9 */ ?>
  15. [noprocess] causes [delimiters] to be <?=skipped?> until the next [/noprocess]
  16. [
  17. define strings.combine(value::string, ...other)::string => {
  18. local(result = #value->append(#other->asString&trim))
  19. return set(#result, not #other, \givenBlock)
  20. }
  21. /**! descriptive text */
  22. define person => type {
  23. parent entity
  24. data name::string, protected nickname, birthdate :: date
  25. data private ssn = null
  26. private showAge() => frozen { return ..age }
  27. protected fullName() => `"` + .nickname + `"` + .'name'
  28. public ssnListed::boolean => .ssn() ? true | false
  29. }
  30. define person->name=(value) => {
  31. .'name' = #value
  32. return self->'name'
  33. }
  34. define bytes->+(rhs::bytes) => bytes(self)->append(#rhs)&
  35. ] <!-- an HTML comment <?=disables delimiters?> as well -->
  36. [no_square_brackets] disables [square brackets] for the rest of the file
  37. <?=
  38. // query expression
  39. with n in array((:-12, 0xABCD, 3.14159e14), (:NaN, -infinity, .57721))
  40. let swapped = pair(#n->\second, #n->first)
  41. group #swapped by #n->first into t
  42. let key = #t->key
  43. order by #key
  44. select pair(#key, #1)
  45. do {^
  46. #n->upperCase
  47. ^}
  48. ?>