Learn xTalk

Lessons Beyond

xTalk is the language HyperCard taught a generation to program in: scripts that read almost like English, in stacks of cards you can see and click. These lessons take you from your first line to libraries, the internet and extensions of your own, one short page at a time. Every example runs, and shows you what it puts.

  • 83 lessons
  • 634 examples
  • 5 levels, from the first line to extensions

Running the examples Each one is a few lines you can change

  1. Open the xTalk Academy in OXT-Beyond: Help > xTalk Academy, in the desktop IDE or the Web IDE. Its playground, on the right, runs xTalk as you type it.
  2. Copy an example with its Copy button and paste it into the playground, over what is there.
  3. Press Run. Each put shows its value on a line of the Output, just as the lesson shows it. Then change the example and run it again.

An example marked Script is a set of handlers for a button's or a stack's script (open its script with the Script Editor, paste and Apply), and one marked xTalk Builder is an extension's source, for Tools > Extension Builder. Every example on these pages is run by the OXT-Beyond engine, with the Academy's own runner, each time the lessons change, and its Output is checked against what the page shows.

Level 1

Beginner First steps

Values, variables, decisions, loops, text and your own handlers: everything a first program needs.

1Welcome to xTalkWhat xTalk is, where scripts live, and how to run your very first line.6 min · 5 examples 2Text and numbersThe two kinds of value you use most, how to write them, and how to leave notes in your code.7 min · 7 examples 3Joining textBuild sentences out of pieces with & and &&, and use xTalk's names for spaces, tabs and new lines.7 min · 5 examples 4VariablesGive values names, keep them, change them, and choose names that make code easy to read.8 min · 7 examples 5ArithmeticSums with + - * / and ^, whole-number division with div and mod, and the commands that change a number in place.8 min · 7 examples 6Math functionsRounding, the biggest and smallest of a list, averages, square roots, trigonometry and random numbers.8 min · 6 examples 7Everything is textWhy "5" + 3 is 8 in xTalk, how to ask what kind of value you have, and what true, false and empty are.7 min · 5 examples 8Making decisionsLet a program choose what to do with if, then, else and else if.8 min · 6 examples 9Comparisons and logicEvery way to compare values in xTalk, from = and < to contains and is among, and how to combine conditions with and, or and not.9 min · 7 examples 10Many choices with switchPick one of many paths with switch, case, break and default, and when to prefer it to a chain of ifs.7 min · 5 examples 11Counting loopsDo something a number of times, count up or down, and add things up as you go.8 min · 7 examples 12Loops that decideLoop while something is true, until something happens, or forever, and leave a loop or skip a turn with exit and next.8 min · 6 examples 13Repeat for eachWalk through every character, word, item or line of a value, the fastest and clearest loop in xTalk.8 min · 5 examples 14Chunks: chars, words, items and linesxTalk's superpower for text: pick out any character, word, item or line by its number, count them, and use the same words on fields and files.10 min · 7 examples 15Changing textPut new text into a chunk, add before and after it, delete it, replace every copy of something, and change case.8 min · 6 examples 16Searching textFind where something is with offset, wordOffset, itemOffset and lineOffset, and count how often it appears.7 min · 4 examples 17Your own commandsGive a job a name with a command handler, hand it values with parameters, and get an answer back from it.9 min · 9 examples 18Your own functionsWrite handlers that work out a value and hand it back, so that you can use them in any expression, just like round or max.9 min · 10 examples 19Where variables liveWhich handlers can see a variable: locals that last one call, script locals a whole script shares, globals, and constants that never change.9 min · 9 examples
Level 2

Intermediate Stacks, objects and data

Cards, buttons and fields, the events they send and the message path, lists, arrays and dates.

