Instruction graph
draws graph of passed expression.
instructionCreate(graph,exp)
variableCreateLocal(x,0.i)
variableCreateLocal(y,0.i)
logicLoopF(x,500.i)
mathExpression(y,exp)
graphicWindowSetPoint(x,y,100.i,100.i,100.i)
}
variableDeleteLocal(x,y)
}
graphicWindowCreate(500.i,500.i,Graph.s)
graph(x)
graph(2.i*x)
graph((250.i-x)%50.i+50.i)
Operator [var.s key]
is used (reference to variable named as key’s value). In fact key is something like pointer to variable.
variableCreate(input,var.s)
input.consoleScan()
variableCreate([input],user<s>created<s>variable.s)
[input].consolePrint()
/To see what happened:
debugVariables()
instructionExecute
worksinstructionExecute
is wrapper for calling instructions. When instruction (e.g. ins(a,b)
or equivalent a.ins(b)
) isn’t built-in instruction, instructionExecute
is called (instructionExecute(ins,a,b)
for both situations). You can also force instructionExecute
to call built-in instruction (eg. instructionExecute(consolePrint,hello.s)
) Try following code and see it yourself:
instructionCreate(myPrint,text)
consolePrint(text)
}
/debugInstructions to see what happened:
debugInstructions()
consolePrint(a.s,b.s)
a.s.consolePrint(b.s)
myPrint(c.s)
instructionExecute(consolePrint,a.s,b.s)
/Even the following is correct!
consolePrint.instructionExecute(a.s,b.s)
instructionExecute
has following logic:
var.s
supertype, try to execute instuction named as this variable value.Related to instructionExecute
:
lastInstruction
(last instruction’s name called by instructionExecute
as var.s
, all non built-in instructions are called by instructionExecute
, not thread-safe, initial value is doNothing
)lastArguments
(last instruction’s called by instructionExecute
argument’s names as var[]
of var.s
, all non built-in instructions are called by instructionExecute
, not thread-safe, initial value is var[]
)It makes creating instructions much easier.
instructionCreate(createNewPrint,insName,text)
/Create variable named as insName
variableCreate(insName,text)
instructionCreate(insName)
/Access variable named as last instruction called by instructionExecute
[lastInstruction]. consolePrint()
consoleNewLine()
}
}
createNewPrint(printHello,hello.s)
createNewPrint(printGoodbye,goodbye.s)
printHello()
printGoodbye()
This example shows how to create fallback for instruction (user might not have necessary dependencies).
<include(library/myIns.ans)>
instructionCreate(fallbackForMyIns)
debugError(Please<s>install<s>myIns.ans.s)
}
variableCreate(myIns,fallbackForMyIns.s)
/...
/..
/If myIns instuction doesn't exist call fallbackForMyIns
myIns(1.i,abbccc.s)
Many of built-in instructions have variable number of arguments. Here’s example showig how to achieve such effect:
instructionCreate(printFromName,name)
[name].consolePrint()
}
instructionCreate(mySuperPrint)
/We need to save lastArguments to temporary variable
/because it would be overwritten by printFromName.
variableCreateLocal(t,lastArguments)
t.arrayForEach(printFromName)
variableDeleteLocal(t)
}
mySuperPrint(a.s,1.i,b.s)
<include(library/arrayPushBack.ans)>
variableCreate(a,var[])
a.arrayPushBack(abbbs.s)
[a.s][0.i].[consolePrint.s.s]()
[123123123.i.s].[consolePrint.s.s]()