; ; @ANO_SCRIPT_NAME db_store ; @ANO_SCRIPT_VERSION 0.0.1 ; @ANO_SCRIPT_DESCRIPTION Simple database put/get data handler ; ; @ANO_FLAGS_USE_PROTOS [ ] ; @ANO_FLAGS_VAR_NAME_SUBS [ ] ; @ANO_FLAGS_VAR_WARN_UNUSED [ ] ; ; Copyright (c) 2016-2026, Jani Salonen ; All rights reserved. ; main [exit: 0] { ; You may want to delete .detroit-engine.db file from your home ; directory after running this example. ; ; This is static storage for database data. ; mov storage ("This is enough room for data returned from database.") ; Tie pointer to storage variable which type is string, this is ; traditional way to tie variables... ; ;mov my_ptr (*0) ; ;tie (\ ; through: "my_ptr", ; to: "storage") ; ; ...and this is preferred, simpler approach to use asterisk in front ; of destination variable: ; my_ptr *(storage) ; Open unencrypted database. ; _hnd = store_open(\ scope: STORE_SCOPE_LOCAL, \ db_type: STORE_TYPE_BTREE, \ file_mode: 0, \ password: NULL) ; Save string to database... ; _hnd.put(\ key: "my_db_key", \ data: "ABCDE", \ data_size: 5) ; ...and get it back, it is saved to storage variable. ; _hnd.get(\ key: "my_db_key", \ data: my_ptr, \ data_size: 5) ; Close database and print what was fetched. ; _hnd.done() print "Data is: " . my_ptr . "\n" }