20Stacks, cards and controlsThe objects a program is made of: drawing controls with the Tools palette, naming them in the Property Inspector, asking about them in the Message Box, and making them from a script.14 min · 9 examples 21PropertiesRead and change what an object looks like and how it behaves, in the Property Inspector and from xTalk: its size and place, its colours and text, whether it shows.12 min · 10 examples 22Referring to objectsAll the ways to point at an object in a script: by name, number and id, by long id in a variable, and with me, the target and the owner.11 min · 9 examples 23Messages and eventsHow a click, a key or a new card becomes a message, how a handler answers it, and how your scripts can send messages of their own.13 min · 13 examples 24The message pathWhere a message goes when its object does not handle it, how pass sends it further, and how to use the path to share code.11 min · 13 examples 25FieldsPut text into fields and take it out, style any chunk of it, and use the palette's Label Field, Scrolling Field and Scrolling List Field for labels, long text and lists to choose from.13 min · 11 examples 26Buttons and menusThe many kinds of button in the Tools palette: push buttons, check boxes and radio buttons, and the menus a button can be, from option menus to tabs.12 min · 12 examples 27Graphics and imagesDraw shapes, lines and polygons from the palette's Shapes, change them from xTalk, fill them with colours and gradients, and paint an image pixel by pixel.13 min · 7 examples 28Cards and going between themMake cards, move between them, share a background of controls across cards, and keep each card's own text.13 min · 10 examples 29Talking to the userTell the user something with answer, ask a question with ask, offer choices, and let them pick a file or a folder.8 min · 7 examples 30Sorting listsPut lines and items in order: alphabetically, by number or date, backwards, and by any part of each line you choose.9 min · 8 examples 31Filtering listsKeep only the lines or items that match a pattern, or throw them away, with wildcards or regular expressions, and remove duplicates.8 min · 7 examples 32ArraysKeep many named values in one variable, look them up by key, count with them, and build records and tables out of them.10 min · 10 examples 33Split, combine and friendsTurn text into arrays and back with split and combine, merge arrays with union and intersect, and do sums over a whole array.9 min · 10 examples 34Custom propertiesGive any object properties of your own, which it keeps when the stack is saved, and group them in sets and arrays.10 min · 6 examples 35Dates and timesRead the clock, show a date the way you want, work out what day a date was, and count the days between two dates.10 min · 9 examples
Level 3

Advanced Bigger programs

Errors and debugging, patterns and Unicode, files, timers, behaviors, libraries and algorithms.

36Handling errorsCatch errors with try and catch so a program can recover, raise your own with throw, and know which commands report problems in the result instead.10 min · 8 examples 37DebuggingFind out why a script does what it does: read the error, trace values with put, step through with the debugger, and test handlers in small pieces.10 min · 8 examples 38Regular expressionsDescribe patterns of text, then find them, pull out their parts and replace them, with matchText, matchChunk, replaceText and filter.11 min · 8 examples 39Formatting text and numbersShow numbers with the decimals you want, pad and line up columns with format, round correctly, and fill templates with merge.9 min · 8 examples 40Unicode and text encodingsText in every language and emoji: characters, codepoints and bytes, converting text to and from UTF-8, and comparing accented text safely.10 min · 7 examples 41Reading and writing filesRead a whole file into a variable and write one back in a line, find the folders a program may use, and list, rename and delete files.10 min · 7 examples 42Files a piece at a timeOpen a file and read or write it a line or a block at a time, for files too big to read whole, and for logs you add to as you go.9 min · 6 examples 43Timers and waitingMake something happen later, or again and again, without freezing the program: wait, send in, the pendingMessages and cancel.9 min · 8 examples 44Animation and gamesMove controls smoothly with move, animate frame by frame with a timer, answer the arrow keys, find collisions, and put it together in a small game.12 min · 7 examples 45BehaviorsWrite a script once and give it to many objects: behaviors, me inside them, their own script locals, pass, before and after, chains, and script-only stacks.11 min · 6 examples 46LibrariesShare handlers across a whole program with library stacks, keep helpers private, and use front and back scripts to see or catch every message.10 min · 6 examples 47Properties with handlersMake properties that work something out when read, check or react when set, and serve many objects from one place: getprop and setprop.9 min · 8 examples 48RecursionHandlers that call themselves: the base case, working through folders and nested arrays, remembering answers, and drawing a tree.10 min · 8 examples 49AlgorithmsClassic recipes in xTalk: Euclid's greatest common divisor, the sieve of primes, linear and binary search, stacks and queues, and the shortest way through a maze.14 min · 6 examples
Level 4

