Log In  

Cart #stringhashtable-5 | 2023-05-31 | Code ▽ | Embed ▽ | No License
1

Feature Overview

This is a script that parses String data and converts it into a hash table. (Not compatible with JSON)

  • A single string can initialize many values.
  • Returns at least an empty table.
  • Elements can be added space-separated. (the space character cannot be used as a value.)
  • {} specifies a table.
  • key=val; key{val} specifies the key and value of the table.
  • Newline codes are ignored.
  • Bool values, Nil, and Hexadecimal strings are automatically normalized.
  • The first level can be initialized with global values by using cat() in _env. CAT(_env,HTBL[[VALUES]]) --init with 5tokens
  • Double quotation marks are not used (they tend to be fewer characters than JSON).
  • Not compatible with JSON.
  • HTBL() uses 150 Token.

"k{v1 v2 ...}" is table. serve just Immediately before hashkey.
"k=v;" is key and value.
See code in cart for examples of format usage.

The parser normalizes individual values using TONORM() in the following order of precedence.

  • Number(hexadecimal)
  • String
  • Bool
  • Nil

may want to Use DMP() if check the converted table.

This function is included in the KNUTIL library.

UPDATE history


v0.4

  • Cut token costs (-12 tokens)
  • Tonorm() is now built-in.
  • The second return value of the final result is now nil.(be careful when doing add())
  • Document inserted.

v0.3

  • code update saved token:
    • htbl 7 tokens
    • tonorm 9 tokens

v0.2

  • run newlines without replace()

v0.1 (2020 08 26)

  • Miniaturization of the cord.
  • No replace "\n" in the recursive process.

old ver


Cart #stringhashtable-3 | 2022-07-30 | Code ▽ | Embed ▽ | No License
1

P#71300 2019-12-22 06:44 ( Edited 2023-10-23 23:14)

1

wow.

P#71331 2019-12-23 00:00
1

May I publish some or all of your code, or derivatives, in https://github.com/sparr/pico8lib ?

P#72818 2020-02-06 18:31

@sparr
Yes. Please use it!
It is frequently used in games that I develop.

P#72857 2020-02-07 02:19

I updated with less code.

  • code update saved token:
    • htbl 7 tokens
    • tonorm 9 tokens
P#115002 2022-07-30 10:37

I updated to HTBL() ver 0.4!!

v0.4

  • Cut token costs (-12 tokens)
  • Tonorm() is now built-in. the second return value of the final result is now nil.(be careful when doing add())
  • Document inserted.
P#130357 2023-05-31 10:06

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 08:29:57 | 0.024s | Q:24