⌚SB Watch 2
🚚 Free fedex shipping from 97 $
🌎 WORLDWIDE SHIPPING for 25 $
Search
Close this search box.

System

About

MagiScript offers some system related functions, like:

  • exit() – the code will stop running
  • sleep() – Atom turns off
  • rand() – for random number generation

Let’s see how you can use them.

Exit

The exit function stops the execution of the actually running MagiScript mini-app. When no device is connected to Atom, it will turn off after waiting for a connection.

				
					exit();
				
			

Sleep

The sleep function turns off Atom. If the code was not persisted, it also means it forgets the code running.

				
					sleep();
				
			

Rand

The rand function generates a random number. Can be called with 0, 1 or 2 parameters.

				
					let n = rand();        // integer between 0 and 2,147,483,647
let n = rand(52);      // integer between 0 and 52
let n = rand(-10, 10); // integer between -10 and 10
				
			

The minimum number specified or used by default will be included in the set of available number. The maximum number is excluded. So you can use it like this:

				
					sbwatch.setTime(rand(12), rand(60)); // random time
db.query('card', 'new', rand(52));   // random card
				
			

Conclusion

These system related functions will help you to control Atom, or to generate random numbers.

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