Expert Beyond

Code that runs code, binary data, JSON, the internet and databases, speed, and extensions of your own.

50Code that runs codeBuild xTalk as text and run it: do, value, calling handlers by a name worked out at run time, merge with code in it, and when not to.10 min · 8 examples 51More from your handlersHandlers that take any number of values, change the caller's variables, give back several values at once, and report failure cleanly with return for error.10 min · 8 examples 52Binary dataWork with bytes, not text: read and write bytes, see them in hexadecimal, pack and unpack numbers with binaryEncode and binaryDecode, read a file's header, base64, compression and bits.11 min · 8 examples 53Hashes, randomness and encryptionFingerprint data with SHA-256, sign messages with HMAC, store passwords safely with Argon2, make secure random keys and IDs, and encrypt with libsodium and AES.12 min · 7 examples 54JSONRead and write JSON, the text format of almost every web service: JSONImport into arrays, JSONExport back out, numbers and lists, errors, and settings files.10 min · 6 examples 55Tables and CSVKeep tables as tab-separated text, read and write CSV correctly (quotes, commas and line breaks inside values), and show a table in a field with columns and grid lines.11 min · 5 examples 56The web and the internetFetch pages and data with URL, send forms and JSON with post, set headers, load in the background, download files, and run a small web server of your own.12 min · 8 examples 57SocketsConnect two programs directly over the network: a server that accepts connections, a client that opens one, reading and writing with messages, errors, and a small protocol of your own.12 min · 5 examples 58DatabasesKeep many records in SQLite: open a database, create tables, insert safely with placeholders, query into text or walk a cursor, transactions, errors, and other database servers.12 min · 8 examples 59Making code fastMeasure before you change anything, then the handful of habits that make xTalk fast: repeat for each, arrays for lookups, the built-in commands, variables instead of fields, and lock screen.10 min · 8 examples 60Extensions in xTalk BuilderWrite your own library and widget in xTalk Builder, the typed, compiled language of extensions: modules, types, lists, a widget that draws itself, and calling C code directly.14 min · 8 examples 61Shipping your programTurn a stack into a program other people run: the Standalone Application Settings, inclusions, files that travel with it, where it keeps the user's data, catching errors out in the world, script-only stacks for version control, and programs for the command line.13 min · 9 examples
Level 5

Extensions Built in

The libraries, widgets and xTalk Suite that come with OXT-Beyond: cryptography, peer-to-peer networking, physics, QR codes, charts and more.

