โŒšSB Watch 2
๐Ÿšš Free fedex shipping from 97 $
๐ŸŒŽ WORLDWIDE SHIPPING for 25 $

Strings

Introduction

Strings are a sequence of characters enclosed in either single quotes (''), double quotes (""), or backticks (``). Single quotes and double quotes are working the same way, but backticks (string templates) have some special features.

Creating Strings

To create a string, simply enclose a sequence of characters in single or double quotes.ย For example:

				
					let str1 = 'Hello, world!';
let str2 = "MagiScript is awesome!";
				
			

MagiScript also supports template strings, which are enclosed in backticks (``) instead of single or double quotes. Template strings allow multiple lines and also embed expressions inside a string using placeholders. Placeholder expressions are enclosed in ${}For example:

				
					let name = "MagiScript";
let message = `Hello, ${name}!`;
				
			

String Methods

Below are the String Methods:

strLen

strLenย is a built-in function in MagiScript that returns the length of a string. It takes one argument, which is the string to be measured.ย For example:

				
					let myStr = "MagiScript";
let len = strLen(myStr); // len is 10
				
			

strSub

strSubย is a built-in function in MagiScript that extracts a substring from a string. It takes two arguments: the string from which the substring will be extracted, and the starting index (inclusive) and the ending index (exclusive) of the substring. For example:

				
					let myStr = "MagiScript";
let subStr = strSub(myStr, 0, 4); // subStr is "Magi"
				
			

strCharAt

strCharAtย is a built-in function in MagiScript that returns the character at a specified index in a string. It takes two arguments: the string from which the character will be extracted, and the index of the character.ย For example:

				
					let myStr = "MagiScript";
let char = strCharAt(myStr, 2); // char is "g"
				
			

strSplit

strSplit is a built-in function in MagiScript that splits a string into an array of substrings. It takes two arguments: the string to be split, and the separator character or substring. For example:

				
					let myStr = "MagiScript is awesome!";
let words = strSplit(myStr, " "); // words is ["MagiScript", "is", "awesome!"]
				
			

Conclusion

In MagiScript, strings are a fundamental data type that can be created using single or double quotes or backticks for template strings. While MagiScript doesnโ€™t support the length property of strings, and accessing the letter at an index using brackets (str[2]), we have strLen, strSub, strCharAt and strSplit to help manipulate and extract information from strings.

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