#### camerart

##### Active Member

I'm trying to convert a piece of code written in PIC Basic to Oshonsoft basic, below:

I get most of it, apart from 'ABS' and e,g, the decimal point in 'Distance.15' and the numbers 13 and 15.

Any help appreciated.

Camerart.

Position VAR WORD

Target VAR WORD

Distance VAR WORD

Position = 1234

Main:

HSEROUT[13, "You're at position: ", DEC Position, 13]

HSEROUT["Enter new target: ",13]

HSERIN[DEC Target]

' Actual calculation starts here.

' When done the variable Distance contains the

' number of "ticks" to target in two's complement format.

Distance = Target - Position

IF Distance.15 = 0 THEN ' Distance is positive

If Distance > 1790 THEN

Distance = Distance - 3580

Endif

ENDIF

IF Distance.15 = 1 THEN ' Distance is negative

IF ABS Distance > 1790 THEN

Distance = Distance + 3580

ENDIF

ENDIF

' End of calculation, result now in Distance.

Done:

IF Distance.15 = 1 THEN ' Distance is negative

HSEROUT["CCW "]

ELSE

HSEROUT["CW "]

ENDIF

HSEROUT[DEC ABS Distance, " ticks.", 13]

Position = Target

Goto Main