Inc

Inc increments. That's it. It's pretty handy if you have something like a popup menu to which you're assigning a bunch of items.

Instead of
aMenuShow{1}:="Remove Field"
aMenuDo{1}:="mRemoveField"
aMenuShow{2}:="Remove Table"
aMenuDo{2}:="mRemoveTable"
aMenuShow{3}:="Remove Bad Code"
aMenuDo{3}:="mRemoveBadCode"
You could do this
Inc(0;0)
aMenuShow{Inc}:="Remove Field"
aMenuDo{Inc(0)}:="mRemoveField"
aMenuShow{Inc}:="Remove Table"
aMenuDo{Inc(0)}:="mRemoveTable"
aMenuShow{Inc}:="Remove Bad Code"
aMenuDo{Inc(0)}:="mRemoveBadCode"

This way, you can reorder the items without having to renumber them all.

The first parameter is the amount to increment, the second is what to set the current value to. So, Inc(0;0) resets it. Inc(0), doesn't increment, which is useful if you need to assign the same number more than once. Calling Inc with no parameters increments by one.

One sort of bad thing about Inc is that it uses a process variable to store the incremented value. I suppose I could have used a resource, external document or magic, but I thought these options were not warranted due to the short nature of the method name.

Since this is just one method, it's here as text instead of an example database or component.

  ` Inc
  ` Returns the next number in a series.
  ` With no parameters, this returns one more than the last number.
  ` Passing a number increments by that much.
  ` Passing a second parameter sets the returned value to that number
  `    This is useful to resetting the value to zero or presetting it to a new value.
  ` Inc is handy when you need to assign a bunch of incremental numbers where it 
  ` can't be done in a loop and you don't want to hard code them.
  ` Example:
  ` Inc (0;0)  ` Initialize - Sets value to second parameter
  ` SetupDropDown(Inc;"Search...")
  ` SetupDropDown(Inc;"Sort...")
  ` Written by Tom Dillon

C_LONGINT(vIncrementalValue;$Inc;$1)

If (Count parameters>=1)
  $Inc:=$1
Else 
  $Inc:=1
End if 

If (Count parameters>=2)
  vIncrementalValue:=$2
End if 

vIncrementalValue:=vIncrementalValue+$Inc

$0:=vIncrementalValue