โŒšSB Watch 2
๐Ÿšš Free fedex shipping from 97 $
๐ŸŒŽ WORLDWIDE SHIPPING for 25 $
Search
Close this search box.

Database

Introduction

It will be possible to upload data to Atom and query it with a MagiScript command.

Available data sources:

  • card: card stack-related queries, several popular stacks are supported

Querying the "pi" Database

To query the “pi” database, use the db.query() function with the first argument set to “pi”. The second argument should be a 4-digit number you want to search for in the database. For example, db.query(‘pi’, 4000) searches for the number 4000 in the “pi” database.

The db.query() function will return an object with keys page, line, and across. These keys represent the page number, line number, and column number where the 4-digit number can be found in the book.

Here’s an example code snippet that demonstrates how to query the “pi” database:

				
					let data = db.query('pi', '4000');
console.log(data.page); // outputs the page
console.log(data.line); // outputs the line
console.log(data.across); // outputs the column
				
			

In this example, the db.query() function searches for the number 4000 in the “pi” database. The result is stored in the data variable, and then the console.log() function is used to output the result to the console.

Card Database (since firmware v1.1.31)

With the card database, you can work with card positions in popular stacks like:

  • “simple”: a simple card deck order, clubs, diamonds, hearts, and spades from Ace to King:
    AC->KC, AD->KD, AH->KH, AS->KS
  • “new”: a new deck order:
    AH->KH, AC->KC, KD->AD, KS->AS
  • “sistebbins”: Si Stebbins stack
  • “mnemonica”: Mnemonica by Juan Tamariz
  • “aronson”: Aronson stack by Simon Aronson
  • “memorandum”: Memorandum by Woody Aragรณn

You can query the card at position #n (please note, that the first card is n = 0):

				
					let card = db.query('card', 'mnemonica', 0); // first card in new deck order
console.log(card.pos);   // 0 - pos in this ("mnemonica") stack
console.log(card.code);  // 3 - pos in "simple" stack
console.log(card.name);  // 4C
console.log(card.value); // 3 - Four
console.log(card.color); // 0 - Clubs
				
			

The name property (‘4C’ in this case) can be sent to PeekSmith and it will recognize it as a poker card when Smart Text is ON. The code is the position of the card in the “simple” stack (color * 13 + value).

You can also search for the card in the stacks by name, and receive the index (pos):

				
					let card = db.query('card', 'new', '10H'); // first card in new deck order
console.log(card.pos);   // 9 - 10th card in stack
console.log(card.code);  // 35 - pos in "simple" stack
console.log(card.name);  // 10H
console.log(card.value); // 9 - Ten
console.log(card.color); // 2 - Hearths
				
			

And finally, it is also an option to search for the card by providing the color and value:

				
					let card = db.query('card', 'sistebbings', 2, 11); // first card in new deck order
console.log(card.pos);   // 11 - 10th card in stack
console.log(card.code);  // 37 - pos in "simple" stack
console.log(card.name);  // QH
console.log(card.value); // 11 - Queen
console.log(card.color); // 2 - Hearths
				
			

Conclusion

In MagiScript, it is possible to query information from a local “database” using the db.query() function.

The “pi” database is a predefined data source that can be queried using MagiScript. By passing a 4-digit number to the db.query() function, you can find the page, line, and column where the number can be found in the Pi book.

The “card” database is to help you work with card stacks, which can be useful for ACAAN routines.

General

๐Ÿ“ƒย First Steps

MagiScript Editor

๐Ÿ“ƒย Basics

๐Ÿ“ƒย Running Your First Program

๐Ÿ“ƒย App Store

๐Ÿ“ƒย Atom Settings (Editor)

๐Ÿ“ƒย Debugging Techniques

Examples

๐Ÿ“ƒย Atom Time

๐ŸŽž๏ธ Time Practice

๐Ÿ“ƒย Atom Pi (Pi Revelations)

๐Ÿ“ƒย Atom Drum

๐ŸŽž๏ธ Atom Stack

๐Ÿ“ƒย Atom Square

๐Ÿ“ƒย Atom Level

๐Ÿ“ƒย Atom THMPR

๐Ÿ“ƒย Poker Hands

๐Ÿ“ƒย Keyboard Numeric

๐Ÿ“ƒย Keyboard NOKIA

๐Ÿ“ƒย Keyboard Cursor

๐Ÿ“ƒย Keyboard Media

๐Ÿ“ƒย Keyboard Custom

Input/Output

๐Ÿ“ƒย Buttons

๐Ÿ“ƒย Vibration Motor

๐Ÿ“ƒย RGB LED

๐Ÿ“ƒย Devices

๐Ÿ“ƒย PeekSmith

๐Ÿ“ƒย SB Watch

๐Ÿ“ƒย Bluetooth Keyboard

๐Ÿ“ƒย Bluetooth Mouse

๐Ÿ“ƒย Timers

๐Ÿ“ƒย Database

๐Ÿ“ƒย Events

๐Ÿ“ƒย System (exit, sleep, rand)

๐Ÿ“ƒย Objects (card, time)

Language

๐Ÿ“ƒย Summary

๐Ÿ“ƒย Comments

๐Ÿ“ƒย Variable Declarations

๐Ÿ“ƒย Operators

๐Ÿ“ƒย Control Flow

๐Ÿ“ƒย Functions

๐Ÿ“ƒย Numbers

๐Ÿ“ƒย Strings

๐Ÿ“ƒย Arrays

๐Ÿ“ƒย Objects

๐Ÿ“ƒย Uint8Array