Skip to content

Commit

Permalink
update example script
Browse files Browse the repository at this point in the history
- qsv_register_lookup now requires a cache age parameter
- linebreaks
  • Loading branch information
jqnatividad committed Oct 22, 2023
1 parent e2442f3 commit d68e91a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions examples/readme-example/testlookup.luau
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ BEGIN {

-- we use the "dathere:https://" scheme to load "us-states-example.csv" from the
-- https://github.com/dathere/qsv-lookup-tables repository
us_states_lookup_headers_table = qsv_register_lookup("us_states", "dathere:https://us-states-example.csv")
-- the 6000 is the cache TTL in seconds (10 minutes)
us_states_lookup_headers_table = qsv_register_lookup("us_states",
"dathere:https://us-states-example.csv", 6000)

-- note how we use the qsv_log function to log to the qsv log file
-- which you can enable by setting the QSV_LOG_LEVEL environment variable to "debug"
-- e.g. `export QSV_LOG_LEVEL=debug`
qsv_log("debug", "us_states_lookup_headers:", us_states_lookup_headers_table)
qsv_log("info", "us_states lookup table:", us_states)
qsv_log("info", `NY Capital: {us_states["NY"]["Capital"]} can be also {us_states.NY.Capital} or {us_states["NY"].Capital}`)
qsv_log("info",
`NY Capital: {us_states["NY"]["Capital"]} can be also {us_states.NY.Capital} or {us_states["NY"].Capital}`)

-- a simple function to sum a table of numbers
function sum(numbers_table: table): number
Expand All @@ -28,7 +31,6 @@ BEGIN {

}!


----------------------------------------------------------------------------
-- this is the MAIN script loop, which is executed ONCE for each row in order

Expand Down

0 comments on commit d68e91a

Please sign in to comment.