Home
The HyperCard Center
HyperTalk Reference
Home » HyperTalk Reference » random

Note: This is a work in progress and many formatting issues have been fixed. Read more about the project on the home page.

random

the random of posInteger

Value returned: a random integer between 1 and posInteger

Random returns values for integers up to 2^31 - 2.

Demo Script

on hyperMath
-- This is a very simple math flash card script.
put random(50) into intOne
put random(50) into intTwo
put item random(2) of "+,-" into theOperator
put intOne && theOperator && intTwo && "=" && ¬
(the value of (intOne && theOperator && intTwo)) into theAnswer
put 0 into theCount
ask "What is" && intOne && theOperator && intTwo
if it is empty then exit hyperMath
if it is last word of theAnswer then put "That's right!" & ¬
return before theAnswer
answer theAnswer
end hyperMath

Placeholders

posInteger

An expression that evaluates to a positive integer.

For example:

3
67 mod 13
the number of bg fields
the number of backgrounds
the number of cards div 2

See also: background, bkgnd, button, card, chunk, field, menu, and menuItem

HyperTalk Reference

Version 0.8b4 (July 4, 2025)

Made with Macintosh

Switch to Retro View