⌚SB Watch 2
🚚 Free fedex shipping from 97 $
🌎 WORLDWIDE SHIPPING for 25 $

Debugging Techniques

Figure Out What's Happening?

We will cover some techniques for debugging your MagiScript code and identifying and fixing errors.

Building Code Step by Step

One of the best ways to identify and fix errors in your code is to build it step by step. This means writing small pieces of code, testing them, and then building on them gradually. This approach makes it easier to identify errors and narrow down where they might be occurring.

Understanding MagiScript Functions

It’s important to have a solid understanding of how MagiScript functions work. This includes understanding how to pass arguments to functions, how to use return values, and how to create and use variables.

Using console.log

Another way to figure out what’s happening in your MagiScript code is to use console.log. This function allows you to log any value in your mini-app and see it displayed in the browser. You can call console.log with many parameters, including numbers and strings. Here are some examples:

				
					// Logging a string
console.log("Hello, world!");

// Logging a number
console.log(42);

// Logging multiple values
console.log("The answer is", 42);
				
			

Disable Some Code

Another technique that can be helpful is commenting out parts of your code. Commenting out code involves adding special characters to your code that prevent it from being executed. This can be useful when you want to temporarily disable a part of your code in order to isolate a bug or test a theory about what might be causing an error. To comment out a piece of code in MagiScript, you can simply add two forward slashes (//) before the line or block of code that you want to disable.

				
					console.log('This will run.'); // console.log('It will not run.');
				
			

Conclusion

Debugging your MagiScript code is an important part of the development process. By building your code step by step, understanding MagiScript functions, and using console.log to log values, you can identify and fix errors more easily. Remember to take your time and be patient – debugging can be a challenging but rewarding process.

Β 

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