And now it's not solved.
I calculate whether I am in landscape or portrait mode and set all my globals up then call os_lock_orientation(true). If I hold my device in landscape mode, all is fine, but if I am holding it in protrait mode, it still runs in landscape mode but with all my globals (width, height and orientation) set as portrait... How strange - anybody experienced problems with this before?
EDIT
Curiouser and curiouser. If I force my app to only allow Portrait modes (Global settings) then hold the tablet in portrait mode, the app opens in landscape mode (but with device_height and width showing it as portrait i.e. height < width). Is this command broken, or am I? Can anybody try this out and comment? Thanks.