Global Navigation Bar

MapInfo Products Knowledge Base


Product: MapBasic
Version: 6.x
Platform: Windows NT 4.0
Category: Tools

Summary:
Finding the current Paper Units in MapBasic.

Question:
There are no functions available in MapBasic that return the current Paper Units. How can the current setting be determined?

Answer:
Try this workaround. The PUI_Test.mb shows how to implement the PaperUnitInfo function.
paperunt.MB

'PaperUnitInfo - Given a WindowID of a Mapper Window,
'will return a string with the current Paper Unit type.
'The mapbasic.def must be included in the calling application

declare function PaperUnitInfo (WindID as float) as string

function PaperUnitInfo (WindID as float) as string
dim scale as float

if not (WindowInfo(WindID,WIN_INFO_TYPE) = WIN_MAPPER) then
PaperUnitInfo = "WindID is not a valid Map WindowID"
exit function
end if

'Record the Original Scale
Scale = MapperInfo(WindID,MAPPER_INFO_SCALE)

'Series of changes and tests to find the matching scale -> Paper Unit
set paper units "in"
if scale = MapperInfo(WindID,MAPPER_INFO_SCALE) then
PaperUnitInfo = "in"
exit function
end if
set paper units "cm"
if scale = MapperInfo(WindID,MAPPER_INFO_SCALE) then
PaperUnitInfo = "cm"
exit function
end if
set paper units "mm"
if scale = MapperInfo(WindID,MAPPER_INFO_SCALE) then
PaperUnitInfo = "mm"
exit function
end if
set paper units "pt"
if scale = MapperInfo(WindID,MAPPER_INFO_SCALE) then
PaperUnitInfo = "pt"
exit function
end if
set paper units "pica"
if scale = MapperInfo(WindID,MAPPER_INFO_SCALE) then
PaperUnitInfo = "pica"
exit function
end if

'Non-standard paper unit in use, reverts to inches
set paper units "in"
PaperUnitInfo = "Error->in"
end function

Last Modified: 12/06/2000 12:26:35 PM
Global Navigation Bar