Store Commands

From WikiManual
Jump to: navigation, search

Store commands alter the contents of memory locations

Operators:

Store Commands:

store
inc dec

The following commands are not supported in versions earlier 2.46:

addstore
substore
multstore
divstore
ceilstore
floorstore
rndstore
sgnstore
abstore
sqrstore
negstore

Store

Store will store a value in a memory location:

a b store

will store a into b. Rather than a and b, you are more likely to see something like this:

40 .up store

which will store 40 into the sysvar .up

Inc and Dec

Inc increases a memory location by 1

Dec increases a memory location by 1

You cannot inc or dec the sysvars 1 - 8.

'Value Freezing'

Thanks to Endy for the following:

You can hold memory locations at certain values using inc and dec. This technique allows you to "freeze" values or to raise or lower a number to a value and then freeze it.
This is best used for when you need a value at a constant number, but without the cost of continously storring it.

' Basic method to demonstrate
' Will keep .tieloc at -1 permanently
cond
start
.tieloc *.tieloc *.tieloc div mult inc
.tieloc dec
stop
' More complex method demonstrates freezing
' at a value with .ploc=7
cond
start
' When *.ploc = 7 dec by 1
.ploc *.ploc 7 sub 1000 mult add dec
.ploc inc
stop

Primarily these are for use with SG's or condtionless bots but I'm sure you all can find other uses for them. Unfortunately memory locations 1 - 8 do not allow this.