I do it like this:
CurrentOffset = GetOEMDRO(46) ' Get Current Coordinate system 1 = G54, 2 = G55, ....
If CurrentOffset = 1 Then
ZOffset=GetVar(5223)
ElseIf CurrentOffset = 2 Then
ZOffset=GetVar(5243)
ElseIf CurrentOffset = 3 Then
ZOffset=GetVar(5263)
ElseIf CurrentOffset = 4 Then
ZOffset=GetVar(5283)
ElseIf CurrentOffset = 5 Then
ZOffset=GetVar(5303)
ElseIf CurrentOffset = 6 Then
ZOffset=GetVar(5323)
End If
For X = 5223 To 5323 Step 20
SetVar(X, ZOffset)
Next X
Sleep(250)