62Using extensionsWhat the libraries, widgets and xTalk Suite that come with OXT-Beyond are, where to find them, how to call a library, and how to put a widget on a card from the Tools palette or a script.10 min · 8 examples 63Cryptography with SodiumXTKeep data secret and prove it genuine with SodiumXT, the xTalk Suite's layer over libsodium: secure random bytes, fingerprints and seals, locked boxes, public-key boxes, signatures, key exchange, files and streams.16 min · 13 examples 64Keys and coins with CoinXTHow Bitcoin and Ethereum keep coins safe, with CoinXT: hashes, private and public keys, addresses and their checksums, recovery words and wallets that grow from them, signatures, and transactions.15 min · 10 examples 65Nostr with NostrXTPost to Nostr, the open social network with no accounts, with NostrXT: key pairs and npub names, events and their ids, signatures, JSON on the wire, tags and replies, profiles, links, private messages and the filters relays answer.14 min · 8 examples 66Fast messages with ENetSend messages between programs the way games do, with ENet: a server and a client, events you poll for, text and bytes, reliable and unreliable channels, the health of a connection, and a polite goodbye.13 min · 6 examples 67Peer to peer with dataChannelXTLet two programs talk directly, with no server carrying their messages, through WebRTC data channels: peers, the offer and answer they swap, channels that open, text and bytes, events, and closing down.13 min · 7 examples 68Sharing files with TorrentXTShare files among many computers at once with BitTorrent, through TorrentXT: the one session, its settings, making a torrent, seeding, magnet links, the events a session reports, the files in a torrent, and stopping.13 min · 8 examples 69Tor with OnionXTReach and run onion services through Tor with OnionXT: what an onion address is, checking one, the public key inside it, an address of your own from a seed, dialling, and the services others dial.10 min · 6 examples 70Physics with Box2DxtMake things fall, bounce, swing and collide with Box2Dxt, the xTalk Suite's layer over the Box2D physics engine: worlds and steps, bodies and their types, shapes and materials, pushes, joints, contacts and rays, and drawing a world on a card.15 min · 8 examples 71Games with the Box2Dxt KitGive the controls of a card real physics with the Box2Dxt Kit, in pixels and degrees: a world in a few lines, shapes that fall, your own graphics and buttons as bodies, pushes and kicks, hinges, and the messages that say when things touch.13 min · 7 examples 72Text toolsThree libraries for everyday text work: Diff to see what changed between two versions and apply the change, GetOpt to read a command line's options, and MIME for file types, email encodings and whole emails.10 min · 9 examples 73QR codes and drawingsMake QR codes a phone can scan with the QR library, in any colour or as a PNG file, and show SVG drawings sharp at any size with the Drawing library, read their shapes back, and turn them into graphics.12 min · 8 examples 74Time zonesThe time anywhere in the world with the Time Zone library: the zones it knows, their offsets from UTC, summer time, a zone's clock for any moment, and a meeting time from one city to another.10 min · 7 examples 75A web server of your ownServe web pages, files and a JSON API from your own program with the HTTP server library: routes for each address, the right status and type, a folder of files served safely, and data sent in.12 min · 6 examples 76Signing in to web servicesLet people sign your program in to a web service with OAuth2, send the access token it gives with each request, refresh it when it runs out, use Dropbox, and check that a message a service sends you is really from it.12 min · 6 examples 77More librariesThe smaller libraries: HyperXTalk's iff and quoted-printable functions, a stack in a phone's browser with the Mobile Web library, a lasting reference to an object, and the libraries made for Android and the Mac.10 min · 8 examples 78Switches, choices and coloursThe widgets for choosing: the Segmented Control for one of a few options, the Switch Button for on or off, the Color Swatch, the Gradient Ramp Editor for a gradient's colours, and the Spinner that says "please wait".12 min · 10 examples 79Header bars, tabs and tilesThe widgets that lay out an app the way phones do: a Header Bar with a title and actions, a Navigation Bar of tabs along the bottom, Tiles to choose from, and the Palette Actions bar the IDE's own palettes use.12 min · 7 examples 80The Tree ViewShow an array as a tree people can open and close with the Tree View widget: its arrayData, sorting, which branches are open, the row that is chosen and the message a click sends, and a folder's files as a tree.12 min · 6 examples 81Charts, clocks and calendarsShow numbers as pictures with the Line Graph and the Pie Chart widgets, answer a click on a slice of the pie, show the time in any city with the Clock, and let people pick a day with the Calendar.12 min · 8 examples 82Icons and SVGFind the icons that come with OXT-Beyond with the Icon SVG library, draw, colour, turn and light them with the SVG Icon widget, draw a shape of your own from an SVG path, and let people choose an icon with the Icon Picker.12 min · 9 examples 83Web pages and native controlsShow a web page, or a page of your own, in a card with the Browser widget, answer what happens in it, let the page call your scripts, and use the buttons and fields each system draws itself with the native widgets.12 min · 6 examples

Where next More ways to learn, in the IDE and beyond

These lessons are written for OXT-Beyond, and follow the path the language's own books and courses took: Danny Goodman's HyperCard handbooks, RunRev's Revolution tutorials, and LiveCode's lessons and User Guide. They are free to use and share under the same licence as OXT-Beyond (GPLv3).