๐ŸŽ TENYO 2026 BUNDLE
๐Ÿ›๏ธ BLACK WEEK DEALS
๐Ÿšš Shipping from 12 USD

System

About

MagiScript offers some system related functions, like:

  • atom.exit() – the code will stop running
  • atom.sleep() – Atom turns off
  • atom.rand() – for random number generation
  • atom.launch() – to launch an other app

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.

				
					atom.exit();
				
			

Sleep

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

				
					atom.sleep();
				
			

Rand

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

				
					let n = atom.rand();        // integer between 0 and 2,147,483,647
let n = atom.rand(52);      // integer between 0 and 52
let n = atom.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(atom.rand(12), atom.rand(60)); // random time
db.query('card', 'new', atom.rand(52));   // random card
				
			

Launch

The launch function launches an other mini-app. The following code will launch the built-in Atom Pi mini-app.

				
					atom.launch('atom_pi');
				
			

Conclusion

These system related functions will help you to control Atom, or access system functions like generating random numbers.

Devices & MagiScript

โš›๏ธ Atom Remote

๐Ÿ”ข Quantum Calculator

๐Ÿคนโ€โ™‚๏ธ MagiScript Language

๐Ÿคนโ€โ™‚๏ธ MagiScript Examples

๐Ÿคนโ€โ™‚๏ธ MagiScript Tutorials

General

๐Ÿ“ƒ First Steps

MagiScript Editor

๐Ÿ“ƒ Basics

๐Ÿ“ƒ Keyboard Shortcuts

๐Ÿ“ƒ Running Your First Program

๐Ÿ“ƒ App Store

๐Ÿ“ƒ Atom Settings (Editor)

๐Ÿ“ƒ Debugging Techniques

Input/Output

๐Ÿ“ƒ Buttons

๐Ÿ“ƒ Vibration Motor

๐Ÿ“ƒ RGB LED

๐Ÿ“ƒ Devices

๐Ÿ“ƒ PeekSmith

๐Ÿ“ƒ Quantum

๐Ÿ“ƒ Teleport

๐Ÿ“ƒ Spotted Dice

๐Ÿ“ƒ SB Watch

๐Ÿ“ƒ IARVEL Watch

๐Ÿ“ƒ Fossil Watch

๐Ÿ“ƒ Cosmos Printer

๐Ÿ“ƒ PeriPage Printer

๐Ÿ“ƒ ATC Remote

๐Ÿ“ƒ Labco Scrabble

๐Ÿ“ƒ 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