Instructions
You can attach Instructions to buttons, fields, and forms.
1. Buttons
Browsers allow
<button>s in the text. Whatever style they may be, buttons mostly have the same "be pushed or changed"
modus operandi.
1.5. Un-buttons
This is a <label><select><option> tag.
These are <label><input> tags.
1.5.1. Un-un-buttons
There are <button> tags which transition to <label><input> and <label><select>.
button style=popup:
2. Field
Hi, I'm a field.
3. Form
4. Events
These have some Javascript attached to them.
5. Instructions
Here are some Instructions to try.
Push the buttons to load up an Instruction and send it.
answer "some quoted text"
ask "math" with 8 * 7 + three
Here, try instructions for yourself
Then click the Run button
Instructions are turned into Javascript that modern browsers execute.
text = char*
char = c:("\\" / "\t" / "\"") -> "\\" c
char = .
#optional line of script, then optional non-line-breaks plus line breaks, then again if desired
rule = line*
line = spaces? script restofline? linebreaks?
line = restofline linebreaks?
line = linebreaks
_ = spaces
spaces = ." \t"+
linebreaks = ."\n\r"+
restofline = t:(-linebreaks .)+ [ignore] -> "// " t
script = command [command]
command = keyword<"answer"> q:expression? -> "alert(" q ")"
command = keyword<"ask"> q:expression? keyword<"with"> w:expression? -> "prompt(" q "," w ")"
command = keyword<"ask"> q:expression? -> "confirm(" q ")"
keyword = spaces? (what [keyword]) spaces?
expression = quoted / math
#quoted = spaces? quote (-quote -linebreaks .)* quote? [quoted]
#quote = ."\"\“\”\'\‘\’" -> "\""
quoted = _? singlequote inner:(-singlequote -linebreaks .)* singlequote? [quoted] -> "\'" inner "\'"
quoted = _? doublequote inner:(-doublequote -linebreaks .)* doublequote? [quoted] -> "\"" inner "\""
singlequote = ."\'\‘\’"
doublequote = ."\"\“\”"
math = sum
sum = t:(sum plus product) -> "(" t ")" / t:(sum minus product) -> "(" t ")" / product
product = t:(product times factor) -> "(" t ")" / t:(product slash factor) -> "(" t ")" / factor
factor = v:value caret f:factor -> "Math.pow(" v "," f ")" / value
value = spaces value spaces? / value spaces
value = "(" s:sum ")" " "* -> s
value = (."0123456789"+ / literal) [number]
literal = "zero"->"0" / "one"->"1" / "two"->"2" / "three"->"3" / "four"->"4" / "five"->"5" / "six"->"6" / "seven"->"7" / "eight"->"8" / "nine"->"9" / "ten"->"10"
plus = ("+" / "plus") -> "+"
minus = ("-" / "minus") -> "-"
times = ("*" / "times") -> "*"
slash = ("/" / "divided" " "+ "by") -> "/"
caret = ("^" / "to" " "+ "the" " "+ "power" " "+ "of")
6. Instruction box
The instruction(s) box is a pretty cool yellow box that you can type Instructions into. It's available for view here:
You can use the instruction box in the editing environment, for example, at /~hypervariety/instructions. Neat! It's got some very neat powers.