MicroStation®

BASIC Guide
DAA010290-1/0002

Trademarks
AccuDraw, MicroStation, MicroStation Modeler, MicroStation PowerDraft, MicroStation Review, MicroStation Vault and SmartLine are registered trademarks of Bentley Systems, Incorporated. Bentley, the “B” Bentley logo, MDL, PowerScope, QuickVision, TeamMate and MasterPiece are trademarks of Bentley Systems, Incorporated. Bentley SELECT is a service mark of Bentley Systems, Incorporated. Adobe, the Adobe logo, Acrobat, the Acrobat logo, Distiller, Exchange, and PostScript are trademarks of Adobe Systems Incorporated. Windows is a registered trademark and Win32s is a trademark of Microsoft Corporation. Other brands and product names are the trademarks of their respective owners.

Copyrights
1997 Bentley Systems, Incorporated. MicroStation® 95 1995 Bentley Systems, Incorporated. IGDS file formats 1987-1994 Intergraph Corporation. Intergraph Raster File Formats 1994 Intergraph Corporation Used with permission. Portions 1992-1994 Summit Software Company. Unpublished – rights reserved under the copyright laws of the United States.

MicroStation BASIC Guide

i

ii

MicroStation BASIC Guide

Table of Contents
Part 1: Concepts and Procedures
1. Introduction to Macros
Creating Macros ______________________________________________ 1-1 Guidelines for creating a macro_____________________________ 1-2 Advanced macro programming _____________________________ 1-3 Running Macros _____________________________________________ 1-5 Creating and Managing Macros ________________________________ 1-6 Generating macros________________________________________ 1-6 Managing macros _________________________________________ 1-7 Adding macros to MicroStation’s user interface ________________ 1-8

2. Prototyping, Editing, and Debugging Macros
Prototyping__________________________________________________ 2-1 Starting conditions ________________________________________ 2-1 The Create Macro dialog box _______________________________ 2-1 Stopping the macro generator ______________________________ 2-2 The form of a prototype macro _____________________________ 2-3 BASIC extensions commonly used by the macro generator _____ 2-4 The BASIC Editor ____________________________________________ 2-6 Text editing area and scrolling______________________________ 2-7 Status message field_______________________________________ 2-8 Line number and column number fields _____________________ 2-8 File menu _______________________________________________ 2-8 Edit menu _______________________________________________ 2-9 Run menu _______________________________________________ 2-10 Debugger icons __________________________________________ 2-11 Working with variables ____________________________________ 2-12

3. Macro Language Overview
Comments___________________________________________________ 3-1 Naming Rules ________________________________________________ 3-1 Built-in Data Types ___________________________________________ 3-2 Integers _________________________________________________ 3-2 Long integers ____________________________________________ 3-2 Strings __________________________________________________ 3-2 Singles __________________________________________________ 3-3 Doubles_________________________________________________ 3-3
MicroStation BASIC Guide

iii

Table Of Contents: Macro Language Overview
Variable Declarations __________________________________________3-3 Declaring integer variables _________________________________3-4 Declaring long variables ___________________________________3-4 Declaring string variables___________________________________3-4 Declaring single variables __________________________________3-5 Declaring double variables _________________________________3-5 Arrays of Variables ____________________________________________3-5 Fixed-length arrays ________________________________________3-6 Variable-length arrays______________________________________3-7 User-defined Data Type Variables _______________________________3-8 Creating a user-defined data type ____________________________3-8 Declaring user-defined data type variables ____________________3-9 Working with user-defined data type variables ________________3-9 Variable Scope _______________________________________________3-9 Local variables____________________________________________3-10 Private variables __________________________________________3-10 Public variables ___________________________________________3-10 Initial Variable Values _________________________________________3-11 Symbolic Constants ___________________________________________3-11 Expressions __________________________________________________3-11 Assignment operator_______________________________________3-11 Arithmetic operators _______________________________________3-12 String concatenation operators ______________________________3-13 Relational operators _______________________________________3-13 Logical operators__________________________________________3-14 Operator precedence ______________________________________3-15 Statements and the Line Continuation Character ___________________3-15 Controlling Execution _________________________________________3-16 If...Then...Else ____________________________________________3-16 Select...Case ______________________________________________3-18 Do...Loop ________________________________________________3-19 While...Wend _____________________________________________3-22 For...Next ________________________________________________3-22 Labels and the Goto statement ______________________________3-24 GoSub and Return statements _______________________________3-24 Program Structure_____________________________________________3-25 Subroutine procedures _____________________________________3-26 Calling subroutine procedures ______________________________3-27 Function procedures_______________________________________3-28 Calling function procedures ________________________________3-30 Passing arguments to procedures ____________________________3-30 Declaring procedures ______________________________________3-32 Objects in BASIC _____________________________________________3-32 Declaring an object variable ________________________________3-33 Object variable operations__________________________________3-34 Creating an object instance _________________________________3-35

iv

MicroStation BASIC Guide

Table Of Contents: Macro Interactions With MicroStation
Accessing object properties ________________________________ 3-36 Accessing object methods__________________________________ 3-36 Object collections ________________________________________ 3-37 Constant objects __________________________________________ 3-37 Error Handling _______________________________________________ 3-38

4. Macro Interactions With MicroStation
MicroStation BASIC Extension conventions _______________________ 4-1 Sequencing MicroStation Commands ____________________________ 4-1 Macro Coordinate System______________________________________ 4-2 Querying and Manipulating Graphic Elements ____________________ 4-3 Modifying graphic elements ________________________________ 4-8 Using selection sets and fences _____________________________ 4-9 Graphic element location __________________________________ 4-11 Accessing design file information ___________________________ 4-12 Accessing MicroStation settings _____________________________ 4-13 Accessing MicroStation state information _____________________ 4-13 Accessing design file view information_______________________ 4-14 Accessing reference file information _________________________ 4-14 Accessing MicroStation session information ___________________ 4-15 Database features of MicroStation BASIC extensions ___________ 4-15 Using Macros to Specify Pen Table Output Actions ________________ 4-18 Overview of macro operation in pen tables___________________ 4-18 The Main subroutine is optional in plotting___________________ 4-19 Working with element priorities in macros ___________________ 4-19 Pen Table Plot Element Hook function return values___________ 4-20 A macro plot function example _____________________________ 4-21 Pen table program entry points _____________________________ 4-22 The different program entry points and their function __________ 4-24 Optimizing the macro for plotting ___________________________ 4-25 Using Macros to Perform DWG Import/Export ____________________ 4-26 Objects for specifying import and export settings______________ 4-26 Object for specifying font cross-reference information__________ 4-27 Objects for specifying cell/block cross-reference information ____ 4-28 Editing and compiling “dwg.bas”____________________________ 4-29

MicroStation BASIC Guide

v

Table Of Contents: Adding Dialog Boxes to Macros

5. Adding Dialog Boxes to Macros
Standard Dialog Boxes_________________________________________5-1 Custom Dialog Boxes__________________________________________5-2 Dialog Builder________________________________________________5-3 Dialog menu _____________________________________________5-4 Edit menu________________________________________________5-6 Options menu ____________________________________________5-8 Common item attributes____________________________________5-10 Text Editor dialog box _____________________________________5-11 Label Editor dialog box ____________________________________5-11 Toggle Button Editor dialog box ____________________________5-12 Option Button Editor dialog box ____________________________5-12 Push Button Editor ________________________________________5-13 Color Picker dialog box ____________________________________5-14 Level Map Editor dialog box ________________________________5-15 Scale Editor dialog box ____________________________________5-15 Alignment menu __________________________________________5-18 Tool box_________________________________________________5-19 Exiting Builder____________________________________________5-20

6. The MDL Alternative
MicroStation Development Environment__________________________6-1 MicroStation Development Language_________________________6-2 MDL built-in functions _____________________________________6-2 When to use MDL instead of BASIC__________________________6-3

Part 1: Macro Language Reference
7. Standard BASIC Reference
BASIC Command Overview ____________________________________7-1 Operators ________________________________________________7-1 Constants and special keywords_____________________________7-2 Math and numerical operators ______________________________7-2 Array handling____________________________________________7-3 System __________________________________________________7-4 Miscellaneous ____________________________________________7-4 Program control __________________________________________7-4 Variable control___________________________________________7-5

vi

MicroStation BASIC Guide

Table Of Contents: Standard BASIC Reference
Character and string manipulation___________________________ 7-6 File handling_____________________________________________ 7-7 Date and time____________________________________________ 7-8 Business calculations ______________________________________ 7-9 Dynamic Data Exchange (DDE), Windows platforms only ______ 7-10 A to Z Reference ____________________________________________ 7-11 & ______________________________________________________ 7-11 ' _______________________________________________________ 7-12 * _______________________________________________________ 7-12 + _______________________________________________________ 7-12 - _______________________________________________________ 7-13 / _______________________________________________________ 7-13 < _______________________________________________________ 7-13 <=______________________________________________________ 7-14 <>______________________________________________________ 7-14 = _______________________________________________________ 7-15 > _______________________________________________________ 7-15 >=______________________________________________________ 7-16 \ _______________________________________________________ 7-16 ^ _______________________________________________________ 7-17 _ _______________________________________________________ 7-17 Abs_____________________________________________________ 7-18 And ____________________________________________________ 7-19 ArrayDims _______________________________________________ 7-19 ArraySort ________________________________________________ 7-20 Asc _____________________________________________________ 7-20 Atn _____________________________________________________ 7-21 Basic.Capability% _________________________________________ 7-21 Basic.Eoln$ ______________________________________________ 7-22 Basic.FreeMemory ________________________________________ 7-22 Basic.OS ________________________________________________ 7-22 Basic.PathSeparator$ ______________________________________ 7-23 Beep ___________________________________________________ 7-24 Call_____________________________________________________ 7-24 CDbl ___________________________________________________ 7-24 Chr$ ____________________________________________________ 7-25 CInt ____________________________________________________ 7-25 CLng ___________________________________________________ 7-26 Close ___________________________________________________ 7-27 Command$ ______________________________________________ 7-27 Const ___________________________________________________ 7-28 Cos_____________________________________________________ 7-28 CSng ___________________________________________________ 7-28 CStr ____________________________________________________ 7-29 Date$ ___________________________________________________ 7-29 DateAdd ________________________________________________ 7-30
MicroStation BASIC Guide

vii

Table Of Contents: Standard BASIC Reference
DateDiff _________________________________________________7-31 DatePart _________________________________________________7-33 DateSerial ________________________________________________7-34 DateValue _______________________________________________7-34 Day _____________________________________________________7-34 DDB ____________________________________________________7-35 DDEExecute______________________________________________7-36 DDEInitiate ______________________________________________7-36 DDEPoke ________________________________________________7-37 DDERequest______________________________________________7-38 DDESend ________________________________________________7-38 DDETerminate____________________________________________7-39 DDETerminateAll _________________________________________7-39 DDETimeOut _____________________________________________7-40 Declare __________________________________________________7-40 DEF… ___________________________________________________7-41 Dim _____________________________________________________7-42 Dir$_____________________________________________________7-44 Do...Loop ________________________________________________7-45 ebArchive ________________________________________________7-47 ebDirectory ______________________________________________7-47 ebHidden ________________________________________________7-47 ebNone__________________________________________________7-48 ebNormal ________________________________________________7-48 ebReadOnly ______________________________________________7-49 ebSystem ________________________________________________7-49 ebVolume________________________________________________7-49 End _____________________________________________________7-50 Environ$_________________________________________________7-50 Eof______________________________________________________7-50 Eqv _____________________________________________________7-51 Erase ____________________________________________________7-52 Erl ______________________________________________________7-53 Err (function)_____________________________________________7-53 Err (statement)____________________________________________7-54 Error ____________________________________________________7-54 Error$ ___________________________________________________7-55 Exit Do __________________________________________________7-56 Exit For__________________________________________________7-56 Exit Function _____________________________________________7-57 Exit Sub _________________________________________________7-57 Exp _____________________________________________________7-58 False ____________________________________________________7-58 FileAttr __________________________________________________7-58 FileCopy _________________________________________________7-59 FileDateTime _____________________________________________7-60

viii

MicroStation BASIC Guide

Table Of Contents: Standard BASIC Reference
FileDirs _________________________________________________ 7-61 FileExists ________________________________________________ 7-61 FileLen__________________________________________________ 7-62 FileList __________________________________________________ 7-62 FileParse$ _______________________________________________ 7-64 Fix _____________________________________________________ 7-65 For...Next _______________________________________________ 7-65 Format$ _________________________________________________ 7-66 FreeFile _________________________________________________ 7-73 Function...End Function ___________________________________ 7-73 Fv ______________________________________________________ 7-75 Get _____________________________________________________ 7-76 GetAttr __________________________________________________ 7-78 Global __________________________________________________ 7-79 GoSub __________________________________________________ 7-79 Goto____________________________________________________ 7-80 Hex$ ___________________________________________________ 7-80 Hour ___________________________________________________ 7-81 If...Then...Else____________________________________________ 7-81 Imp ____________________________________________________ 7-83 Input #__________________________________________________ 7-84 Input$ __________________________________________________ 7-85 InStr ____________________________________________________ 7-85 Int______________________________________________________ 7-86 IPmt ____________________________________________________ 7-87 IRR _____________________________________________________ 7-88 Is ______________________________________________________ 7-90 Item$ ___________________________________________________ 7-90 ItemCount _______________________________________________ 7-91 Kill _____________________________________________________ 7-91 LBound _________________________________________________ 7-92 LCase$ __________________________________________________ 7-93 Left$ ____________________________________________________ 7-93 Len _____________________________________________________ 7-94 Let _____________________________________________________ 7-95 Like ____________________________________________________ 7-95 Line Input # _____________________________________________ 7-96 Line$ ___________________________________________________ 7-97 LineCount _______________________________________________ 7-98 Loc _____________________________________________________ 7-98 Lock ____________________________________________________ 7-99 Lof _____________________________________________________ 7-101 Log _____________________________________________________ 7-101 LSet ____________________________________________________ 7-102 LTrim$ __________________________________________________ 7-102 Main____________________________________________________ 7-103
MicroStation BASIC Guide

ix

Case ______________________________________________7-137 Set ______________________________________________________7-139 SetAttr ___________________________________________________7-140 x MicroStation BASIC Guide ...Table Of Contents: Standard BASIC Reference Mid$ ____________________________________________________7-103 Minute __________________________________________________7-104 MIRR ____________________________________________________7-104 MkDir ___________________________________________________7-105 Mod_____________________________________________________7-106 Month ___________________________________________________7-106 Name ___________________________________________________7-107 Not _____________________________________________________7-107 Now ____________________________________________________7-108 NPer ____________________________________________________7-108 Npv _____________________________________________________7-110 Null _____________________________________________________7-111 Oct$ ____________________________________________________7-111 On Error _________________________________________________7-112 Open____________________________________________________7-114 Option Base______________________________________________7-116 Option Compare __________________________________________7-116 Or ______________________________________________________7-117 PI_______________________________________________________7-118 Pmt _____________________________________________________7-118 PPmt ____________________________________________________7-119 Print ____________________________________________________7-121 Print# ___________________________________________________7-122 Private___________________________________________________7-123 Public ___________________________________________________7-124 Put______________________________________________________7-125 Pv ______________________________________________________7-127 Random _________________________________________________7-128 Randomize _______________________________________________7-128 Rate_____________________________________________________7-129 ReDim___________________________________________________7-130 REM ____________________________________________________7-131 Reset ____________________________________________________7-131 Resume__________________________________________________7-131 Return ___________________________________________________7-133 Right$ ___________________________________________________7-133 RmDir ___________________________________________________7-133 Rnd _____________________________________________________7-134 RSet_____________________________________________________7-134 RTrim$ __________________________________________________7-135 Second __________________________________________________7-135 Seek (function) ___________________________________________7-135 Seek (statement) __________________________________________7-136 Select.

. MbeState.errorMessages. MicroStation Extensions to BASIC State Object _________________________________________________ 8-2 MbeState..Wend ____________________________________________ 7-156 Width#__________________________________________________ 7-156 Word$ __________________________________________________ 7-157 WordCount ______________________________________________ 7-157 Write #__________________________________________________ 7-158 Xor _____________________________________________________ 7-158 Year ____________________________________________________ 7-159 8.inputType _______________________________________ 8-3 MbeState.getInputKeyin ___________________________________ 8-4 MbeState..getInputCommand________________________________ 8-3 MbeState.getInputDataPoint ________________________________ 8-4 MbeState.End Sub ____________________________________________ 7-146 SYD ____________________________________________________ 7-147 Tab_____________________________________________________ 7-148 Tan_____________________________________________________ 7-148 Time$___________________________________________________ 7-149 Timer ___________________________________________________ 7-149 TimeSerial _______________________________________________ 7-150 TimeValue_______________________________________________ 7-150 Trim$ ___________________________________________________ 7-151 True ____________________________________________________ 7-151 Type____________________________________________________ 7-151 UBound_________________________________________________ 7-152 UCase$ _________________________________________________ 7-153 UnLock _________________________________________________ 7-153 Val _____________________________________________________ 7-154 Weekday ________________________________________________ 7-155 While.noElementDisplay ________________________________ 8-6 MicroStation BASIC Guide xi .messages __________________ 8-6 MbeState.cmdResult _______________________________________ 8-5 MbeState..Table Of Contents: MicroStation Extensions to BASIC Sgn _____________________________________________________ 7-141 Sin _____________________________________________________ 7-141 Sleep ___________________________________________________ 7-141 Sln _____________________________________________________ 7-142 Space$ __________________________________________________ 7-142 Spc _____________________________________________________ 7-143 Sqr _____________________________________________________ 7-143 Stop ____________________________________________________ 7-144 Str$_____________________________________________________ 7-144 StrComp ________________________________________________ 7-145 String$ __________________________________________________ 7-146 Sub.

MbeState.reviewDBAttributes ____________________________8-18 MbeElement.color _________________________________________8-35 MbeElement.locateHeaderFilePos_______________________________8-10 MbeState.headerElement ________________________________8-26 MbeElement.extractDBLinkages _____________________________8-20 MbeElement.internalSize ___________________________________8-30 MbeElement.setLocateFileMask.firstElement ___________________________________8-22 MbeElement.fromLocate____________________________________8-32 MbeElement. MbeState.getPoints _____________________________________8-39 MbeElement.locatePropVal _____________8-13 MbeState.measureResult1.measureResult2 ____________8-7 MbeState.Table Of Contents: MicroStation Extensions to BASIC MbeState.getEndPoints __________________________________8-41 xii MicroStation BASIC Guide .locatePropMask. MbeState.locateFileNum ____________________________________8-9 MbeState.locateComponentFilePos ___________________________8-10 MbeState.class _________________________________________8-36 MbeElement.fromFile ______________________________________8-31 MbeElement.getOrigin _____________________________________8-38 MbeElement.attachActiveEntity ______________________________8-18 MbeElement.changeAll_____________________________________8-34 MbeElement.isComponent __________________________________8-29 MbeElement.properties ____________________________________8-37 MbeElement.nextElement __________________________________8-22 MbeElement.thisComponent ________________________________8-27 MbeElement.filePos _______________________________________8-33 MbeElement.locateTolerance___________________________________8-8 MbeState.style _________________________________________8-35 MbeElement.foundDBLinkages ______________________________8-19 MbeElement. MbeState.weight _______________________________________8-36 MbeElement.setPoints______________________________________8-40 MbeElement.appendDBLinkage _____________________________8-21 MbeElement.isHeader______________________________________8-28 MbeElement.parseAll _________________________________________8-7 MbeState.locateClassMask __________________________________8-14 Element Object ______________________________________________8-15 MbeElement.componentFilePos _____________________________8-33 MbeElement.getLocateFileMask________8-10 MbeState.deleteDBLinkage_______________________________8-21 MbeElement.getLocateTypeMask _____8-11 MbeState.level _________________________________________8-34 MbeElement.isGraphics ____________________________________8-29 MbeElement.loadDAttributes ________________________________8-19 MbeElement.fileSize _______________________________________8-30 MbeElement.fileNum ______________________________________8-33 MbeElement.type _________________________________________8-29 MbeElement.nextComponent _______________________________8-24 MbeElement.setLocateTypeMask.reportDBLinkages ______________________________8-19 MbeElement.

rewrite_______________________________________ 8-44 MbeElement.getCellBox ___________________________________ 8-48 MbeElement.getCentroid___________________________________ 8-47 MbeElement.cellName_____________________________________ 8-47 MbeElement.sweepAngle __________________________________ 8-55 MbeElement.isTagged _____________________________________ 8-57 MbeElement.justification ___________________________________ 8-51 MbeElement.perimeter ____________________________________ 8-46 MbeElement.secondaryAxis ________________________________ 8-54 MbeElement.bottomRadius ____________ 8-55 MbeElement.setString _____________________________________ 8-53 MbeElement.extractLinkage ________________________________ 8-59 MbeElement.rotate ________________________________________ 8-42 MbeElement.getRotation ___________________________________ 8-49 MbeElement.font _________________________________________ 8-49 MbeElement.getCellLevels _________________________________ 8-48 MbeElement.appendLinkage _______________________________ 8-60 MbeElement.fontName ____________________________________ 8-49 MbeElement.lineSpacing ___________________________________ 8-51 MbeElement.fromFence _________________________________ 8-63 MbeElementSet.publish ______________________________________ 8-56 MbeElement.clear ______________________________________ 8-65 MicroStation BASIC Guide xiii . MbeElement.getMbeTag ___________________________________ 8-58 MbeElement.scale ________________________________________ 8-43 MbeElement.topRadius.numTags _____________________________________ 8-58 MbeElement.getRange _____________________________________ 8-41 MbeElement.charWidth ______________ 8-50 MbeElement.tagId ________________________________________ 8-57 MbeElement.extractTags ___________________________________ 8-58 MbeElement.area _________________________________________ 8-46 MbeElement. MbeElement.getNext____________________________________ 8-64 MbeElementSet.addToFile ____________________________________ 8-45 MbeElement.attachTag ____________________________________ 8-59 MbeElement.getString _____________________________________ 8-52 MbeElement.fromSelectionSet ____________________________ 8-62 MbeElementSet.Table Of Contents: MicroStation Extensions to BASIC MbeElement.primaryAxis __________________________________ 8-53 MbeElement.startAngle ____________________________________ 8-54 MbeElement.move ________________________________________ 8-42 MbeElement.volume ______________________________________ 8-47 MbeElement.getNumLinkages ______________________________ 8-59 MbeElement.charHeight.deleteLinkage _________________________________ 8-61 Element Set Object ___________________________________________ 8-62 MbeElementSet.getTopOrigin _________________________________ 8-55 MbeElement.group________________________________________ 8-57 MbeElement.display_______________________________________ 8-45 MbeElement.getFirst ____________________________________ 8-64 MbeElementSet.

gridReferences _________________________________8-72 MbeSettings.level__________________________________________8-73 MbeSettings.textLineLength _________________________________8-80 MbeSettings.lineStyle ______________________________________8-74 MbeSettings.axisAngle _____________________________________8-68 MbeSettings.point _________________________________________8-77 MbeSettings.getScale_______________________________________8-78 MbeSettings.lineTerminator _________________________________8-74 MbeSettings.cell___________________________________________8-69 MbeSettings.depthLock_____________________________________8-83 MbeSettings.fontName _____________________________________8-72 MbeSettings.capMode______________________________________8-69 MbeSettings.textJustification ________________________________8-80 MbeSettings.angle _________________________________________8-67 MbeSettings.patternAngle1__________________________________8-75 MbeSettings.axisLock ______________________________________8-82 MbeSettings.patternCell ____________________________________8-76 MbeSettings.lineStyleName _________________________________8-74 MbeSettings.setScale _______________________________________8-78 MbeSettings.axisOrigin _____________________________________8-68 MbeSettings.weight ________________________________________8-81 MbeSettings.getPatternDelta ________________________________8-77 MbeSettings.textWidth _____________________________________8-79 MbeSettings.terminatorScale ________________________________8-79 MbeSettings.currentGraphicGroup ___________________________8-71 MbeSettings.areaMode _____________________________________8-68 MbeSettings.cellStretchLock _________________________________8-82 MbeSettings.boresiteLock___________________________________8-82 MbeSettings.gridUnits ______________________________________8-73 MbeSettings.colorName ____________________________________8-70 MbeSettings.setPatternDelta_________________________________8-76 MbeSettings.fillColor _______________________________________8-71 MbeSettings.textHeight _____________________________________8-79 MbeSettings.patternAngle2__________________________________8-75 MbeSettings.Table Of Contents: MicroStation Extensions to BASIC Settings Object _______________________________________________8-66 MbeSettings.font __________________________________________8-72 MbeSettings.nodeJustification _______________________________8-75 MbeSettings.color _________________________________________8-70 MbeSettings.constructionPlaneLock __________________________8-83 MbeSettings.fillMode_______________________________________8-71 MbeSettings.tagIncrement __________________________________8-78 MbeSettings.class__________________________________________8-69 MbeSettings.associationLock ________________________________8-81 MbeSettings.patternScale ___________________________________8-77 MbeSettings.graphGroupLock _______________________________8-83 xiv MicroStation BASIC Guide .textLineSpacing ________________________________8-80 MbeSettings.

dgnUnits _____________________________ 8-95 MbeCurrentTransform.pointToUors__________________________ 8-98 MbeCurrentTransform.textNodeLock _________________________________ 8-86 MbeSettings.cellFileName _________________________________ 8-91 MbeDgnInfo.active __________________________________________ 8-100 MbeView.dgn3D _______________________________________ 8-88 MbeDgnInfo.moveOrigin __________________________ 8-96 MbeCurrentTransform.endOfFile ____________________________________ 8-88 MbeDgnInfo.fromView ____________________________ 8-97 MbeCurrentTransform.snapLock _____________________________________ 8-86 MbeSettings.pattern _________________________________________ 8-102 MbeView.lineWeight ______________________________________ 8-102 MbeView.subPerMaster _________________________________ 8-90 MbeDgnInfo.screenNum______________________________________ 8-101 MbeView.fenceOverlap__________________________________ 8-84 MbeSettings.getGlobalOrigin _______________________________ 8-90 MbeDgnInfo.fastCurve _______________________________________ 8-101 MbeView.nextGraphicGroup ____________________________ 8-91 MbeDgnInfo.scalarToUors _________________________ 8-97 MbeCurrentTransform.rotate________________________________ 8-96 MbeCurrentTransform.masterUnits __________________________ 8-93 MbeCurrentTransform.gridLock______________________________________ 8-84 MbeSettings.levelLock _____________________________________ 8-85 MbeSettings.graphicGroup_________________________________ 8-90 MbeDgnInfo.selectionSetLock _______________________________ 8-85 MbeSettings.cellFileReadOnly ______________________________ 8-92 Current Transformation Object _________________________________ 8-93 MbeCurrentTransform.fenceVoid ____________________________________ 8-85 MbeSettings.settingErr _____________________________________ 8-86 Design File Information Object ________________________________ 8-87 MbeDgnInfo.uorPerSub____________________________________ 8-89 MbeDgnInfo.scale ________________________________ 8-97 MbeCurrentTransform.dgnFileReadOnly______________________________ 8-88 MbeDgnInfo.slowFont _______________________________________ 8-102 MbeView.subUnitName _________________________________ 8-89 MbeDgnInfo.cell3D _______________________________________ 8-91 MbeDgnInfo.fenceClip _____________________________________ 8-84 MbeSettings.masterUnitName ______________________________ 8-88 MbeDgnInfo.noText _________________________________________ 8-101 MbeView.Table Of Contents: MicroStation Extensions to BASIC MbeSettings.pointFromUors _______________________ 8-98 View Object ________________________________________________ 8-99 MbeViews(index) _________________________________________ 8-99 MbeView.textNode _______________________________________ 8-103 MicroStation BASIC Guide xv .scalarFromUors _______________________ 8-98 MbeCurrentTransform.dgnFileName _________________________________ 8-87 MbeDgnInfo.moveOriginWorld _____________________ 8-96 MbeCurrentTransform.

levelsOn.msVersion _____________________________________8-117 MbeSession.areaFill__________________________________________8-105 MbeView.active _________________________________________8-109 MbeRefFile.levelsOff ____________________8-114 MbeRefFile.deferApply ______________________________________8-105 MbeView.elapsedTime ___________________________________8-119 C Expression Statements ______________________________________8-120 MbeCExpressionLong ______________________________________8-120 MbeCExpressionDouble____________________________________8-120 MbeCExpressionString _____________________________________8-121 CAD Input Operations ________________________________________8-123 MbeGetInput _____________________________________________8-124 MbePoint ________________________________________________8-125 MbeSendAppMessage______________________________________8-125 xvi MicroStation BASIC Guide .canSwapScreen ________________________________8-119 MbeSession.msProduct _____________________________________8-116 MbeSession.attachName ____________________________________8-112 MbeRefFile.scaleLineStyle __________________________________8-111 MbeRefFile.update __________________________________________8-106 MbeView. MbeView.levelSymbology __________________________________8-103 MbeView.getLevels ________________________________________8-106 MbeView.refBoundary _____________________________________8-105 MbeView.locate _________________________________________8-110 MbeRefFile.language ______________________________________8-118 MbeSession.fileName_______________________________________8-112 MbeRefFile.enterDataField ___________________________________8-103 MbeView. MbeRefFile.display ________________________________________8-110 MbeRefFile.numScreens ___________________________________8-118 MbeSession.levelsOff _______________________8-107 Reference File Object _________________________________________8-108 MbeRefFiles.msPlatform ____________________________________8-117 MbeSession.snap __________________________________________8-111 MbeRefFile.saveSettings ____________________________________8-115 Session Object _______________________________________________8-116 MbeSession.levelsOn.fastRefClip_______________________________________8-105 MbeView.dimension _______________________________________8-104 MbeView.grid ____________________________________________8-103 MbeView.logical_________________________________________8-113 MbeRefFile.plot ___________________________________________8-111 MbeRefFile.construction _____________________________________8-104 MbeView.notFound ______________________________________8-110 MbeRefFile.scale __________________________________________8-113 MbeRefFile.Table Of Contents: MicroStation Extensions to BASIC MbeView.getLevels ______________________________________8-114 MbeRefFile.maxRefFiles ___________________________________8-109 MbeRefFiles(index) ________________________________________8-109 MbeRefFile.description _____________________________________8-113 MbeRefFile.

MbeFileCreate _______________________________ 8-145 MbeMessageBox _________________________________________ 8-146 MbeInputBox ____________________________________________ 8-147 MbeSelectBox ____________________________________________ 8-147 MbeOpenModalDialog ____________________________________ 8-148 MbeSqlda Object ____________________________________________ 8-150 MbeSqlda.value __________________________________________ 8-150 MbeSqlda.isNull __________________________________________ 8-151 MbeSqlda.type ___________________________________________ 8-151 MbeSqlda.name __________________________________________ 8-153 MbeTable.precision _______________________________________ 8-152 MbeSqlda.getIndex _______________________________________ 8-152 MbeTable Object ____________________________________________ 8-153 MbeTable.Table Of Contents: MicroStation Extensions to BASIC MbeSetAppVariable _______________________________________ 8-125 MbeSetScaledAppVar______________________________________ 8-126 MbeSendCommand _______________________________________ 8-127 MbeSendDataPoint________________________________________ 8-127 MbeSendDragPoints_______________________________________ 8-128 MbeSendLastInput ________________________________________ 8-129 MbeSendKeyin ___________________________________________ 8-129 MbeSendReset ___________________________________________ 8-129 MbeSendTentPoint________________________________________ 8-129 MbeWriteCommand_______________________________________ 8-130 MbeWriteError ___________________________________________ 8-130 MbeWriteMessage ________________________________________ 8-131 MbeWritePrompt _________________________________________ 8-131 MbeWriteStatus___________________________________________ 8-131 MbeRelocate _____________________________________________ 8-131 MbeStartLocate ___________________________________________ 8-132 Example of element location techniques _____________________ 8-133 MbeLocateElement________________________________________ 8-139 MbeScalarFromString ______________________________________ 8-141 MbePointFromString ______________________________________ 8-141 MbeAngleFromString ______________________________________ 8-141 MbeStringFromScalar ______________________________________ 8-142 MbeStringFromPoint ______________________________________ 8-142 MbeStringFromAngle ______________________________________ 8-143 MbeGetConfigVar_________________________________________ 8-143 MbeFindFile _____________________________________________ 8-143 MbeStartDefaultCommand _________________________________ 8-144 Dialog Box Statements _______________________________________ 8-145 MbeFileOpen.scale ___________________________________________ 8-152 MbeSqlda.criteria _________________________________________ 8-153 MicroStation BASIC Guide xvii .numColumns ___________________________________ 8-150 MbeSqlda.column ________________________________________ 8-150 MbeSqlda.length__________________________________________ 8-151 MbeSqlda.

entityNumber____________________________________8-154 MbeTable.editActiveEntity _______________________________8-164 MbeDatabase.largestMslink ____________________________________8-154 MbeTable.fenceFilter ______________________________________8-155 MbeTable.linkType _________________________________8-170 MbeDatabaseLink.describe ________________________________________8-156 MbeTable.reportOpen __________________________________8-167 MbeDatabase.modeLinkage _________________________________8-166 MbeDatabase.modeCommit_________________________________8-165 MbeDatabase.connect______________________________________8-163 MbeDatabase.reportTable _____________________________________8-155 MbeTable.create __________________________________________8-159 MbeTable.Table Of Contents: MicroStation Extensions to BASIC MbeTable.activeReview ____________________________________8-154 MbeTable.modeConfirm ________________________________8-165 MbeDatabase.linkClass _________________________________8-170 MbeDatabaseLink.activeEntity __________________________________8-162 MbeDatabase.recordDelete ____________________________________8-159 MbeTable.name________________________________________8-161 MbeDatabase.defineActiveEntity _____________________________8-164 MbeDatabase.linkSize __________________________________8-170 MbeDatabaseLink.reportClose __________________________________8-167 MbeDatabaseLink Object ______________________________________8-168 MbeDatabaseLink.dAType______________________________________8-167 MbeDatabase.disconnect ___________________________________8-163 MbeDatabase.isUserLink ________________________________8-170 MbeDatabaseLink.tableName _______________________________8-171 xviii MicroStation BASIC Guide .mslink ___________________________________8-171 MbeDatabaseLink.entityNumber _____________________________8-169 MbeDatabaseLink.showActiveEntity______________________________8-164 MbeDatabase.recordInsert _____________________________________8-158 MbeTable.modeForms __________________________________8-166 MbeDatabase.modeDelete __________________________________8-165 MbeDatabase.isModified________________________________8-169 MbeDatabaseLink.mslink_______________________________________8-162 MbeDatabase.isRemote _________________________________8-169 MbeDatabaseLink.recordLast_______________________________________8-157 MbeTable.recordFirst ______________________________________8-156 MbeTable.describe _____________________________________8-163 MbeDatabase.recordUpdate____________________________________8-158 MbeTable.drop ___________________________________________8-160 MbeDatabase Object __________________________________________8-161 MbeDatabase.recordNext ______________________________________8-157 MbeTable.copy ___________________________________________8-159 MbeTable.dAType __________________________________8-169 MbeDatabaseLink.isInformation _____________________________8-169 MbeDatabaseLink.errorText ____________________________________8-162 MbeDatabase.

getGroup___________________________________ 8-173 MbeDgnLevels.addLevel __________________________________ 8-180 MbeNamedLevel Object _______________________________________ 8-181 MbeNamedLevel.add ___________________________________________ 8-188 MbeTagSet.levelNumber ______________________________ 8-181 MbeNamedLevel.freeLevels __________________________________ 8-174 MbeDgnLevels.numNamedLevels ___________________________ 8-173 MbeDgnLevels.groupName _______________________________ 8-177 MbeLevelGroup.addGroup _________________________________ 8-180 MbeLevelGroup.loadLevelsFromFile __________________________ 8-174 MbeDgnLevels.getLevelMask ______________________________ 8-179 MbeLevelGroup.getTagDefNames _______________________________ 8-187 MbeTagSet.Table Of Contents: MicroStation Extensions to BASIC MbeDgnLevels Object ________________________________________ 8-172 MbeDgnLevels.getParentGroup ____________________________ 8-179 MbeLevelGroup.saveLevelsToFile ____________________________ 8-175 MbeDgnLevels.getDescendentLevels________________________ 8-178 MbeLevelGroup.levelName ________________________________ 8-181 MbeNamedLevel.name _________________________________________ 8-186 MbeTagSet.getLevelMask _____________________________ 8-182 MbeNamedLevel.generateReport _________________________________ 8-189 MicroStation BASIC Guide xix .freeAll _____________________________________ 8-174 MbeDgnLevels.levelComment_____________________________ 8-182 MbeNamedLevel.getLevels__________________________________ 8-177 MbeLevelGroup.getParentGroup ___________________________ 8-182 MbeNamedLevel.getLevel____________________________________ 8-173 MbeDgnLevels.freeGroups _________________________________ 8-173 MbeDgnLevels.deleteLevel _______________________________ 8-183 Tag BASIC Extensions ________________________________________ 8-184 MbeNumberOfTagSets_____________________________________ 8-184 MbeGetTagSetNames______________________________________ 8-184 MbeTagSet Object ___________________________________________ 8-186 MbeTagSet.numTagDefs ___________________________________ 8-187 MbeTagSet.delete _________________________________________ 8-188 MbeTagSet.deleteGroup _______________________________ 8-180 MbeLevelGroup.reportName ____________________________________ 8-186 MbeTagSet.update ________________________________________ 8-188 MbeTagSet.fileNum _______________________________________ 8-187 MbeTagSet.numGroups ________________________________ 8-172 MbeDgnLevels.saveGroupsToFile ___________________________ 8-175 MbeDgnLevels.getTagDef _____________________________________ 8-189 MbeTagSet.getDescendentGroups ______________________ 8-178 MbeLevelGroup.saveAllToFile _______________________________ 8-176 MbeLevelGroup Object _______________________________________ 8-177 MbeLevelGroup.rootGroup__________________________________ 8-172 MbeDgnLevels.loadGroupsFromFile _________________________ 8-174 MbeDgnLevels.loadAllFromFile _____________________________ 8-175 MbeDgnLevels.

deleteInstances_________________________________ MbeTagDef Object ___________________________________________ MbeTagDef.prompt _______________________________________ MbeTagDef. GbeTLayerLine.getTaggedElement ________________________________ MbeTag. GbeTLayerMixed.getMbeElement ___________________________________ MbeTag.Table of Contents: MicroStation Extensions to BASIC MbeTagSet. GbeTLayerMixed. GbeTLayerMixed.holes. GbeTLayerLine.sqlStatement.holes _________ GbeTLayerPoint. GbeTLayerPolygon.update _______________________________________ MbeTagDef.sqlStatement __________________________ GbeTLayerPoint.shapesAsAreas.isConstant ____________________________________ MbeTagDef.tagType ______________________________________ MbeTagDef.delete ________________________________________ MbeTag Object ______________________________________________ MbeTag.name____________________________________________ MbeTag.fileNum _________________________________________ MbeTag.add __________________________________________ MbeTagDef.setName ______________________________________ MbeTagDef.name _________ GbeTLayerPoint.sqlStatement.getTextElement ___________________________________ MbeMacro Object ____________________________________________ MbeMacro.name ________________________________________ MbeTagDef.name.suspend _______________________________________ Topology Objects ____________________________________________ GbeTLayerPoint.queryList.version __________________________________________ MbeTag.setName _________________________________________ MbeTag. GbeTLayerPolygon.name.holes.defaultValue __________________________________ MbeTagDef.sqlStatement.typeGbeTLayerMixed.holes.style _________________________________________ MbeTagDef.size _____________________________________________ MbeTag.getOffset_________________________________________ MbeTag. GbeTLayerLine. GbeTLayerMixed.isHidden _____________________________________ MbeTagDef.name.isHidden_________________________________________ MbeTag. GbeTLayerLine.setOffset _________________________________________ MbeTag.type.shapesAsAreas.targetId__________________________________________ MbeTag.value____________________________________________ MbeTag. GbeTLayerPolygon.tagId _________________________________________ MbeTagDef.queryList.shapesAsAreas. 8-190 8-191 8-191 8-192 8-192 8-192 8-193 8-193 8-194 8-194 8-194 8-195 8-195 8-196 8-197 8-197 8-198 8-198 8-198 8-199 8-199 8-199 8-200 8-200 8-200 8-201 8-201 8-201 8-202 8-202 8-203 8-203 8-204 8-205 8-205 8-205 8-206 8-206 xx MicroStation BASIC Guide .type.id_______________________________________________ MbeTag. GbeTLayerLine. GbeTLayerPolygon.type_____________________________________________ MbeTag.queryList ___ GbeTLayerPoint. GbeTLayerLine.queryList.type ____________ GbeTLayerPoint. GbeTLayerPolygon. GbeTLayerPolygon.

linePolyOverlay_____________________________ GbeTLayerPolygon Object ____________________________________ GbeTLayerPolygon.level ______________________________________ GbeTLayerLine.pointPolyOverlay __________________________ GbeTLayerLine Object ________________________________________ GbeTLayerLine.pointPolyOverlay ________________________ GbeTLayerPolygon.cellLibrary ___________________________________ GbeCategory. GbeTLayerPolygon.color _____________________________________ GbeTLayerPoint. GbeTLayerLine.detachMaps __________________________________ GbeCategory.color ______________________________________ GbeTLayerLine.listMapsByMslink _____________________________ GbeCategory.display.display_______ GbeTLayerPoint Object _______________________________________ GbeTLayerPoint.polyPolyOverlay_________________________ GbeTLayerPolygon.linePolyOverlay _________________________ GbeTLayerMixed Object ______________________________________ GbeTLayerMixed.fileExt_______________________________________ GbeCategory.style ___________________________________ GbeTLayerPolygon.shapesAsAreas ________________________ GbeTLayerPoint.add ____________ GbeTLayerPoint. GbeTLayerMixed.add.indexFromMslink ____________________________ GbeCategory.load.display.nodeType _________________________________ GbeTLayerPoint.listByMslink ________________________________ GbeCategories(index) _____________________________________ GbeCategories.Table of Contents: MicroStation Extensions to BASIC GbeTLayerMixed.fillColor ________________________________ GbeTLayerPolygon.weight ____________________________________ GbeTLayerLine.add.level _____________________________________ GbeTLayerPoint. GbeTLayerLine.maxCategories ______________________________ GbeCategories. GbeTLayerLine.listFeaturesByMslink___________________________ GbeCategory. GbeTLayerMixed.add.color __________________________________ GbeTLayerPolygon. GbeTLayerMixed.style ______________________________________ GbeTLayerLine.attachMaps __________________________________ GbeCategory.load ___________ GbeTLayerPoint.mslink ______________________________________ GbeCategory.weight _________________________________ GbeTLayerPolygon. GbeTLayerPolygon.load.load.display.doFill __________________________________ GbeTLayerPolygon.pointPolyOverlay__________________________ GbeTLayerMixed. GbeTLayerPolygon.level ___________________________________ GbeTLayerPolygon.name _______________________________________ 8-206 8-206 8-207 8-207 8-208 8-208 8-208 8-208 8-208 8-209 8-210 8-210 8-210 8-210 8-210 8-210 8-212 8-212 8-212 8-212 8-212 8-213 8-213 8-213 8-213 8-214 8-215 8-215 8-215 8-216 8-217 8-217 8-217 8-218 8-218 8-218 8-218 8-218 8-219 8-219 8-219 8-219 8-219 MicroStation BASIC Guide xxi .linePolyOverlay ___________________________ Topology Error Codes_____________________________________ Category Object _____________________________________________ GbeCategories.weight____________________________________ GbeTLayerPoint.

DBconnect ____________________________________ GbeProject.weight _______________________________________ Feature Error Codes ______________________________________ Map Object _________________________________________________ GbeMaps.isAttached _______________________________________ GbeMap.maxMaps _______________________________________ GbeMaps.Table of Contents: MicroStation Extensions to BASIC Category Error Codes _____________________________________ Feature Object ______________________________________________ GbeFeatures.mslink _______________________________________ GbeFeature.indexFromMslink ________________________________ GbeMap.display _______________________________________ GbeFeature.level _________________________________________ GbeFeature.categoryMslink ________________________________ GbeFeature.categoryMslink ___________________________________ Map Error Codes _________________________________________ Project Object _______________________________________________ GbeProject.directory ______________________________________ GbeProject.description ______________________________________ GbeMap.name ___________________________________________ GbeMap.attachByView ___________________________________ GbeMaps(index) _________________________________________ GbeMaps.directory ________________________________________ GbeMap.close _________________________________________ Project Error Codes _______________________________________ 8-220 8-221 8-221 8-221 8-222 8-222 8-222 8-222 8-222 8-223 8-223 8-223 8-223 8-223 8-223 8-224 8-224 8-225 8-225 8-225 8-226 8-226 8-226 8-226 8-226 8-227 8-227 8-227 8-227 8-227 8-227 8-228 8-229 8-229 8-229 8-229 8-230 8-230 8-230 8-230 8-230 8-230 8-231 8-231 xxii MicroStation BASIC Guide .style _________________________________________ GbeFeature.mapManager___________________________________ GbeProject.listByMslink __________________________________ GbeFeatures(index)_______________________________________ GbeFeatures.attach ___________________________________________ GbeMap.indexFromMslink _____________________________ GbeFeature.maxFeatures__________________________________ GbeFeatures.loginName ____________________________________ GbeProject.workMap______________________________________ GbeProject.detach __________________________________________ GbeMap.exportFile _____________________________________ GbeProject.listByMslink_____________________________________ GbeMaps.type _________________________________________ GbeFeature.keyMap _______________________________________ GbeProject.open _________________________________________ GbeProject.color _________________________________________ GbeFeature.DBload _______________________________________ GbeProject.description____________________________________ GbeFeature.mslink __________________________________________ GbeMap.name ________________________________________ GbeFeature.

Table of Contents: Error Codes 9. Error Codes Runtime Error Messages _______________________________________ Visual Basic Compatible Error Messages _____________________ MicroStation Error Messages________________________________ Compiler Error Messages ______________________________________ Run-time error codes _________________________________________ Topology Error Codes ________________________________________ Category Error Codes _________________________________________ Feature Error Codes __________________________________________ Map Error Codes _____________________________________________ Project Error Codes ___________________________________________ 9-1 9-2 9-4 9-5 9-8 9-8 9-9 9-9 9-10 9-10 A-2 A-2 A-3 A-3 A-4 A-6 A-7 A-9 Appendix: OLE Automation Differences Between MicroStation BASIC and OLE Automation______ The Application object ____________________________________ MicroStation-defined constants _____________________________ Dim statements __________________________________________ MicroStation-defined “User-Defined Types” ___________________ MicroStation Application methods ______________________________ OLE Automation-specific methods and objects ________________ Examples________________________________________________ Appendix: MicroStation BASIC Constants MicroStation BASIC Guide xxiii .

Table of Contents: MicroStation BASIC Constants xxiv MicroStation BASIC Guide .

Part I: Concepts and Procedures .

.

MicroStation has a built-in macro generator that allows users to write macro prototypes by recording the task as it is MicroStation BASIC Guide 1-1 . Several sample macros are supplied with MicroStation. Creating Macros Writing macros for MicroStation was designed to be as simple as possible. In its simplest form. the macro facility capitalizes on your knowledge about the MicroStation interface. usually short sequences of operations. a macro “drives” MicroStation in much the same way a human user does. using many of the tools documented in this guide. Subject to these limitations. Third. and more. Some of the MicroStation BASIC extensions documented cannot be used to develop macros for some products. In this way. First. For example. such as MicroStation PowerDraft and MicroStation PowerScope. The obvious advantage of writing a macro to perform a task that could otherwise be done manually is automating mechanical and repetitive tasks. send key-ins. we chose the BASIC language because of its ease-of-use and rich functionality. references in this guide to “MicroStation” also apply to MicroStation-based products. manipulate dialog boxes. All BASIC language extensions are easily recognized by their Mbe prefix. we extended the BASIC language to include many statements that closely resemble familiar MicroStation commands and actions.1 Introduction to Macros Macros are BASIC programs that automate often-used. modify elements. Many MicroStation-specific extensions have been added to the BASIC language to customize it for the MicroStation environment. Macros select tools and view controls. the macro command MbeSendDataPoint sends a data point to MicroStation. Second. since those products do not have the same functionality as MicroStation 95 and other Bentley engineering products. ✍ This guide covers the entire functionality of MicroStation BASIC.

many other BASIC language extensions are available in MicroStation. and making the program more interactive. Making the program more interactive An additional level of flexibility can be gained with a macro by querying the user for additional information during its execution. use MicroStation’s Macro Generator to generate a rough prototype of the program. At this point. For example. Running the macro generator In most cases. resets. Guidelines for creating a macro Creating a macro involves running the macro generator. adding BASIC language constructs. edit the program to take advantage of the features of the BASIC language to make the macro more useful. instead of always playing back a macro with the 1-2 MicroStation BASIC Guide . execute the task manually with the macro generator running and then review the generated macro program. Adding BASIC language constructs The newly generated macro consists almost entirely of MicroStation BASIC language extensions because MicroStation activity cannot be expressed in terms of standard BASIC.Creating Macros manually performed. the macro writer may wish to make the program more useful by replacing hard-coded coordinates with BASIC variables or adding looping commands so the task can be performed multiple times. This feature also serves as a learning aid for macro writing. and then stop the macro generator. etc. Afterwards. These include commands to interactively accept CAD input (data points. like elements and current session information. There are also “object” extensions representing different types of data in MicroStation. The combination of standard BASIC language functionality and all MicroStation extensions makes for a rich programming environment. a small macro program reflects the actions performed during the generation. In general. Start the macro generator.) ✍ For more flexible and powerful macro programming.) as well as display standard and custom dialogs to collect additional information during the execution of a macro. perform the general task to be echoed by the macro. (To learn how to write a macro that performs a particular MicroStation task.

• Element Set Object Extensions — MbeElementSet extension simplifies processing of multiple MbeElement elements selected by the user with either a selection set or fence. Many extensions to the BASIC language have been provided to answer this need. such as the File Open and File Create dialogs. Here is an overview of the different types of BASIC programming extensions available: • Element Object Extensions — MbeElement organizes design file elements into objects with sets of properties and functions. the MicroStation graphics environment is presented to a macro programmer in the form of well developed objects with properties and methods. into a system object with property and method extensions.Creating Macros fixed coordinates of its original generation. MicroStation BASIC Guide 1-3 Introduction to Macros 1 . • Element Location Extensions — Allow you to generate element selection/location information for one or more elements and feed this information into standard MicroStation tools. • State Object Extensions — An MbeState object is used to encapsulate information about the current state of MicroStation. you will need access to detailed information about the graphics environment while writing a macro. are also available. Several utility dialogs are available as extensions to the macro language for this purpose. such as active settings and locks. A macro using these objects can manipulate elements without knowing all the details of element formats. the macro could ask the user to enter a data point interactively. Advanced macro programming In many cases. • Design File Information Object Extensions — MbeDgnInfo organizes design file information into properties and methods of the current design file. • Settings Object Extensions — MbeSettings organizes overall session information. Some standard dialogs in MicroStation. Such dialogs are designed using the BASIC Editor window. Custom dialogs can also be displayed by macros to collect more specialized information. It may also be necessary for the macro to collect more general information such as string. or floating point values. Where possible. This organization makes data management easier and isolates the macro writer from file update logic. integer. This is accomplished using the MbeGetInput extension.

✍ It is possible to provide command line arguments to the macro from the Key-in window. • Reference File Object Extensions — Reference file attributes such as file name. scale and many others are encapsulated in MbeRefFile objects. 1-4 MicroStation BASIC Guide . through the Command$ BASIC statement. if any. The macro accesses these arguments. description. “What input is available from the user?” and “What were the results of the last command sequenced by my macro?”.Creating Macros For example. • Design View Information Object Extensions — An array of MbeView objects is provided as a way of reading and writing MicroStation design view information.

argn] MbeSendKeyin “<macro_name> [arg1 arg2 . key in: MACRO <macro_name> [arg1 arg2 . choose Macros. OR 1. Key in or select the desired macro. Click the Run button... 3. In the Macro Name list box. Click the Browse button. From the Utilities menu.Running Macros Running Macros You can load and run a macro using the Macros settings box or a key-in. Macros settings box 2. choose Macros. argn]” MicroStation BASIC Guide 1-5 Introduction to Macros ➤ To load and run a macro 1 . The Start Macro dialog box opens. select the macro. The Macros settings box opens. and click the OK button.. 1. From the Utilities menu. 2.. Click the Run button. The Select Macro dialog box opens. OR x In the Key-in window. The Macros settings box opens. 4. 3.

3. Click the Play button to resume generating the macro. The macro begins and a small dialog box opens. Key in the name and description of the macro to be generated. ➤ To generate a macro 1. your actions are captured and written to the macro. Click the OK button to start the macro generation session. Create Macro dialog box 2. Pause — When this button is clicked your actions are not written to the macro. and End (right) 4. 1-6 MicroStation BASIC Guide . Generating macros Create Macro is used to generate a macro based on your actions in MicroStation. From the Utilities menu. Pause (middle). select Create Macro … The Create Macro dialog box opens. Play (left). When the dialog box is initially displayed. Dialog box with controls for macro session. You can also use the Customize dialog box to create a tool or menu item that runs a macro. Control your macro session by choosing the dialog buttons as follows: Play — When this button is clicked. Pausing is useful when actions should not be captured before the macro is finished.Creating and Managing Macros Creating and Managing Macros You can create and manage your macros using the Create Macro dialog box and the Macros dialog box. the Play button is automatically selected.

. Click the Edit… button. BASIC Editor The BASIC Editor window is used to display. The Macros dialog box opens. 2. edit. From the Utilities menu. Select a macro name from the list box. The Macros settings box is used to display a list of available macros and optionally to run.Creating and Managing Macros End — Clicking this button has the same effect as choosing End Macro from the Utilities menu: the dialog box closes. choose Macros. or debug a given macro. argn] MicroStation BASIC Guide 1-7 Introduction to Macros Managing macros 1 . ➤ To open the BASIC Editor window 1. OR x Key in: macro debug <macroname> [arg1 arg2 . edit and debug macros. 3..

. stepping into macro subroutines. 1-8 MicroStation BASIC Guide . BASIC Editor window The large multiline text field is a limited functionality ASCII editor. If no extension is given.bas extension. viewing and changing the values of variables. Adding macros to MicroStation’s user interface The Customize dialog box (Workspace menu/Customize) is used to customize MicroStation’s graphical user-interface. argn] where macroname can have either the .. running the macro to completion and stopping the debugger.where macroname can have either no extension or a .bas is assumed. The key-in to run a macro is: macro debug <macroname> [arg1 arg2 . macro key-ins can be assigned to icons for starting macros with a single click. The icons above this edit window allow for single stepping through macro commands.ba or . Since any key-in may be assigned to a customized tool box icon.bas extension.. setting breakpoints.

Creating and Managing Macros MicroStation BASIC Guide 1-9 Introduction to Macros 1 .

Creating and Managing Macros 1-10 MicroStation BASIC Guide .

A selection set is one example of a pre-condition. generate the original prototype with similar starting conditions. resuming. Starting conditions In some cases. and Debugging Macros Planning. the first step in writing a macro is to generate a prototype program with the macro generator.2 Prototyping. step. a location other than the default macro directory where the generated macro file will be stored. or series of commands. that duplicate the actions. editing. Other examples of preconditions are: the presence on the screen of a particular view window or dialog box or activation of a particular design file. The Create Macro dialog box The Create Macro dialog box is used to supply three pieces of information about the new macro: the macro name. prototyping. and stopping the macro generator. MicroStation BASIC Guide 2-1 . Prototyping Usually. often continuous. you may make changes to this plan during the editing and debugging phases. A small dialog appears on the screen containing three buttons. This is a control dialog for the macro generator. used for pausing. So. If this case. A user can “sketch” a rough program by manually performing the task while the macro generator translates the actions into a series of macro commands. before starting the prototype session. and optionally. The macro generator “watches” user actions in MicroStation and tries to generate an approximate macro command. a description of the macro. you may design a macro program that operates on selection sets and expects a selection set to exist before the macro starts. the generated macro program may require certain conditions before starting. For example. In that case. Even though you may carefully plan your macro. you may wish to “set the stage” for the macro. create a selection set that is representative of those to be operated on by the finished macro. and debugging a macro is usually performed in one large. Editing.

For the most part. the End Macro menu item is replaced by Create Macro. the user will typically go to the BASIC Editor window to shape the macro into final form. Before beginning our discussion of the BASIC Editor.. This description becomes part of the program in the form of a comment block. At this point. The second text field is labeled “Description”. Stopping the macro generator To stop the macro generator. Likewise.. The name of the macro has an 8 character limitation and is used as the base filename of the generated macro program. 2-2 MicroStation BASIC Guide . The remaining controls in the Create Macro dialog box are the OK and Cancel buttons. To save the macro in one of the alternate directories. the Create Macro dialog is dismissed and a small control dialog for the macro generator becomes active and “watches” for user actions to translate and save as macro statements. In some cases. the generation of the prototype macro program is finished and the control dialog is closed. when the macro generator is stopped. If OK is clicked. the entire session is ignored and the macro generator will not start. The Location option menu at the bottom of the Create Macro dialog is supplied for this reason. labeled “Name”.Prototyping The first text field in the dialog. If more directory names need to be added to the option menu. The user can enter a free-form description of the macro and the actions it performs. click the stop button in the control dialog or choose End Macro from the Utilities menu. menu item when the macro generator starts. If Cancel is clicked. This menu item replaces the Create Macro. however. you do not need to know that a macro program is stored as a file. you may wish to save the macro to an alternate location from the default directory. Once the macro generator is stopped. choose the appropriate directory from the option menu. This somewhat structured control over the location of macros is a deliberate measure to de-emphasize a macro’s location as a file and to instead focus attention on its name and description. assigns a name to the macro. let’s look at some commands that are commonly generated by the macro generator. you must change the MS_MACRO configuration variable to contain the new directory names. This option menu shows all the directory names listed in the MS_MACRO configuration variable. then display the Create Macro dialog again.

5% MbeSendCommand "PLACE BLOCK ICON" point.z = 268473.y = startPoint.z = startPoint.629900# startPoint.667900# Send a data point to the current command point.z + 6. 5% point.Prototyping The form of a prototype macro Here is an example of a prototype macro created by the macro generator.x = startPoint.393900# MbeSendDataPoint point.y = startPoint.023000# point. ' Place circle and block Sub main Dim startPoint As MbePoint Dim Point As MbePoint.x = 214704.728400# point.y + 3.z = startPoint.z = startPoint.y = startPoint.401300# MbeSendDataPoint point.4. the macro generator captured the placement of a circle and a block.y + 4.y point.006900# point.y = startPoint.6. In this example.z MbeSendDataPoint point. point2 As MbePoint ' Start a command MbeSendCommand “PLACE CIRCLE ICON” Coordinates are in master units startPoint.775400# point.345000# startPoint.z + 0.z = startPoint.y + 1.x point. 5% MbeSendReset End Sub ' ' MicroStation BASIC Guide 2-3 Prototyping.943600# point.x .8. 5% point.x = startPoint. and Debugging Macros 2 .z + 5.x = startPoint.x . Editing.x = startPoint.x .674700# point.y = 214775.908800# MbeSendDataPoint point.

some extensions take optional arguments which may. new BASIC language elements had to be added to the MicroStation BASIC interpreter. three unique extension calls were generated: MbeSendCommand. These new language elements will hereafter be referred to as “BASIC extensions” or just “extensions. The macro description. The first use of each extension is preceded by a comment describing its purpose. The macro generator will always generate one flat subroutine called main. Because the BASIC language was not designed for CAD environments. some extension functions have “overloaded” argument lists. Although the BASIC interpreter is not case-sensitive. users should review documentation for all MicroStation extensions. be used by the macro generator. meaning they can take different types of arguments depending on the goal.” To make the BASIC extensions for MicroStation easy to distinguish from standard BASIC.” In the example. BASIC extensions commonly used by the macro generator The following list highlights the extensions used by the macro generator to approximate the user’s actions in MicroStation: Command MbeSendCommand MbeSendDataPoint MbeSendTentPoint Used to Issues a MicroStation command Issues a data point Issues a tentative point 2-4 MicroStation BASIC Guide . Also. we follow one naming convention: all MicroStation BASIC extensions begin with the letters “Mbe. or may not. The subroutine is flat because it does not call any other subroutines. which appears first in the file.Prototyping The macro has two major parts. can be edited but must always appear at the top of the macro program. Some generated macros do not show all the ways extensions can be called. The remaining part of the macro is the program itself. Although a simple review of the program created by the macro generator is informative. parameters to functions are shown with datatype suffixes to be clear about the type of data being passed. MbeSendDataPoint and MbeSendReset. initial capitalization makes the extensions easier to read. For example. Also.

Editing. and Debugging Macros 2 . MbeSendAppMessage MicroStation BASIC Guide 2-5 Prototyping.Prototyping Command MbeSendReset MbeSendKeyin MbeSendDragPoints MbeSetAppVariable MbeSetScaledAppVar Used to Issues a Reset Sends a key-in string to MicroStation Simulates a drag of the pointing device Sets the state of a dialog box application variable Sets the state of a dialog box application variable. the values represent distances or coordinates in Master Units. Initiate an application-defined event.

choose Macros. The built-in editor provides debugging capabilities for testing changes during editing. Another option is to use MicroStation’s BASIC Editor window to edit Macros. Click the Edit button. select the macro to be edited. Since macro source files (. From the Utilities Menu. you can edit the macro to refine its behavior and extend its usefulness. you can edit them outside the MicroStation Macro graphics environment using any text editor then return to the MicroStation environment to run the macro. In the list box. 2-6 MicroStation BASIC Guide . or Click the Browse button and use the select Macro dialog box to select the Macro. ➤ To edit an existing macro 1.The BASIC Editor The BASIC Editor After generating a macro prototype. 3.bas extension) are text. Macros dialog box 2.

copy. Control horizontal scrolling by moving the pointer to the left or right. Editing.The BASIC Editor The BASIC Editor window opens. and Debugging Macros 2 . Text editing area and scrolling The text editing area is the large rectangle that spans most of the BASIC Editor window is resized. Horizontal scrolling is also supported. and paste operations are supported. Save the changes to disk. As the pointer moves MicroStation BASIC Guide 2-7 Prototyping. Make the desired edits. 5. Select multiple characters by dragging the cursor through text ranges and by performing keyboard navigation while holding down the <Shift> key. The standard cut. The editing area allows text strings to be entered and edited and supports vertical scrolling. 4. Press the <Return> key to enter a line break. you can open the BASIC Editor window by keying MACRO DEBUG <macroname>. users can increase or decrease the number of visible rows and columns in the editing area. ✍ As an alternate to steps 1-3. so is the editing area. Thus.

Stretch the width of the window to expand the field size. These fields are always synchronized with cursor movement. Open Displays the Open BASIC Source file dialog box to select a new macro file for editing. Status message field The status message field is a read-only. It is located directly beneath the text editing area on the left side of the window. either from a user key-in (for example. File menu New Discards the current macro file being edited and clears the text editing area. text field used to display debugger status messages. Save As… Allows the user to save the current text editing area contents to a new macro file name. the macro file currently being edited is discarded and the new macro file is loaded into the text editing area. MicroStation scrolls the text so the cursor remains in the editing area. The new (empty) buffer will be untitled. 2-8 MicroStation BASIC Guide . Line number and column number fields The line number and column number fields are read-only. Save Saves the text updates to the macro file on disk.The BASIC Editor out of the editing area. Use “Save As” before debugging the new macro. If a new macro file is already selected. text fields that show the macro program line and column numbers where the cursor is currently positioned. The Save Source To dialog box displays so that the user may choose the new macro file name. Up arrow or <Pg Dn>) or from a macro error during debugging.

the preceding operation cannot be undone. deleting the text from the text editor window afterwards. You can undo a series of operations by repeatedly choosing this option. Editing. Paste Copies text from the clipboard into the text editing area at the location of the cursor. Cut Copies the currently selected text in the text editing area to the clipboard. Find Next Searches for the next occurrence of the text you entered in the Find text dialog box. MicroStation BASIC Guide 2-9 Prototyping. It negates the undo. start the search by clicking the OK button. Type in the text to find. and Debugging Macros 2 . After you undo an operation. The existing text editing area contents remain intact. Find Opens the Find Text dialog box. enable the Match Case toggle button. the user is warned and given an opportunity to save the updates to the macro file at this time. Edit menu Undo Undo negates the last modification to the text by the user. Redo This is effective after an undo command has been executed. Then. changing the text to its original format before the undo took place. To make the search case-sensitive. Copy Copies the currently selected text in the text editing area to the clipboard. If the contents of the text editing area have been modified but not yet saved. MicroStation highlights the first match moving forward from the pointer position.The BASIC Editor Exit Causes the Macro Editor to be unloaded.

All custom dialogs created will be saved as resources in the compiled version of the macro (the. Custom Dialog > Insert… Displays a list of custom dialogs defined for the current macro. refer to the section “Working with variables” on page 2-12. The BASIC functions defined by program entry points provide customization for the final plot when standard pen tables are not sufficient. If the currently highlighted line is a subprocedure call. the debugger traces execution “down and into” the subprocedure then stops and highlights the first executable line in the subprocedure. For more on variables and the Variables window. Step Into Causes the debugger to execute the currently highlighted line in the macro. the debugger is stopped before the compilation starts. Break Causes a breakpoint to be toggled (set or reset) at the current line position in the text editing area indicated by the cursor position. Selecting an entry in the list enters a line of source code in the macro at the current cursor position: actionbutton = MbeOpenModalDialog (<chosen dialogId>) Program Entry Point Allows the programmer to designate BASIC functions to be called for use in the plotting process. Run menu Execute Compiles the current macro and runs it from the beginning. Custom Dialog > Edit… Opens the Builder dialog box. which is used to create custom dialog boxes.The BASIC Editor Variables Opens the Variables window.BA file). 2-10 MicroStation BASIC Guide . If the debugger is active when Execute is chosen.

Click Go Stop Toggle Breakpoint Step Into Step Over Edit Variables MicroStation BASIC Guide 2-11 Prototyping. If the currently highlighted line is a subprocedure call.The BASIC Editor Step Over Causes the debugger to execute the currently highlighted line in the macro. Execute one line of source without tracing execution into subroutines. Breakpoint information remains intact. Editing. Debugger icons The following icons appear at the top of the BASIC Editor window: To Continue execution of macro. Execute one line of source and trace execution into a subroutine if necessary. Opens the Variables dialog for viewing and modifying BASIC variables. Stop Debug Causes the debugger to abort the current debugging session for the macro. the debugger suspends the macro and highlights the current line. Go Causes the debugger to continue executing the macro from the current statement forward until completion or until a breakpoint is encountered. Halt execution of macro. If a breakpoint is encountered. Toggle a breakpoint. and Debugging Macros 2 . the debugger runs all statements in the subprocedure before stopping and highlighting the first executable line after the subprocedure call.

(See “Variable Scope” on page 3-9 for a discussion on public. the variables that are local to that subroutine are automatically added 2-12 MicroStation BASIC Guide . but constituent properties cannot be accessed. single (!) and double (#). members of userdefined types and arrays may also be viewed and changed.The BASIC Editor Working with variables Use the Variables window to view and change the values of BASIC variables of a macro running in the debugger. In addition. Objects defined by the macro are shown by name. private and local variables are color-coded for easy identification. the Variables window updates automatically to show all variables in use by the macro at each stage of your debugging session. To display the Variables. string ($). All simple BASIC data types are supported: integer (%).) Color is also used to highlight changed values of variables as the user steps through a macro in the debugger. private and local variables. Likewise. choose Edit > Variable or click the Edit Variable icon in the BASIC Editor window. As you step into a subroutine in the debugger. Variables window Public. the calling subroutine’s local variables go “out of scope” and therefore are automatically removed from the list. long integer (&). private and local variables As you step through a macro in the debugger. once the first executable statement in the new subroutine is highlighted. By default. updated values are displayed in red. Public.

Public and private variables always remain in the list while the macro is being debugged. and Debugging Macros 2 .The BASIC Editor to the list. Changing values You can change the value of a BASIC variable in the list if it is one of these data types: integer. single-precision floating point or double-precision floating point. string. Expanding and collapsing complex variables Expand user-defined types (UDT) and arrays to show their constituent members by double-clicking on the respective entry in the list. Change Variable Value dialog box MicroStation BASIC Guide 2-13 Prototyping. long integer. In the same manner. Double-click on the appropriate entry or press the <Return> key after the entry is highlighted. To expand a UDT or array from the keyboard. Change the value of one of these data types using a procedure identical to expanding or collapsing UDTs and arrays. then press the <Return> key. an expanded UDT or array can be collapsed down again by double-clicking on its entry in the list. Editing. use the cursor keys to highlight the entry in the list. The value displays for editing in the Change Variable Value dialog box.

The BASIC Editor 2-14 MicroStation BASIC Guide .

In fact. A single quote ( ' ) anywhere on a line indicates the beginning of a comment. refer to a BASIC reference book. how it does it. Example ' This is a comment beginning at the left edge of the screen. see “Macro Interactions With MicroStation” on page 4-1. and the underbar (_). digits 0 to 9. and for any other reason you choose. world!" ' The comment extends to the end of the line The entire line is treated as a comment when it begins with the Rem statement Example Rem Rem Both lines in this example are treated as comments. If you need more information about BASIC than provided here. MicroStation BASIC Guide 3-1 . Print "Hello. • Names must begin with an alphabetic character. must follow the same naming rules: • Names are composed of alphabetic characters. This chapter is intended as an overview of BASIC. The examples in this chapter will include comments to tell you more about them. and object properties. Naming Rules All names in macros. labels. such as the names of variables.3 Macro Language Overview The MicroStation macro language is BASIC with MicroStationspecific extensions. why it does it. For information about the macro language’s MicroStation-specific extensions. Comments You can put comments in a macro to explain what it does. procedures. the text you entered as the description when you created the macro is inserted as comments on the first lines of the macro.

Strings A string variable contains a group of ASCII characters. world!” or “Area = 20411. 2048. or -13. but the range of values is much larger. The following names are valid: Dim origin. cell_origin Dim viewNumber ' Names of variables ' Another variable name The following names are invalid: Dim 1view Dim point@start ' Names cannot begin with a digit. Built-in Data Types All variables and literal constants (hard-coded values) in a macro are associated with a specific data type.147.647.483. A string variable can hold up to 32.648 to 2. A string literal constant is a double quoted group of characters. Integer variables can contain positive or negative numbers in the range from -32768 to 32767. Long integers Long integers are like integers." The maximum number of characters in a string literal constant is 255. Capitalization is used only to make a macro easier to read. use two double quote characters.147.. Integers An integer is a whole number like 0. i. Long variables can contain whole numbers in the range from -2. Example Print "John said ""Hello"" to Jane and Mary.767 characters. ' Illegal character in the name. If double quotes are needed in the constant. 3-2 MicroStation BASIC Guide . the characters “Hello. point2.Built-in Data Types • Names cannot be longer than 40 characters.2 SQ FT”. • Names are not case-sensitive.e.483.

as for a single literal constant.402823E38. If the value is very large. Variable Declarations You specify.401298E-45 to 3. or very close to 0. it should be expressed using the same nnnnEeee format.797693134862315E308. If the value is very large. • Implicitly when the variable is used the first time by appending a type character to the name. or very close to 0.75.5 or -414.797693134862315E308 to -4.94066E-324 and positive values from 4. the data type of a variable in one of two ways: • Explicitly when the variable is dimensioned at the beginning of the macro or procedure. The double-precision float is formatted according to IEEE standards.401298E-45 and positive values from 1. or declare.94066E-324 to 1. A single literal constant is a number with a decimal point. very small. Doubles Double-precision floating point numbers are like single-precision floating point numbers. it should be expressed as nnnnEeee where nnnn is the mantissa and eee is the exponent. Single variables have seven significant digits and contain negative values from -3. Double variables have 15 significant digits and contain negative values from -1.Variable Declarations Singles A single-precision floating point value is a real number like 0. MicroStation BASIC Guide 3-3 Macro Language Overview 3 . A double literal constant is a number with a decimal point.402823E38 to -1. but more digits are significant and the ranges of possible values are much larger. The single-precision float is formatted according to IEEE standards. ✍ Declaring variables explicitly is recommended because it makes it easier for you to read and debug your macros. very small.

Declaring long variables Long integer variables are declared explicitly in a Dim statement by appending an As Long clause or by appending an ampersand (&) to the variable name. 3-4 MicroStation BASIC Guide . Longer or shorter groups of characters can be assigned to a string variable without losing characters or padding the value with spaces. Example Dim textBuffer As String Dim commandName$ ' Explicit string declarations String variables are declared implicitly by appending a dollar sign to the variable name the first time it is used. Example newLength& = elemLength + 10 ' Implicit declaration of newLength Declaring string variables String variables are declared explicitly in a Dim statement by appending an As String clause or by appending a dollar sign ($) to the variable name. Example title$ = "First Floor Plan" ' Implicit declaration of title String variables do not have a fixed length.Variable Declarations Declaring integer variables Integer variables are declared explicitly in a Dim (dimension) statement by appending an As Integer clause or by appending a percent sign (%) to the variable name. Example Dim count As Integer Dim viewNumber% ' Explicit integer declarations Integer variables are declared implicitly by appending a percent sign to the variable name the first time it is used. Example Dim filePosition As Long Dim elemLength& ' Explicit long integer declarations Long variables are declared implicitly by appending an ampersand to the variable name the first time is it used. it is an integer variable. Example previousView% = viewNumber ' Implicit declaration of previousView When a variable is used without being declared either explicitly or implicitly.

Arrays of Variables Declaring single variables Single-precision floating point variables are declared explicitly in a Dim statement by appending an As Single clause or by appending an exclamation point (!) to the variable name. ✍ Using double variables to store floating point values is recommended over using single variables. Example Dim scale As Double Dim origin# ' Explicit double declarations Double variables are declared implicitly by appending a pound sign to the variable name the first time it is used. and the elements of the array are contiguous. Calculations on doubles are faster than calculations on singles.. With arrays. Example ' Declare an array of 32 file names. Example Dim tempF As Single Dim fraction! ' Explicit single declarations Single variables are declared implicitly by appending an exclamation point to the variable name the first time it is used. you can refer to a series of variables by using a single name and then use a number (an index) to refer to a particular variable within the array. Indices are from 0 to 31 Dim refFiles(31) As String refFiles(0) = "city. message$ = "Reference File: " + refFiles(31) ' Use the last member MicroStation BASIC Guide 3-5 Macro Language Overview 3 Example tempC! = 5 * (tempF .dgn" ' Set the first member .32) / 9 ' Implicit declaration of tempC .. Arrays have both a lower and an upper bound. Declaring double variables Double-precision floating point variables are declared explicitly in a Dim statement by appending an As Double clause or by appending a pound sign (#) to the variable name. Example endPoint# = origin + origin / 2 ' Implicit declaration of endPoint Arrays of Variables An array is a group of related variables of the same data type.

Z coordinates of first vertex -0.0) vertex(0. Y. you must specify the index in each dimension.0 vertex(0. Only the upper bound in each dimension must be specified when declaring a fixed-length array.Next” on page 3-22. Example Option Base 1 .. The default lower bound is 0. Instead.Loop” on page 3-19 and “For. Example Dim referenceFile$(31) Dim vertex(1. The range for array bounds is from -32. last is (2..0) vertex(1. One or both of the bounds may be negative integers.1) vertex(0.5 1000.2) ✍ Array members are rarely set using literal constant indices as in the examples above.5 vertex(0.1) vertex(1. 1 3-6 MicroStation BASIC Guide .1) + 203. Example Dim viewFlags%(1 To 8) Dim points#(100. For more information see “Do.2) As Double ' Array of 32 character strings ' 2x3 array of doubles You can change the default lower bound to 1 by putting an Option Base 1 statement outside of any subroutines and functions. When you refer to a member of a multi-dimensional array.Arrays of Variables The array in the above example is a one dimensional array. arrays are often referenced within loops. Example Dim vertex#(1.2) vertex(1.767. Dim referenceFile$(32) ' Indices from 1 to 32 Dim vertex(2. You can also work with multi-dimensional arrays of up to 60 dimensions.0) ' Coordinates of second vertex vertex(0..1). -1 To 1) ' Explicitly set lower bound to 1 ' Second dimension indices are -1. ' Declaring the arrays when Option Base 1 is specified. Fixed-length arrays When the number of dimensions and the lower and upper bounds of each dimension are known ahead of time.0 ' X..2) vertex(0..3) You also can set the lower bound in an array dimension explicitly using the To keyword..768 to 32. 0. declare a fixed-length array with the Dim statement.3) As Double ' First member is (1.2) = = = = = = ' Declare 2x3 array of coordinates 0.

Example Dim attachedFiles() As String Dim points#() ' Number of attached files is unknown ' Number of points will change The dimensions of the array are defined at runtime by using the ReDim (redimension) statement. add the Preserve option to the ReDim statement. Example numRefFiles% = 10 ' 10 reference files are attached ReDim attachedFiles(1 To numRefFiles) numPoints% = 5 ' Shape is a pentagon ReDim points(numPoints. MicroStation BASIC Guide 3-7 Macro Language Overview 3 . Example Dim textBuffer$() ' Declare variable array of strings numLines% = 10 ' Start with 10 lines ReDim textBuffer(numLines) numLines = numLines + 10 ' Add 10 lines and preserve contents ReDim Preserve textBuffer(numLines) numLine = numLines . You may not change the number of array dimensions if you are preserving the contents of the array while resizing it. of a dimension. -1 To 1) You can change the size of an array with the ReDim statement many times when running a macro.Arrays of Variables Variable-length arrays When the number of dimensions or the bounds in a dimension are not known ahead of time or will change. The bounds are specified much as they are in the Dim statement. Declaring a variable-length array differs from declaring a fixed-length array in that you do not specify the array bounds. If the contents of the array should be saved when it is resized.5 ' Remove last 5 lines from textBuffer ReDim Preserve textBuffer(numLines) You can use the ArrayDims function to query the number of dimensions in an array and the LBound and UBound functions to find out the lower and upper bounds. respectively. declare a variablelength array with the Dim statement.

the pieces of information are grouped together and can be accessed through the same variable.User-defined Data Type Variables User-defined Data Type Variables A user-defined data type is a data structure. A field can also be a fixed-length array. represent related pieces of information and can be different data types. The general format is: Type username variable1 As type1 variable2 As type2 . Creating a user-defined data type A user-defined data type is created with a Type.End Type statement outside of all the subroutines and functions in the macro.. Example Type Point2d x As Double y As Double End Type ' Create a 2D point data type Example Type TableDescription title As String origin As Point2d extent As Point2d name(1 To 32) As String End Type ' Create a table description data type 3-8 MicroStation BASIC Guide . Each field in the user-defined data type is defined with a variable name and a corresponding data type.. or fields. that contains more than one variable. When you declare a variable of a userdefined data type. or record.. in the record.. variableN As typeN End Type The name of the user-defined data type is username. The variables. The data type of a field can be any builtin data type or a user-defined data type created earlier in the macro.

Example refFileTable.Variable Scope Declaring user-defined data type variables Once a user-defined data type is defined. Example Dim plotView As TableDescription Dim vertices(100) As Point2d ' Table description for reference files ' Array of 101 2D points (Option Base 0) User-defined type variables cannot be declared implicitly by appending a type definition character to the variable name the first time it is used. MicroStation BASIC Guide 3-9 3 .name(2) points(0). file table ' Add table size ' to origin ' Names of ' reference files refFileTable.name(2) = "details.0 refFileTable.x points(49).0 refFileTable.6 points(49).origin. extent As Point2d extent = origin ' Set the extent equal to the origin Dim origin As Point2d.dgn" refFileTable.y = 532.x = 0.name(1) = "border.x = points(0). block(4) As Point2d block(0) = block(4) ' Copy last point to first origin = block(0) ' Copy first point to origin Variable Scope The statement with which you declare a variable controls the parts of the macro in which the variable name is valid.extent.y + 16.0 points(0). Example Dim origin As Point2d.table = "Reference Files" ' Title for ref. variables of that type must be declared explicitly in a Dim statement by using the As type clause where type is the user-defined data type name.extent.x = refFileTable.origin.dgn" refFileTable. The contents of all fields of one variable are copied to the other.y = points(0).name(3) = refFileTable.x + 2.y = refFileTable.y / 2 ' Coordinates of the first point ' Coordinates of the 50th point You can assign user-defined data type variables of the same type to each other. Working with user-defined data type variables Macro Language Overview A field in a user-defined data type variable is accessed with the “dot” operator and is treated like any other variable of the same data type.

you will not be able to run the second macro. Public variables are a way for macros to share data. Declare public variables with the Public statement.Variable Scope Local variables Local variables. The syntax of the Private statement is like the Dim statement. 3-10 MicroStation BASIC Guide . Example Private designFile As String Private Private Private Private elementCount% lastPoint As Point2d pointBuffer(100) As Point2d elementList() As Long ' ' ' ' ' Declared with As <Type> clause Declared with type character User-defined data type variable Fixed-length array Variable-length array Public variables Public variables are recognized within all subroutines and functions in all the macros that are currently loaded. Private variables Private variables are recognized within all subroutines and functions within a macro and exist as long as the macro is executing. If two macros use the same variable name for public variables of different data types. Example Public designFile As String Public Public Public Public numberOfElements% acceptPoint As Point2d levelFlags(63) As Integer referenceNames$() ' ' ' ' ' Declared with As <Type> clause Declared with type character User-defined data type variable Fixed-length array Variable-length array Use public variables only if necessary. The syntax of the Public statement is like the Dim statement. but it must be placed before all the subroutines and functions in the macro. a new set of variables is created on each call. Private variables are a way for subroutines and functions to share data. are recognized only within the subroutine or function in which they are declared. either declared explicitly with the Dim statement or implicitly using a type character. but it must be placed before all the subroutines and functions in the macro. Declare private variables with the Private statement. Once the subroutine or function exits. the variables no longer exist and the names are not valid. If a subroutine or function is called recursively.

or the comparison of a string variable and the string returned by a function procedure. You can freely assign numeric values to numeric variables without explicitly converting the data type. an overflow error will occur at runtime if the numeric value is larger than can be represented by the data type of the variable. Expressions An expression is any combination of literal constants and variables.Initial Variable Values Initial Variable Values All declared numeric variables are given an initial value of 0. its value cannot be changed. All declared string variables are initialized with the empty string (“”). functions. are meaningless. in and of themselves. and operators that can be evaluated. If the same constants appear over and over and are difficult to remember or. with the Const statement.” a complicated mathematical formula. These statements must be placed outside of all the subroutines and functions in the macro. An expression can be a simple “3. MicroStation BASIC Guide 3-11 Macro Language Overview 3 . on the left. Symbolic Constants Your macro may contain many literal constants. the variable. Example Const MaxReferenceFiles% = 255 Const AcceptReject$ = "Accept/Reject" Const OneThird# = 1 / 3 ' Integer constant ' String constant ' Derived from an expression Once a symbolic constant is defined. Declare symbolic constants. However. Most of the code examples in this chapter include assignment statements. either numeric or string. The expression is on the right side of the equal sign. symbolic constants can make your macro easier to read and maintain. Assignment operator The result of an expression is assigned to a variable with the equal sign (=).

Arithmetic operators Arithmetic operators work with numeric operands and yield a numeric result. 2.5. and 3. 3-12 MicroStation BASIC Guide . 4. Operator + * / \ Mod Used to Negate the expression Add the expressions Subtract the second expression from the first Multiply the two expressions Divide the first expression by the second Integer divide the first expression by the second Calculate the remainder in an integer division of the expressions Raise the first expression to the power specified by the second # of arguments 1 2 2 2 2 2 2 ^ 2 The operands in an arithmetic expression need not be the same numeric data type.5 is rounded to 4. When they differ. Longs are larger than integers. 2.6 is rounded to 5.5.5 is truncated to 2. it is rounded to the nearest integer using Baker’s rounding rules: • If the fractional part is larger than 0.767 When a floating point value (single or double) is converted to an integer value (integer or long).5. • If the fractional part is smaller than 0. The operands can be numeric literal constants. • If the fractional part is equal to 0. the number is rounded. or more complex expressions that evaluate to numeric results.Expressions Example dValue# = 45207 iValue% = dValue ' Assign integer value to double variable ' Overflow—Maximum integer value 32. and floating point data types are larger than whole number data types. simple variables. the operand with the “smaller” data type is promoted to the “larger” data type before the operation is performed. the number is truncated. doubles are larger than singles. For example.1 is rounded to 2. the number is rounded if it is odd and truncated if it is even.

The operands will be promoted to the “largest” of the two operands and the result variable before performing the operation. the comparisons are case-sensitive. in other words.” You can turn off case sensitivity in string comparisons by placing an Option Compare Text statement outside of the subroutines and functions in the macro. String concatenation operators The operators that work with string operands and yield a string result are solely for string concatenation. Relational operators The relational operators are used to compare expressions and yield a Boolean result. See the online help topic Macro Language Reference: in the “MicroStation BASIC” help file for a complete list. extracting the first six characters. + & Concatenate two string expressions Concatenate two string expressions Other string manipulations. = <> > < >= <= Are the expressions equal? Are the expressions not equal? Is the first expression greater than the second? Is the first expression less than the second? Is the first expression greater than or equal to the second? Is the first expression less than or equal to the second? When you use the relational operators to compare string expressions. for example. Also.Expressions If an expression that includes an arithmetic operator is part of an assignment statement. “a” is not the same as “A”. the data type of the result is also considered before performing the operation. are performed by calling BASIC functions. MicroStation BASIC Guide 3-13 Macro Language Overview 3 . upper case letters in a string sort lower than lower case letters so that comparing “a” and “A” would show that “A” is less than “a. True (-1) or False (0).5. operands promoted to Doubles. For example: Example dValue# = 10 / 4 ' dValue = 2.

Is either expression True? Are both expressions True? Is one expression True and the other False? Are both expressions True or are both False? Is the second expression implied by the first? Operands 1 2 2 2 2 2 The logical operators also work with numeric operands.680 in decimal c = 0000 1111 1111 1111. 61. c As Long a b c c c c c c = = = = = = = = 3855 255 Not a a Or b a And b a Xor b a Eqv b a Imp b ' ' ' ' ' ' ' ' In binary. b is 0000 0000 1111 1111 c = 1111 0000 1111 0000. 61.455 in decimal c = 1111 0000 1111 1111. expressions yielding a Boolean result. Example Dim a As Long. and yields a numeric result. 15 in decimal c = 0000 1111 1111 0000. True (-1) or False (0). a is 0000 1111 0000 1111 In binary. Logical operator Not Or And Xor Eqv Imp Used to Reverse the Boolean result. The logical operation is performed bitwise—in other words—on each bit of the two numeric operands. 4095 in decimal c = 0000 0000 0000 1111. 4080 in decimal c = 1111 0000 0000 1111. b As Long.Expressions Logical operators The logical operators work with Boolean operands. 61.695 in decimal 3-14 MicroStation BASIC Guide . and yield a Boolean result.

Eqv." The line continuation character cannot be used within strings. the underbar (_).Statements and the Line Continuation Character Operator precedence An expression can include more than one operator. When an expression contains more than one operator of the same precedence. Statements and the Line Continuation Character Usually. You can also use parentheses in expressions even when they are not necessary in order to make your macros easier to read and debug. However. a line in a BASIC program is a complete statement. and implication Object references The order in which operations are performed always can be forced by parenthesizing. <. equivalence.dgn because a " + _ "design file with that name is already open. if the statement is very long. Like Not And Or Xor. <>. MicroStation BASIC Guide 3-15 Macro Language Overview 3 . it can span several lines by using line continuation characters. must be the last character on the line and be preceded by a space. Example message$ = "Cannot create MS_DEF:plan. evaluation proceeds from left to right. =. The line continuation character. >. The order in which the operations are performed is called the operator precedence. <=. From highest to lowest precedence: ( ) ^ *. >=. Imp Is Parentheses Exponentiation Unary minus Multiplication and division Integer division Modulo Addition and subtraction Relational and pattern matching Logical negation And Or Exclusive or. / \ Mod +.

..Else block varies widely. For example..... each condition is a Boolean expression. a condition may also be any expression that evaluates to a numeric value...Then.Else An If. you can make a block of statements execute only if a condition is True or make a block of statements execute multiple times.. If.Then.. The BASIC language includes several constructs to control the path of execution. an expression that evaluates to True or False. The general format is: If condition1 Then [statementblock1] [ElseIf condition2 Then [statementblock2]] [Else [statementblockN]] End If Usually. The result is converted to an integer before the condition is tested. so on. If it is False... The Else block is also optional and is executed if all of the conditional expressions evaluate to False. However.Then. until a True condition is found. A zero numeric value is False and any nonzero numeric value is True...Else structure executes a block of statements conditionally. The structure of an If. When the True condition is found. Here are some examples: Example ' Simple If-Then-Else structure If numPoints < 3 Then 3-16 MicroStation BASIC Guide . The ElseIf blocks are optional and depend on how many conditions are to be checked. Each statement block is the one or more statements to be executed when the condition is True.Controlling Execution Controlling Execution The prototype macros generated by the Create Macro and End Macro commands are very simple in that each statement in the Main subroutine is executed in order and exactly once.Else construct begins with evaluating the first conditional expression.. the corresponding statement block is executed followed by the statement after the End If. the next conditional expression is evaluated and. Execution of an If..Then.

1 Print "Shape contains "." EndIf EndIf MicroStation BASIC Guide 3-17 Macro Language Overview 3 .Controlling Execution Print "Shape needs at least three points.x) And (p(1). Note use of ElseIf and And If numPoints < 2 Then Print "At least two points are needed to define a line string..y Then Print "End points are coincident.y = points(numPoints)." End If An If. numPoints.Then syntax for single condition with single statement If numPoints < 3 Then Print "Shape needs at least three points..y) Then numVertices% = numPoints ..Then block is to “nest” the If statements. numVertices.y = p(numPoints). For example: Example ' Alternate coincident point check If points(1)." End If Example ' Name in drawing title block depends on the design file name If designFile$ = "untitled... " vertices.x Then If points(1).Then statement that is contained to one line does not require the EndIf statement: Example ' Special If." Else Print "Line string contains ".dgn" Then titleBlock$ = "" Else titleBlock$ = designFile$ End If Example ' Examine points in a buffer." Another way to perform multiple comparisons in an If. " points..x = p(numPoints)." ElseIf (p(1).x = points(numPoints).

16 '0.Case The Select. 23. 1. 13. 21. Each statementblock contains the zero or more statements to be executed when the expressions match. 23. 18 '3. The result is compared with the values in each Case in the construct.. 21. 22 Print "Right Margin justification" Case Is < 127 'Values between 25 and 126 Print "Undefined justification" 3-18 MicroStation BASIC Guide . When expressionlist contains more than one expression. The statements in the optional Case Else block are executed when a match is not found in any of the expressionlists.. 24 '12. 15. 19. 18 Print "Left Margin justification" Case Is < 12. 15.. the expressions are separated by commas.. 8.. 10.Else for selectively executing one block of statements from among several blocks of statements.Controlling Execution Select. After the test expression is evaluated..Case structure is an alternative to If. 2. the expressionlists in the Case statements are evaluated in order. the block of statements associated with the Case is executed. 7. 15. 11. 24 Print "Right justification" Case Is < 6.Then.. 17. Example Select Case textJustification Case Is < 0 'All negative values Print "Invalid justification" Case 0 To 2. 17. and when a match is found. and the statements associated with the first matching Case statement are executed followed by the statement after the End Select.. 16 Print "Left justification" Case 6 To 8. 19. The expressions can be specific values or ranges of values. The general format is: Select Case testexpression [Case expressionlist1 [statementblock1]] [Case expressionlist2 [statementblock2]] [Case Else [statementblockN]] End Select Each expressionlist is a list of one or more expressions that evaluate to the same type as the testexpression. A single test expression is evaluated once at the top of structure. 20 '6. 20 Print "Center justification" Case 12 To 14. 5. 22 '9. 4.

If it evaluates to False.... This loop executes zero or more times. execution continues with the statement after the Loop While statement.Loop..Loop evaluates a condition to determine whether to execute the block of statements again.dgn") Do While dgnFile(numFiles) <> "" numFiles = numFiles + 1 dgnFile(numFiles) = Dir$() Loop ' Array for 100 DGN names ' Get first design file name ' Get next design file name The second variation of the Do. the statements are executed again. the statements are executed.Loop is one in which the condition is evaluated after the statements are executed. Each variation of the Do. Do statements Loop While condition The statements are executed and then condition is evaluated. If the condition evaluates to True.Loop A Do loop executes a block of statements an indefinite number of times.Loop.... If the condition evaluates to False. the statements are skipped and execution continues after the Loop statement. Execution returns to the Do While statement and condition is evaluated again. get design files in current directory Dim dgnFile$(1 To 100) Dim numFiles As Integer numFiles = 1 dgnFile(numFiles) = Dir$("*. the statements are executed as long as the condition is True: Do While condition statements Loop The condition is evaluated first..Controlling Execution Case 127 '127 Print "No justification" Case Else 'Anything greater than 127 Print "Invalid justification" End Select Do. In the first variation of the Do.. Example ' Using Do While.. If the condition evaluates to True. In this MicroStation BASIC Guide 3-19 Macro Language Overview 3 .

. Do Until condition statements Loop This loop is executed zero or more times.Controlling Execution variation of the Do.Loop..Loop is like the first except the loop is repeated as long as condition is False.While Not condition.. get design files in current directory Dim dgnFile$(1 To 100) ' Array for 100 DGN names Dim numFiles As Integer numFiles = 0 Do numFiles = numFiles + 1 If numFiles = 1 Then ' Get first design file name dgnFile(numFiles) = Dir$("*. Notice that the Do Until condition is equivalent to Do While Not condition. the statements are executed at least once. Do statements Loop Until condition The statements are executed at least once.Loop Until..dgn") Else ' Get next design file name dgnFile(numFiles) = Dir$() End If Loop While dgnFile(numFiles) <> "" The third variation of the Do.dgn") Do Until dgnFile(numFiles) = "" numFiles = numFiles + 1 dgnFile(numFiles) = Dir$() Loop ' Array for 100 DGN names ' Get first design file name ' Get next design file name The fourth variation of the Do.......Loop While.. Example ' Using Do.. get design files in current directory Dim dgnFile$(1 To 100) ' Array for 100 DGN names 3-20 MicroStation BASIC Guide .. Notice again that the Do.. Example ' Using Do..Loop.Loop is like the second variation except the loop is repeated as long as condition is False. Example ' Using Do Until.Until condition is equivalent to the Do. get design files in current directory Dim dgnFile$(1 To 100) Dim numFiles As Integer numFiles = 1 dgnFile(numFiles) = Dir$("*..

Case statement....Loop without waiting for the condition test at the top or the bottom of the loop.Loop is the endless Do loop. The Exit Do statement is also an appropriate way to exit an endless loop... Do statements Loop Sometimes you will find it convenient to exit a Do.Controlling Execution Dim numFiles As Integer numFiles = 0 Do numFiles = numFiles + 1 If (numFiles = 1) Then ' Get first design file name dgnFile(numFiles) = Dir$("*. Example ' Using Do.. The Exit Do statement. which generally appears in an If statement or a Select...dgn") Else ' Get next design file name dgnFile(numFiles) = Dir$() End If Loop Until dgnFile(numFiles) = "" The fifth variation of the Do.dgn") Else ' Get next design file name dgnFile(numFiles) = Dir$() End If If dgnFile(numFiles) = "" Then Exit Do ' Exit the loop While MicroStation BASIC Guide 3-21 Macro Language Overview 3 . immediately transfers execution to the statement after the Loop statement.Loop and Exit Do. A condition is not specified so the statements repeat until an End statement exits the macro or some type of Exit statement is encountered. get design files in current directory Dim dgnFile$(1 To 100) ' Array for 100 DGN names Dim numFiles As Integer numFiles = 0 Do numFiles = numFiles + 1 If numFiles = 1 Then ' Get first design file name dgnFile(numFiles) = Dir$("*.

start should be less than or equal to end.. get design files in current directory Dim dgnFile$(1 To 100) numFiles% = 1 dgnFile(numFiles) = Dir$("*... start must be greater than or equal to end for the statements to be executed. a For. and increment are numeric expressions that are evaluated once at the beginning of the loop. Execute the statements. Example ' Using While... exit the loop and continue with statement after Next..dgn") While dgnFile(numFiles) <> "" numFiles = numFiles + 1 dgnFile(numFiles) = Dir$() Wend ' Array for 100 DGN names ' Get first design file name ' Get next design file name For.Next structure is executed as follows: 1..Wend structure is another way to execute a block of statements an indefinite number of times. increment defaults to 1.Wend. It is identical to the first variation of the Do. 3-22 MicroStation BASIC Guide .Wend The While. When the statements must be executed a specific number of times. the statements will not be executed. While condition statements Wend This loop executes zero or more times. end... Compare counter to end. If increment evaluates to a negative value.Next Do loops are effective when the block of statements is to be executed an unknown number of times. otherwise.Controlling Execution While.Next structure is more efficient.. 3. The general format is: For counter = start To end [Step increment] statements Next [counter] Counter is a numeric variable and start.Loop in functionality. If increment evaluates to a positive value... If counter is greater than end when increment is positive or is less than end when increment is negative.. the statements are executed as long as the condition is True. Initialize counter to start. 2. The For.. If the Step clause is not included.

.y = points(num).x = p(1) points(num). r is 2x2 rotation matrix Dim p#(1 To 2) ' Temporary coordinate buffer Dim num%. Go back to the second step.2) * points(num). The Exit For statement immediately transfers execution to the statement after the Next statement.x * scale points(num).y = p(2) Next num Sometimes you will find it convenient to exit a For.Controlling Execution 4.dgn") Else ' Get next design file name dgnFiles(numFiles) = Dir$() End If If dgnFiles(numFiles) = ""Then ' Got last design file name Exit For ' Exit the loop End If Next numFiles MicroStation BASIC Guide 3-23 Macro Language Overview 3 .Next and Exit For. Example ' Using For.. Dim dgnFile$(1 To 100) ' Array for 100 DGN names Dim numFiles As Integer For numFiles = 1 To 100 If numFiles = 1 Then ' Get first design file name dgnFiles(numFiles) = Dir$("*.y * scale Next num For.Next structures can be nested to perform loops within loops.Next loop without completing the specified number of iterations.x + r(row. get design files in current directory ' The example handles a directory containing more than 100 design files. 5.x = points(num).y Next row points(num).1) * points(num).. For num% = LBound(points) To UBound(points) points(num). Example ' Scale points in dynamic array about the origin.... row% For num = LBound(points) To UBound(points) For row = 1 To 2 p(row) = r(row. Example ' Rotate points in a dynamic array. Add increment to counter.

7 origin = point ' Labeled with "setPoint" ' Labeled with "copyPoint" The Goto statement unconditionally transfers execution to a labeled statement.. total&. GoSub differs from Goto in that execution returns to the statement after the GoSub when a Return statement is encountered. The labeled statement must be in the same procedure as the Goto statement. exponent% 3-24 MicroStation BASIC Guide . Example ' Calculate the sum of the first 10 powers of 2 Sub Main Dim maxExponent%.2 point. The calculation in the previous example can be done more clearly with a For. exponent% maxExponent = 10 total = 0 exponent = 0 repeat: ' Label at top of the loop exponent = exponent + 1 total = total + 2 ^ exponent If exponent < maxExponent Then Goto repeat ' Jump to repeat: Else Goto done ' Jump to done: End If done: ' Label after the loop print "Sum is ".Controlling Execution Labels and the Goto statement You can label groups of statements in a macro. total End Sub ✍ Use Goto statements sparingly for they make macros difficult to read and debug.. total&. Example setPoint: copyPoint: point.Next loop. Example ' Calculate the sum of the first 10 powers of 2 Sub Main Dim maxExponent%. GoSub and Return statements The GoSub statement is similar to the Goto statement in that execution unconditionally jumps to a labeled statement in the same procedure. A label is a name ending with a colon (:) and it must be the first item in a line.y = 1.x = 356.

MicroStation BASIC Guide 3-25 Macro Language Overview 3 ✍ The GoSub and Return statements should be used sparingly if at all. • Function procedures do return a value so the function call must be part of an expression. maxExponent. and procedures can be reused. Procedures can be implemented as either subroutines or functions. Instead. A recursive procedure is one that calls itself directly or indirectly. Procedures are either intrinsic or user-defined. Procedures make macros easier to read and to maintain. the statements in a labeled subprocedure block should be moved into a procedure and the procedure called in place of the GoSub statement. total Exit Sub ' Exits the subroutine calculate: ' calculate subprocedure For exponent = 1 To maxExponent total = total + 2 ^ exponent Next exponent Return ' Return to Print statement End Sub Program Structure As the Main procedures in your macros get larger and more complex. An intrinsic procedure can be called from any subroutine or function in any macro. A user-defined procedure can be called from any subroutine or function in the same macro. • User-defined procedures are the subroutines and functions you define within the macro. Calling the subroutine is the entire statement. User-defined procedures can be implemented as recursive subroutines or functions.Program Structure maxExponent = 10 total = 0 GoSub calculate ' Jump to calculate: Print "Sum of ". • Subroutine procedures do not return a value. break them up into procedures that each do a single task. . • Intrinsic procedures are subroutines and functions implemented as part of the BASIC language and the MicroStation BASIC extension. "is ". Procedures are discussed in the next section.

maxExponent%) Dim total&. Example ' Print the sum of the first N powers of M ' Parameters are integers Sub PrintPowerSum (baseNum As Integer. a type declaration character at the end of variablename. If a type is not specified. if any. The parameter can be an array variable. the parameters are separated by commas. exponent% total = 0 For exponent = 1 To maxExponent total = total + baseNum ^ exponent Next exponent Print "Sum of the powers = ". When the list contains more than one parameter.. changes in member values are always reflected back in the procedure that called the subroutine. if it is a built-in data type. the parameter is given the integer type. are defined by the Sub. ✍ The ByVal keyword is incompatible with user-defined data type and array parameters. Each parameter in the paramlist looks like a variable declaration and acts like a variable in the subroutine. The statements make up the body of the subroutine and perform the task delegated to the subroutine. those that do not return a value. The paramlist is the list of the subroutine’s parameters. When the optional ByVal keyword is included in a parameter declaration. changes in the parameter value are not reflected back to the procedure that called the subroutine.Program Structure Subroutine procedures Subroutine procedures. The data type of the parameter is specified either by using the As type clause or. The general format is: Sub procedurename [(paramlist)] statements End Sub Procedurename is the name of the subroutine. The syntax is: [ByVal] variablename[( )] [As type] Variablename is the name the parameter will use in the subroutine. however.. total End Sub Example ' Print the distance between two 2D points ' Parameter is an array of the Point2d user-defined data type 3-26 MicroStation BASIC Guide .End Sub structure. The Main procedure in a macro is a predefined subroutine with no parameters. the dimensions and bounds of the array are not specified.

distance End Sub Sometimes you will find it necessary to exit a subroutine before the End Sub statement at the end of the subroutine. the statement is just the subroutine name. The general format is: Call subroutinename [(arglist)] Again. the arglist is not included when the subroutine has no parameters.Program Structure Sub PrintDistance (points() As Point2d) Dim xDistance#. Example ' Print the sum of the first 10 powers of 2 and 3 Sub Main MicroStation BASIC Guide 3-27 Macro Language Overview 3 .points(1). and execution continues in the calling procedure with the statement following the subroutine call. The general format is: subroutinename [arglist] The Call statement is a second way call a subroutine.x .dgn") ' Get first design file name While dgnFiles(numFiles) <> "" numFiles = numFiles + 1 if (numFiles >= 100) Then ' Array is full Exit Sub ' Exit GetDesignFiles dgnFiles(numFiles) = Dir$() ' Get next design file name Wend End Sub Calling subroutine procedures The statement for calling a subroutine is the name of the subroutine followed by a comma separated list of expressions that match the subroutine’s parameter list. Example ' Get design files in current directory (one last time) ' Subroutine has no parameters Private dgnFiles$(1 To 100) ' Macro-wide array for 100 DGN names Sub GetDesignFiles Dim numFiles As Integer numFiles = 1 dgnFiles(numFiles) = Dir$("*. If a subroutine has no parameters. Any number of Exit Sub statements can appear anywhere in a subroutine.y distance = Sqr(xDistance * xDistance + yDistance * yDistance) Print "Distance is ".points(1).x yDistance = points(2). yDistance# xDistance = points(2).y . The Exit Sub statement immediately exits the subroutine.

If a type is not specified. the function returns a 0 if it is a numeric data type or an empty string (“”) if it is a string data type. maxExponent Call PrintPowerSum (3. procedures that return a value. the parameters are separated by commas.y = 1. maxExponent) End Sub Example ' Print distances between some 2D points Sub Main Dim points(1 To 2) As Point2d points(1)..x = points(1). The statements make up the body of the function and perform the task delegated to it.5 points(2).y = -16. if any..End Function structure. 3-28 MicroStation BASIC Guide .8 PrintDistance points points(2). The syntax is identical to that described for subroutine procedures.x = 356.2 points(1). Only built-in data types are valid. Each parameter in paramlist looks like a variable declaration and acts like a variable in the function. are defined by the Function. When the list contains more than one parameter.Program Structure Dim maxExponent As Integer maxExponent = 10 PrintPowerSum 2.7 points(2). At least one of the statements should assign a value to procedurename. Because a function returns a value.0 Call PrintDistance (points) End Sub ' Initialize point coordinates ' Change second point's coordinates Function procedures Function procedures.x points(2). functions cannot return an array or a user-defined data type.x = 501. The general format is: Function procedurename [(paramlist)] [As type] statements End Function Procedurename is the name of the function.y = 299. The paramlist is the list of the function’s parameters. the data type of the function is specified either by using the As type clause or a type declaration character at the end of procedurename. the function is given the integer type. If a function exits without setting procedurename.

Array is already filled. and execution continues in the calling procedure with the statement following the function call.Program Structure Example ' Calculate the sum of the first N powers of M ' Parameters are integers ' Function returns a long integer Function PowerSum (baseNum As Integer.x yDistance = points(2).y . Private dgnFiles$(1 To 100) ' Macro-wide array for 100 DGN names Function CountDesignFiles% Dim numFiles As Integer CountDesignFiles = 0 ' Initialize return value numFiles = 1 While dgnFiles(numFiles) <> "" CountDesignFiles = numFiles ' Update return value if (numFiles >= 100) Then ' At the end of the array Exit Function ' Exit CountDesignFiles numFiles = numFiles + 1 Wend End Function MicroStation BASIC Guide 3-29 Macro Language Overview ' Parameter is an array of the Point2d user-defined data type ' Function returns a double Function Distance# (points() As Point2d) Dim xDistance#. yDistance# xDistance = points(2).points(1). Example ' Count the design files in the array. exponent% total = 0 For exponent = 1 To maxExponent total = total + baseNum ^ exponent Next exponent PowerSum = total End Function Sometimes you will find it necessary to exit a function before the End Function statement at the end of the function. It returns an integer. Any number of Exit Function statements can appear in a function.y Distance = Sqr(xDistance * xDistance + yDistance * yDistance) End Function 3 Example ' Calculate the distance between two 2D points . The Exit Function statement immediately exits the function. ' Function has no parameters. maxExponent%) As Long Dim total&.x .points(1).

The general format is: . and any changes made to the corresponding parameter’s value in the procedure are not made to the variable’s value in the calling procedure.. functionname ([arglist]). A function call expression is the name of the function followed by its arguments which are enclosed in parentheses.y = 299. 10) Print "Sum of the first 10 powers of". If a variable’s value must not be changed by a called procedure. Distance(points) End Sub Passing arguments to procedures By default. total Next baseNum End Sub Example ' Print distances between some 2D points Sub Main Dim points(1 To 2) As Point2d points(1).x = 356.. Distance(points) points(2).x = points(1). baseNum% For baseNum = 2 To 8 Step 2 total = PowerSum(baseNum.8 Print "First distance is". and 8 Sub Main Dim total&.y = -16. arguments are passed to subroutine and function procedures by reference.2 ' Initialize point coordinates points(1). The argument is then passed by value.x = 501.y = 1. 4. a function must be called in an expression. arglist. is a comma-separated list of expressions that match the function’s parameter list. 6.0 Print "Second distance is". Example ' Print the sum of the first 10 powers of 2.. baseNum.. The argument list. 3-30 MicroStation BASIC Guide . enclose the argument in parentheses.Program Structure Calling function procedures Because a function procedure returns a value.x ' Change second point's coordinates points(2).7 points(2). When a variable is passed to a procedure by reference.5 points(2). any changes made to the corresponding parameter’s value in the procedure are also made to the variable’s value in the calling procedure. "is".

5.0. the corresponding argument is always passed by value. For example: 'Pass 'Pass 'Pass 'Pass theArg theArg theArg theArg by by by by reference. value. the expression is evaluated. Value will not change.5. Example Sub ScaleValue (scale#. (dValue) Print dValue ScaleValue 1. value.5. Example Sub ScaleValue (scale#. dValue Print dValue ScaleValue 0. Value will not change. and the result is passed to the procedure by value. Sqr(dValue) End Sub ' ' ' ' ' Pass dValue by reference Prints "200" Pass dValue by value Prints "200". value#) value = value * scale End Sub Sub Main Dim dValue# dValue = 100 ScaleValue 2. ScaleValue 0. not "100" Pass square root of 200 by value  Be careful when a procedure takes a single argument. and any changes made to the parameter’s value are not made to the variable in the calling procedure. End Sub scale dValue (dValue) Sqr(dValue) ' ' ' ' dValue does not change ScaleValue prints "200" ScaleValue prints "50" ScaleValue prints "15" Arrays of variables and user-defined data type variables are always passed by reference to subroutine and function procedures. Value may change. ByVal value#) value = value * Print value End Sub Sub Main Dim dValue# dValue = 100 ScaleValue 2.5. The ByVal keyword cannot be used when declaring parameters that are arrays or user-defined data types in the MicroStation BASIC Guide 3-31 Macro Language Overview 3 . Value may change.Program Structure When the argument being passed to a procedure is an expression rather than a variable.0. When a parameter declaration includes the ByVal keyword. ScaleValue 1. Example mySubroutine theArg mySubroutine (theArg) sTs = myFunction(theArg) sTs = myFunction((theArg)) The parameter declarations in the subroutine and function procedures also affect the way the arguments are passed. reference.

Then. Example ' Declare statements for subroutine examples Declare Sub PrintPowerSum (baseNum As Integer. When the attributes and directions are combined. and. When circumstances prevent this arrangement.Objects in BASIC procedure. the optional paramlist. Declaring procedures It is good programming practice to place subroutine and function procedure definitions in the macro source before the procedures that call them. When you follow this practice. Objects in the BASIC language are used to group together procedures and data items that are meant to be used together. if it is a function. maxExponent%) As Long Declare Function Distance# (points() As Point2d) Declare Function CountDesignFiles% Objects in BASIC An object is an encapsulation of data and routines into a single unit. are identical to their counterparts in the Sub and Function procedure definition statements. a MicroStation graphics element has attributes such as color. and in the function declaration. they form an object. the Main subroutine is the last procedure in the macro. size and location. Changes made to member values are also made to the variable members in the calling procedure. The formats for declaring subroutine function procedures are: Declare Sub procedurename [(paramlist)] Declare Function procedurename [(paramlist)] [As type] Procedurename. as well as directions that specify how to display it using those attributes. the returned data type. any calls to a procedure can be checked against the procedure definition for the number and the data type of the arguments. For example. 3-32 MicroStation BASIC Guide . maxExponent%) Declare Sub PrintDistance (points() As Point2d) Declare Sub GetDesignFiles ' Declare statements for function examples Declare Function PowerSum (baseNum As Integer. the definition of the returned data type. use the Declare statement to receive the benefits of syntax checking.

Object Type Basic MbeCurrentTransform MbeDgnInfo MbeElement MbeElementSet MbeRefFile MbeRefFiles MbeSession MbeSettings MbeState MbeView MbeViews Description Operating system information Macro coordinate system Design file information Graphic element Elements in selection set or fence Reference file The collection of reference files MicroStation session information Active settings and locks MicroStation state information View or window The collection of views Declaring an object variable An object variable. a variable that refers to an object. For example.Objects in BASIC Not all of the information about the data of an object and how the procedures manipulate that data is accessible outside of the object. • Certain internal procedures in objects are also made available for programmability. Example Dim element As MbeElement Private elemSet As MbeElementSet ' An MbeElement object variable ' Macro-wide object variable MicroStation BASIC Guide 3-33 Macro Language Overview 3 . a Private statement. A new object type cannot be defined by a macro. A method is implemented either as a subroutine or a function that may or may not have arguments. Only a simple and refined interface is exposed. the element object may expose a Move method to translate the element based on an argument that specifies the distances in the x. an element object could expose an integer called color. Basic is the only non-MicroStation-specific object that is available. you can both retrieve (Get) and modify (Set) properties. The As type clauses in the statements specify the object type. For example. Such procedures are called methods. Only object types that have been predefined are available to a macro. is declared explicitly in a Dim statement. Usually. Such data items are known as properties. y and z directions. • Certain data items in objects are made available for programmability. or a Public statement.

A reference to the object is copied to objectvariable so that the physical object or underlying application object can be accessed through it. Object variable operations Object variables are assigned with the Set statement. 3-34 MicroStation BASIC Guide . Set Set element1 as MbeElement... • An object variable can be compared to Nothing to determine if it refers to any object. This first format of the Set statement does not duplicate the object referred to by objectexpression. The physical object or the underlying application object can no longer be accessed through objectvariable. The second format for the Set statement is: Set objectvariable = Nothing Assigning objectvariable to Nothing breaks the association the variable had with an object. The expression can be as simple as another object variable or it can be a function that returns an object variable.Objects in BASIC An object variable is given an initial value of Nothing (0) when it is declared because the variable is not yet associated with a physical object or an underlying application object. element2 As MbeElement element1 = FirstSetElement() ' Function returns an MbeElement object element2 = element1 ' Both variables refer to same object element1 = Nothing element2 = Nothing ' Break element1's association ' Break element2’s association The value contained in an object variable is meaningless to the macro except in the following situations: • Object variables can be compared to each other to determine if they refer to the same object. The difference is that objectexpression must evaluate to the object type of objectvariable. Object variables are compared by using the Is operator. The format is: Set objectvariable = objectexpression This statement is similar to the assignment statement for other data types. objectexpression is evaluated and the result is assigned to objectvariable. An object variable can also be assigned to Nothing with the Set statement. Example ' Declare two object variables. Initial values are Nothing Dim Set Set .

Set variables to refer them.. Initial values are Nothing. the initial object variable value is not Nothing. Example ' Declare object variables. If selectionSet Is Nothing Then Print "selectionSet is not associated with an element set object" End If If fence Is Not Nothing Then Print "fence is in use" If selectionSet Is fence Then Print "selectionSet and fence refer to the same element set object" Print "(or Nothing)" End If Creating an object instance An object variable must be associated with a physical object or an underlying application object before you can access object properties or call object methods You can create an object instance at the same time an object variable is declared with the Dim statement by using the As New objecttype clause. fence As MbeElementSet . Example ' Declare object variables and create underlying objects Dim element As New MbeElement Dim selectionSet As New MbeElementSet When the New keyword is included in the Dim statement.Objects in BASIC Example Dim selectionSet As MbeElementSet. Set element = New MbeElement Set selectionSet = New MbeElementSet MicroStation BASIC Guide 3-35 Macro Language Overview 3 . You also can create an object instance with the Set statement. Dim element As MbeElement Dim selectionSet As MbeElementSet ' Create underlying objects.. The third format for the Set statement is: Set objectvariable = New objecttype A new instance of objecttype is created and objectvariable is set to the value that refers to the physical object or the underlying application objects. but a value that refers to the physical object or the underlying application object.

element.method [arglist] The arglist is a comma-separated list of expressions that match the method’s parameter list. Example element. The argument list. is a comma separated list of expressions that match the method’s parameter list.method([arglist]).cellName End If ' Retrieve the element type ' Retrieve the cell name Accessing object methods Once an object variable is associated with a physical object or an underlying application object. the statement is just objectvariable. Example Dim origin As MbePoint If element.. The properties of an object are accessed with the “dot” operator: objectvariable. An object’s methods are accessed with the “dot” operator just like an object’s properties. The format is similar to a function call expression: . The arguments are enclosed in parentheses.method.objectvariable.color = 4 ' Set the element color When a property is readable. An object method that does not return a value is called in a standalone statement. you can retrieve and modify the object’s properties. you can use it in expressions like any other variable of the same type.getOrigin (origin) <> MBE_Success Then ' Relational expr. you can modify it with the assignment operator.property When a property is writable.. If the method has no parameters. The format is similar to calling a subroutine procedure: objectvariable. Example element.type = MBE_CellHeader Then Print "Cell : ".. Example If element.. you can manipulate the object by calling its methods.firstElement ' Highlight the element ' Set component in complex element An object method that returns a value is called as part of an expression.Objects in BASIC Accessing object properties Once you have declared an object variable and associated it with a physical object or an underlying application object. arglist. 3-36 MicroStation BASIC Guide .display MBE_Hilite element.

status% distance. A symbolic constant that refers to that object is declared for you.z End If Example Dim distance As MbePoint. In some ways.Objects in BASIC Print "Element doesn't have an origin" Else Print "Element origin :".5 distance.update ' Update view 7 For num% = 1 To 8 If MbeViews(num). Each object in the grouping is accessed individually by using an index that is either a number or a string. origin. num." End If Next num An object collection can itself have properties that expose information about the collection and methods to navigate the collection.x.y = 15.pattern = True ' Set pattern display in view 7 currentView. Example ' MbeRefFiles is a collection of MbeRefFile objects numFiles% = MbeRefFiles. A constant object is a pre-instantiated object of a reserved type. origin. Example ' MbeViews is a collection of MbeView objects Dim currentView As MbeView Set currentView = MbeViews(7) ' Assign MbeView object variable currentView. both the BASIC language and the MicroStation BASIC extensions expose system data and procedures that manipulate the environment through constant objects.25 distance. MicroStation BASIC Guide 3-37 Macro Language Overview 3 .maxRefFiles ' Collection property Constant objects Because objects are a convenient way to group related data items and procedures. an object collection is like a one-dimensional array of objects. " is active.x = -10.y.active <> 0 Then ' Retrieve MbeView property Print "View ".z = 1 / 3 status = element.move (distance) ' Assignment statement Object collections An object collection is a grouping of objects. origin.

The format is similar to calling a subroutine procedure: constantname.Version ' Set MbeDgnInfo masterUnitName ' Retrieve Basic version A constant object’s methods are accessed with the “dot” operator. " : ".property If the property is writable. The properties of a constant object are accessed with the “dot” operator. The format is similar to calling a function in an expression: .. 3-38 MicroStation BASIC Guide ..getInputDataPoint (point. Dim point As MbePoint. Query MbeState object. For example. Basic. view. These runtime errors can be dealt with through error handlers. you can modify it with the assignment operator.. view% If MbeState.method ([arglistI]). errors may still occur when running a macro. You also cannot declare additional object variables of the reserved object type or create new objects of the object type. the floppy drive may not be ready or bad input could cause a value to be too large for a variable. You cannot use the symbolic constant in Set statements or in logical expressions using the Is operator. point. you can use it in expressions like any other variable of the same type. point.masterUnits True Example ' Get the coordinates of the user's data point. view) = MBESuccess Then Print "Point in view ".masterUnitName = "km" Print "BASIC version ". Example MbeDgnInfo. Example ' Set transformation to master units in MbeCurrentTransform object MbeCurrentTransform.x. If the property is readable.Error Handling Only the properties and methods of a constant object can be accessed. The format is: constantname.method [arglist] A method that does return a value is called as part of an expression.. Call a method that does not return a value in a standalone statement.constantname.y End If Error Handling Even after syntax errors and program logic problems have been corrected.

Resume Use this format to repeat the statement that invoked the error handler. This format should be used infrequently. MicroStation BASIC Guide 3-39 Macro Language Overview 3 . Resume label Use this format to resume execution at a labeled statement. for appropriate action. Resuming on the next statement is most commonly used when the code needs correction. if at all. this form of the Resume statement makes a macro difficult to read and debug.Error Handling You set an error handler for a procedure with the On Error statement. Within the error handler. After you handle the error (such as by displaying the error message to the user). The format of the Resume statement determines the statement with which execution resumes. use a Resume statement to return to executing statements in the procedure. The format is: On Error Goto label If an error occurs at runtime. which must be in the same procedure. Resume Next Use this format to return to the statement after the one that invoked the error handler. Like the Goto and GoSub statements. Repeating the statement is most commonly used when the user can correct the error. you can retrieve the error number with the Err function and a corresponding message string with the Error function. execution will jump to the statement at label.

Example ' Check existence of a design file Function DesignFileExists% (dgnName$) On Error Goto handleError DesignFileExists = Dir$(dgnName) <> "" Exit Function handleError: errNum% = Err() If errNum = 71 Then ' Disk is not ready Print "Insert floppy or CD" Sleep(2000) ' Pause for 2 seconds Resume ' Repeat Dir statement ElseIf errNum = 53 Or errNum = 76 Then ' File/path not found DesignFileExists = False Resume Next ' Resume after Dir statement Else ' Other. the error handler in the calling procedure is invoked. When an enabled error handler is found among the calling procedures. Once an error handler is invoked. A similar search for enabled error handlers in calling procedures happens when a runtime error occurs within an error handler. not the statements in the procedure in which the error occurred. execution jumps to that handler as if the error were generated in that procedure. If an enabled error handler is not found. The Error statement in the previous example takes advantage of this search for enabled error handlers. The search continues back through the calling procedures until either an enabled error handler is found or there are no more procedures. the macro terminates with an error. it is disabled and is no longer the active error handler. Example Function DesignFileExists% (dgnName$) DesignFileExists = Dir(dgnName) <> "" End Function ' No handler enabled 3-40 MicroStation BASIC Guide . The Resume and Resume Next statements return execution to the statements in the procedure with the enabled handler. unexpected error Error errNum ' Trigger error in calling procedure End If End Function If a runtime error occurs and an error handler is not enabled for the procedure. If an error handler is not enabled in the calling procedure. the error handler in its calling procedure is invoked.

Use this type of error handling only in controlled situations. Disabling an error handler is useful when the handler does not apply to all the statements in a procedure. you can disable it with the third form of the On Error statement: On Error Goto 0 After this statement is executed. execution continues with the next statement. defaults to 0 (False). because it has not ' been assigned. which is the desired result. DesignFileExists. Example ' Check existence of a design file ' If a runtime error occurs. and Close statements. The format is: On Error Resume Next If an error occurs at runtime. Get. error handling is no longer enabled for the procedure. Function DesignFileExists% (dgnName$) On Error Resume Next DesignFileExists = Dir$(dgnName) <> "" End Function If you no longer need an error handler.Error Handling Function ValidDesignFile% (dgnName$) On Error Goto fileFailure If DesignFileExists(dgnName) <> 0 Then ' Open the file with Open statement ' Read the first four bytes with Get statement ' Compare values with design file numbers ' Set ValidDesignFile accordingly ' Close the file with Close statement Else ValidDesignFile = False End If Exit Function fileFailure: ' This handler deals with all errors from DesignFileExists() as ' well as any generated by the Open. execution continues with the next ' statement--exiting the function. MicroStation BASIC Guide 3-41 Macro Language Overview 3 . ValidDesignFile = False ' Not a valid design file Exit Function ' Clears error condition End Function You can use the On Error statement to ignore runtime errors altogether in a procedure.

The format is: Error errornumber The errornumber is either a built-in error number or a userdefined error number. 3-42 MicroStation BASIC Guide .Error Handling Example Sub CreateDesignFile (dgnName$) On Error Goto handleError If DesignFileExists(dgnName) <> 0 Then On Error Goto 0 ' Disable handler Kill dgnName ' Delete old file On Error Goto handleError ' Enable handler again End If ' Create the design file Exit Sub handleError: ' Deal with runtime errors End Sub You can generate runtime errors in a procedure with the Error statement. The Error statement is most commonly used to trigger an unexpected error again from within an error handler. you can use Error to simulate a system error to debug an error handler. you can use the Error statement to generate macro-specific runtime errors. Also. During testing. if you write the error handlers to deal with them.

objects. the element extensions provide access to the geometry and display attributes of MicroStation’s graphic elements. functions. All such functions return MBE_Success (which is predefined as 0) if successful or a nonzero error code that identifies the error if unsuccessful. as well as methods for simple manipulations to them. Pre-defined MicroStation-specific constants start with the MBE_ signature. types. the macro programmer steps MicroStation through commands rather than directly manipulating elements. The concepts behind the extensions are also described in this section.4 Macro Interactions With MicroStation This section discusses extensions to BASIC that give the macro programmer access to the inner workings of MicroStation. Many extension functions return an integer that indicates whether the function was successful. MicroStation BASIC Extension conventions MicroStation-specific extensions to BASIC are distinguished from other BASIC language features and user-written functions in that they always start with a signature of MBE_ or Mbe. For example. For more difficult element manipulations (for example. All MicroStation-specific functions. The MicroStation-specific extensions include predefined constants. data types. These functions include MbeSendCommand. When recording a macro. MicroStation generates a macro that consists of calls to the extension functions that correspond to the user’s inputs. Sequencing MicroStation Commands Often the easiest way to accomplish a macro’s objectives is to use the MicroStation commands and provide the inputs. MbeSendKeyin. chamfer or fillet). and methods are documented in “MicroStation Extensions to BASIC” on page 8-1. MicroStation BASIC Guide 4-1 . The aim of the BASIC extensions is to remain simple. Details of the implementation of the individual functions. and predefined objects or collections start with the Mbe signature. objects and collections.

The coordinate system can be changed by the macro programmer using the MbeCurrentTransform Current Transformation Object. MbeWriteCommand and MbeWritePrompt extensions to guide and prompt the user. Sometimes the macro generated by recording user input can be run unmodified.Macro Coordinate System MbeSendDataPoint. When coordinates are provided by the macro to the extensions. the masterUnits method sets it back to the default of master units. you need to modify the macro. macro programmers need not worry whether the current design file is 2D or 3D. Points are passed to and from the MicroStation extension procedures as type MbePoint. macros work in the “master units” of the active design file. Use the predefined MbeState State Object to retrieve the type and details of the user’s input. (The BASIC rules for promotion to double precision values are used if coordinates are not provided in double precision variables. Use the MbeGetInput extension to get user input. MbeWriteStatus.) Additionally. Macro Coordinate System The macro programmer need not be concerned with how the design file working units are set up. By default. The MbeCurrentTransform dgnUnits method sets the coordinate system to design file coordinates. Use the MbeWriteMessage. MbeSendLastInput and MbeSendReset. All coordinates that are returned to macros from the MicroStation-specific extensions are returned in double precision variables. The fromView method sets the coordinate system to match the 4-2 MicroStation BASIC Guide . the z member is zero when returned from an extension function and is ignored when an MbePoint is passed as an argument to an extension function. MbeSendTentPoint. but more often the recording serves as a starting point in the programming process. which is predefined as if the following statements were included in every macro: Type MbePoint x as Double y as Double z as Double End Type If the active design file is 2D. MbeWriteError. Frequently. they are provided in double precision.

cones and cylinders. view configuration. it is sometimes more convenient to directly perform simple manipulations than to sequence MicroStation commands. However. The MbeElement object extensions meet these needs. Simple graphic elements represent their entire geometry in one data item in the design file. which is easily accomplished by multiplying by 180. it is still necessary to understand some graphic elements concepts. distanceToUors. line strings. moveOriginWorld. MicroStation BASIC Guide 4-3 Macro Interactions With MicroStation 4 . ellipses. The implementation of the MbeElement object minimizes the knowledge of the graphic element format that is required of the macro programmer. rotate and scale methods to make other coordinate system transformations. Control elements save design file settings. Use the moveOrigin. such as lines. macros that generate key-ins from angles must convert from radians to degrees.0/PI. Graphic elements are categorized as “simple” or “complex” graphic elements. attach reference files. shapes. arcs. All angles passed to and from the MicroStation extension functions are in radians. The information stored in control elements is not directly accessible to the macro programmer through the MbeElement object. scalarFromUors. Since angle key-ins to MicroStation (for example. All manipulations are performed with object functions. text. etc. All data is retrieved using object properties or functions. MicroStation design files are composed of control elements and graphic elements. Manipulating or creating elements by sequencing MicroStation commands is often all that is needed but sometimes macros need information about graphic elements to determine how to process them or what inputs to supply to MicroStation commands. and distanceFromUors methods. A macro can transform points and distances back and forth between its current coordinate system and the fixed design file coordinate system by using the scalarToUors. setting the active angle) are expected in degrees.Querying and Manipulating Graphic Elements orientation of a particular view. Also. Querying and Manipulating Graphic Elements Most macros affect graphic elements in the design file.

In this example we use element as the variable name. text nodes. Each complex element is made up of a “header” element followed by one or more “component” elements. and groupings of simple graphic elements like cells. The first step in using an MbeElement object is to declare the object and allocate space for it using either of the following BASIC constructs: Dim element as New MbeElement or Dim element as MbeElement Set element = New MbeElement You can call the MbeElement object variable anything you want in your program. To the macro programmer both simple and complex elements are represented by a single MbeElement object. 4-4 MicroStation BASIC Guide . Either of these constructs establishes a name for an element object and allocates memory for the object. Using the MbeElement Object As explained in “Macro Language Overview” on page 3-1. the MbeElement object implementation simplifies the task of modifying component elements and makes it difficult for a macro programmer to corrupt a design file. The MbeElement object allows the macro programmer to modify component elements without worrying about consequential modifications required to the header element because the object implementation takes care of them. Use the fromLocate method to obtain the element that the user (or a macro emulating a user) last interactively located in the design file. In fact.Querying and Manipulating Graphic Elements Complex graphic elements require more than one data item in the design file. The next step is to associate an actual graphic element with the object. Use the fromFile element to obtain a graphic element from either the active design file or one of the attached reference files given its file position. Cells can group together other complex elements like text nodes and other cells. and complex shapes and chains. There are two MbeElement methods that provide means for obtaining a graphical element. B-spline curves and B-spline surfaces. This is desirable because many modifications to individual component elements of a complex element require modifications to the header element. objects in BASIC are used to encapsulate the data representing an entity and to group the functions or methods that can be used to manipulate that data. These more complicated graphic elements include surfaces of projection or revolution.

you can query its properties and manipulate it using the methods of the MbeElement object.Querying and Manipulating Graphic Elements Once you have associated a graphic element with your MbeElement object. charHeight and getString methods for text. you can determine geometric properties using the getRange. style. Component Elements Header Element Complex Element In the case where one complex element is contained within another. Complex Graphic Elements It is more complicated when a complex graphic element is represented by the MbeElement object. charWidth. justification. the first step is determining the type of graphic element and whether it is a simple or complex graphic element. startAngle and sweepAngle methods for ellipses (including circular ellipses) and arcs. For many element types. but there are some differences. level and class properties. The simplest complex element has one header element (the trunk) and one or more component elements (the branches). You can query (and change) the display attributes using the color. Picture a complex element as a tree with branches. The techniques used to query and manipulate element objects are similar for simple graphic elements and complex graphic elements. secondaryAxis. queries and manipulations are straightforward. the component element branch that is itself a header element has its own branches. getEndPoints and getPoints object methods. Use font. getOrigin. Often. The type and isHeader read-only properties are used for these two tasks. Use primaryAxis. 4 . weight. This nesting can go up to ten MicroStation BASIC Guide 4-5 Macro Interactions With MicroStation Simple Graphic Elements If the graphic element represented by the MbeElement object is a simple graphic element. as illustrated below.

Querying and Manipulating Graphic Elements levels deep. Next Component The most efficient way to process each component element of a complex element is to use a recursive subroutine (or function). The nextElement and nextComponent methods differ in their behavior when the element at the “current position” is a header element. at the same nesting level as the complex header. A nested cell complex element is illustrated below. either a header element or a component element. A recursive subroutine is a subroutine that calls itself. When the methods mentioned above for simple elements are applied to an MbeElement object representing a complex element. Cell Header Cell Header Nested Cell Complex Element To effectively deal with complex elements. The effect of nextElement and nextComponent is illustrated below: Next Current Next Effect of NextElement. including nextElement. The nextElement method moves the current position to the element following the complex header. the macro programmer needs a way of querying the component elements individually and a way of navigating through each branch of the tree. There are a number of element methods that are used to move the current position within a complex element. The nextComponent method moves the current position to the first component element of the complex element (that is. In this case a cell contains a single nested cell. nextComponent and firstElement. they apply to the graphic element that is at the current position in the complex element. A subroutine is written to process all component elements of the complex 4-6 MicroStation BASIC Guide . to the first “branch”).” The current position points to one of the graphic elements that makes up a complex element. Querying individual components of a complex element is done by using “current position.

nextElement Else gotNext = inElem. Else print "Type ". element type.") Type ". inElem. inElem as MbeElement) Dim gotNext as integer Do ' call function that shows info for element at current position Call ShowElemInfo (nestLevel. inElem as MbeElement) If nestLevel > 0 Then print Spc(nestLevel*2). inElem.type.nextComponent End If Loop While gotNext = MBE_Success End Sub '----------------------------------------------------------------' ' Main entry point ' '----------------------------------------------------------------Sub main MicroStation BASIC Guide 4-7 Macro Interactions With MicroStation 4 . "(". When that subroutine encounters a component element that is a complex header.type.nestLevel.componentFilePos End Sub '----------------------------------------------------------------' ' Recursive subroutine that processes a simple or complex element ' '----------------------------------------------------------------Sub ProcessElement (nestLevel as integer. including every component element of the complex graphic elements: '----------------------------------------------------------------' 'Subroutine that shows element type.nextComponent = MBE_Success Then Call ProcessElement (nestLevel+1. nesting level and file position ' '----------------------------------------------------------------Sub ShowElemInfo (nestLevel as integer. process them recursively If inElem.isHeader <> 0 Then ' if any components in complex. inELem) If inElem. it calls itself to process the components of that complex element. Here is an example of a simple macro that uses a recursive subroutine to print the nesting level. End If print " Filepos ". inElem) End If gotNext = inElem. and file position of each graphic element in a file.Querying and Manipulating Graphic Elements element. inElem.

In contrast a number of properties can be read and written.fromFile (filePos + element. set it with caution. It corrupts the element to simply change its type so the MbeElement object does not allow this. meaning they can be used like variables in BASIC statements. Since changeAll makes sweeping changes to all component elements. This makes it easy to change. 4-8 MicroStation BASIC Guide . style. In this case those properties can be used in expressions and as the target of an assignment: oldColor = element.bas examples uses this exact technique. the level of every text element in a text node or every element in a cell. Others that apply to all graphic elements include level. When these properties are assigned. if the changeAll property of an MbeElement is set to TRUE.type = MbeCellHeader ' This will result in a “not method” error The type property in this example is read-only since the data format for each element type is different. Modifying graphic elements Some of the MbeElement properties are read-only.color = newColor The color property is one such read/write property. weight. by default they are assigned to the component element at the current position.fileSize) Loop End Sub The ProcessElement function can be easily modified for use in other situations where the task involves processing components of complex elements.type but cannot be used as the target of an assignment: element. class and group.color element. element) filePos = element. However.fromFile (0) Do While filePos >= 0 Call ProcessElement (0. then when the property is assigned it affects all component elements of the MbeElement object. such as: elemType = element. for example.Querying and Manipulating Graphic Elements Dim element as New MbeElement Dim filePos as Long ' read the first element filePos = element. The elemshow.

If there are no elements selected and the fence is not placed. the set is discarded using the clear object method. There are two object methods for getting elements into the MbeElementSet object: fromSelectionSet and fromFence. it shows only those elements selected using MicroStation’s element selection tool. Using selection sets and fences The MbeElementSet object provides a means for macros to operate on multiple elements selected by the user with either a selection set or a fence. which is predefined as if the following statements were included in every macro: Type MbeSetMember filePos as Long fileNum as Integer End Type When done retrieving and processing the elements of an MbeElementSet object. it shows elements in the fence. the macro does nothing. retrieve them sequentially using the getFirst and getNext object functions. The following macro example uses the same technique as the previous example to show information about graphic elements. nesting level and file position ' MicroStation BASIC Guide 4-9 Macro Interactions With MicroStation 4 . If no element is selected.Querying and Manipulating Graphic Elements Refer to the MbeElement reference section for information on other MbeElement object methods. To operate on elements in the MbeElementSet. The first step in using an MbeElementSet object is to declare the object and allocate space for it using either of the following BASIC constructs: Dim elemSet as New MbeElementSet or Dim elemSet as MbeElementSet Set elemSet = New MbeElementSet This allocates memory for the MbeElementSet object which is now an empty set. '----------------------------------------------------------------' 'Subroutine that shows element type. Instead of showing every element in the design file. Each member of the set is returned as type MbeSetMember.

Else print "Type ".nextComponent = MBE_Success Then Call ProcessElement (nestLevel+1. "(".fromFence () <> MBE_Success Then print "No fence . inElem. inElem as MbeElement) If nestLevel > 0 Then print Spc(nestLevel*2). process them recursively If inElem.componentFilePos End Sub '----------------------------------------------------------------' ' Recursive subroutine that processes a simple or complex element ' '----------------------------------------------------------------Sub ProcessElement (nestLevel as integer.isHeader <> 0 Then ' if any components in complex. inElem.nestLevel.trying fence" If elemSet.giving up" Exit Sub 4-10 MicroStation BASIC Guide . End If print " Filepos ".Querying and Manipulating Graphic Elements '----------------------------------------------------------------Sub ShowElemInfo (nestLevel as integer.nextComponent End If Loop While gotNext = MBE_Success End Sub '----------------------------------------------------------------' ' Main entry point ' '----------------------------------------------------------------Sub main Dim elemSet as New MbeElementSet Dim element as New MbeElement dim setMember as MbeSetMember Dim gotElement as Integer dim filePos as long If elemSet.") Type ".type. inElem as MbeElement) Dim gotNext as integer Do ' call function that shows info for element at current position Call ShowElemInfo (nestLevel. inElem) End If gotNext = inElem.nextElement Else gotNext = inElem.fromSelectionSet (1) <> MBE_Success Then print "No Selection Set .type. inELem) If inElem. inElem.

use the MbeStartLocate function. Graphic element location Quite often a macro operates on a graphic element selected by the user. One way of doing this task is to set up the macro to work on an element set from a selection set. User inputs are received by the BASIC program and forwarded to MicroStation. but sometimes it is preferable to have control over the selection process. Of course. the macro can ignore the elements when it processes the set.filePos. this method is appropriate for operations that make changes independent of geometry (for example. rotate element) unless the required geometry can be calculated from information extracted from the graphic element.fileNum) Call ProcessElement (0.Querying and Manipulating Graphic Elements Else print "Processing Fence" End If Else print "Processing Selection Set" End If gotElement = elemSet. changing symbology). The user selects the element(s) to work on and then invokes the macro or the macro guides the user by sequencing the MicroStation CHOOSE ELEMENT command. The macro will operate on the located element using the methods provided for the MbeElement object. the macro can use the MicroStation BASIC Guide 4-11 Macro Interactions With MicroStation 4 . There are several different types of element location problems that macro programmers encounter: 1.getFirst (setMember) Do While gotElement = MBE_Success filePos = element. For this case. Because information about the location of the data point used to select each element in a selection set is not available. While this is a good approach there are a few drawbacks. A second drawback is that a macro cannot affect the elements that the user puts into the selection set.fromFile (setMember. setMember. When an element is located. However.getNext (setMember) Loop End Sub See the MbeElementSet object reference section for details. it is also generally unsuitable for operations dependent on geometry (for example. element) gotElement = elemSet.

fromLocate object method to retrieve the located element. endOfFile. 4-12 MicroStation BASIC Guide . 2. To the active command. In contrast to MbeElement and MbeElementSet objects. The macro can check to see if it matches a criteria of its own before operating on it using MbeElement object methods. But it wants to sequence a MicroStation command that requires element location to perform the actual task. MbeDgnInfo is pre-defined for each macro. In this case the macro locates the element as in 1 and then starts the MicroStation command (using the MbeSendCommand function). dgn3d. uorPerSub and subPerMaster. The following read/write properties are supported: masterUnitName. The object is automatically defined for you and you access its properties and methods using the construct MbeDgnInfo. dgnFileReadOnly. The macro wants to apply its own criteria. as in 1 above. subUnitName. the macro calls MbeRelocate. cellFileReadOnly. the macro calls MbeLocateElement. so it uses the MbeStartLocate function. The MbeDgnInfo object includes the following read-only properties: dgnFileName. In this case. it wants to sequence a MicroStation command to do the actual element manipulation. graphicGroup and nextGraphicGroup.method. But when the graphic element is located. When the command asks the user to identify an element. cell3d. When the command asks the user to identify an element. this has the same effect as the user entering a data point at a location specified as an argument to MbeLocateElement and selecting the element specified as an argument.Querying and Manipulating Graphic Elements MbeElement. cellFileName. the macro starts the MicroStation command for each element on which it wants to operate. The macro wants to find elements to work on using either the fence or a selection set or by stepping through the design file and finding them. this has the same effect as the user selecting the element located by the MbeStartLocate function by entering a data point at exactly the location that was sent to MicroStation during the location interaction. This means you cannot declare an MbeDgnInfo object in a Dim statement. Accessing design file information Information about the active design file is encapsulated in the MbeDgnInfo object. To the active command. 3.

axisLock. fillMode. angleLock. scaleLock. areaMode. patternCell. The object methods that retrieve or change settings include: color. lineTerminator. graphGroupLock. axisAngle. cell. fillColor. fenceVoid. The “table” BASIC example illustrates using a number of MbeSettings properties. getPatternDelta. lineStyle. Accessing MicroStation state information Information about the current state of MicroStation is encapsulated in the MbeState object. level. fontName. point. getInputDataPoint and getInputKeyin properties. getScale. determine the success or error status of the commands sequenced by the macro by examining the cmdResult read-only property. setPatternDelta. so the object is automatically defined. boresiteLock. and the getInputCommand. locateHeaderFilePos and locateComponentFilePos read-only properties. patternAngle1. The object methods that retrieve or change lock state include: snapLock. setScale. textJustification. nodeJustification. levelLock. textLineLength. When input is directed to MicroStation using the MbeSendCommand and MbeSendDataPoint statements. gridReference. weight. terminatorScale and currentGraphicGroup. The MbeState object also includes read/write properties that allow a macro to control whether MicroStation informational and MicroStation BASIC Guide 4-13 Macro Interactions With MicroStation 4 . class. textLineSpacing. angle. patternScale. textNodeLock. Determine the file number and file position of a located element using the locateFileNum. fenceClip. which reveals the type of input entered by users. which retrieve the actual input. gridUnits. isometricLock and depthLock. gridLock.method. Like the MbeDgnInfo object. axisOrigin. textWidth. tagIncrement. the MbeSettings object is predefined. This includes the inputType read-only property. cellStretchLock. capMode. colorName. fenceOverlap. Access its properties and methods using the construct MbeSettings. contructionPlaneLock. associationLock.Querying and Manipulating Graphic Elements Accessing MicroStation settings Access the active settings and locks that MicroStation uses while placing and manipulating elements through the MbeSettings object. patternAngle2. selectionSetLock. lineStyleName. font. textHeight.

enterDataFields. The maximum number of reference files that can be attached is accessible as 4-14 MicroStation BASIC Guide . Use the locateTolerance property to read or modify the element location tolerance. locatePropVal. areaFill. assign a view to it using the BASIC Set operator. The results of measure commands are available through the measureResult1 and measureResult2 read-only properties. textNode. grid. Syntactically. noText. a macro can declare a variable of type MbeView. Accessing design file view information MicroStation views are represented to the macro programmer as a predefined BASIC collection of MbeView objects called MbeViews.active View attributes that affect the way graphic elements are displayed can be queried and changed using the read/write properties fastCurve. query the read-only property active using the expression MbeViews(1). pattern. setLocateTypeMask and setLocateFileMask methods. and access the object property through the MbeView object: Dim view as MbeView Set view = MbeViews(1) active = view. If deferApply is set to TRUE. levelSymbology. Alternatively. the changes take place on the next update.active. For example. dimension. And finally. to tell if view 1 is active. errorMessages) and whether graphic element are drawn to the views (noElementDisplay). the MbeState object provides several methods for controlling the element location process. refBoundary and fastRefClip. Use the levelsOn and levelsOff methods to turn master file levels on and off. locatePropMask. Use the update method to update a view. Accessing reference file information Reference files are represented as a BASIC collection of MbeRefFile objects called MbeRefFiles. accessing views is similar to subscripting an array. slowFont. lineWeight. construction.Querying and Manipulating Graphic Elements error messages are displayed to the user (messages. Use the getLevels method to retrieve the levels currently turned on. Control the elements eligible for modification by manipulation and fence commands through the locateClassMask. If the read/ write property deferApply is FALSE (the default) the changes take place immediately by updating the view.

The MbeSession object is predefined. logical. notFound. The MbeSqlda object is similar to the concept of records in a database table. msPlatform. getLevels.elapsedTime. Database features of MicroStation BASIC extensions The database features of MicroStation BASIC are implemented over these main objects: • MbeSqlda • MbeTable • MbeDatabase • MbeDatabaseLink MbeSqlda object The MbeSqlda object helps the user extract results after a query or a describe table operation. The MbeSession properties (all of which are read-only) include msProduct. MbeRefFiles(refNum). display. The elapsed time since the start of the MicroStation session can also be obtained with MbeSession. you can either access an individual reference file in a syntax similar to an array reference. language. fileName. Use the saveSettings method to write the changes back to attachment control element in the design file. snap. or you can declare an MbeRefFile object and use the Set operator to assign it to access a particular reference file. for example. display. MbeRefFile methods include active. Access its properties and methods using the construct MbeSession. Using the MbeSqlda object The first step in using an MbeSqlda object is to declare the object and allocate space for it using either of the following BASIC constructs: Dim sqlda as New MbeSqlda MicroStation BASIC Guide 4-15 Macro Interactions With MicroStation 4 . levelsOn and levelsOff.method. numScreens and canSwapScreen. scaleLineStyle. plot. locate.property. As with views. scale.Querying and Manipulating Graphic Elements MbeRefFiles. Accessing MicroStation session information Information about the MicroStation session is encapsulated in the MbeSession object. attachName.maxRefFiles. msVersion. description.

you can query its properties using the methods of the MbeSqlda object. In this example.name provides the means for making a valid MbeTable object. MbeTable. sqlda is used as the variable name. Once you have a valid MbeTable object. 4-16 MicroStation BASIC Guide . The next step is to associate an MbeTable object with a valid table in the database.Querying and Manipulating Graphic Elements or Dim sqlda as MbeSqlda Set sqlda = New MbeSqlda You can call the MbeSqlda object variable anything you want in your macro. The following methods provides the means for obtaining a valid MbeSqlda object.recordFirst MbeTable. you can query and manipulate its properties using the various methods of the MbeTable object. tb is used as the variable name. Either of the constructs establishes a name for an MbeTable object and allocates memory. MbeTable object The MbeTable object represents a table in a database. MbeTable.recordNext Once you have obtained a valid MbeSqlda object. The next step is to associate a record with the MbeSqlda object. Using the MbeTable object The first step in using an MbeTable object is to declare the object and allocate space for it using either of the following BASIC constructs: Dim tb as New MbeTable or Dim tb as MbeTable Set tb = New MbeTable You can call the MbeTable object variable anything you want in the program. Both constructs establish a name for a sqlda object and allocates memory for that object.recordLast MbeTable. In this example.describe MbeTable.

you can query and manipulate its properties using the various methods of the MbeDatabase object. Either of these constructs establishes a name for an MbeDatabaseLink object and allocates memory. MicroStation BASIC Guide 4-17 Macro Interactions With MicroStation 4 . In this example.name provides means for making a valid MbeDatabase object. In this example we use link as the variable name.Querying and Manipulating Graphic Elements MbeDatabase object MbeDatabase object represents a database or schema. Using the MbeDatabaseLink object The first step in using an MbeDatabaseLink object is to declare the object and allocate space for it using either of the following BASIC constructs: Dim link as New MbeDatabaseLink or Dim link as MbeDatabaseLink Set link = New MbeDatabaseLink You can call the MbeDatabaseLink object variable anything you want in your program. db is used as the variable name. The next step is to associate an MbeDatabase object with a valid database name. Once you have a valid MbeDatabase object. MbeDatabaseLink object MbeDatabaseLink object represents the linkage between graphics and database. Either of these constructs establishes a name for an MbeDatabase object and allocates memory. MbeDatabase. Using the MbeDatabase object The first step in using an MbeDatabase object is to declare the object and allocate space for it using either of the following BASIC constructs: Dim db as New MbeDatabase or Dim db as MbeDatabase Set db = New MbeDatabase You can call the MbeDatabase object variable anything you want in your program.

the prioritized elements are re-processed through the macro functions. For example. 2. The Pen Table Plot Element Hook entry point function associated with the current pen table section is executed. Compared to the core pen table features. At this point any element manipulations performed in the macro will be passed on as plot output. When the pen table is loaded. Each element is processed through the section element criteria and when a match is found. The following steps show how the plotting process utilizes any BASIC macros defined as part of a pen table’s section definitions: 1. 6. again in order of their priority value. This is followed by the loading of any Pre-Plot Hook entry point function defined in each macro from the pen table section. Once all non-prioritized elements have been processed. Overview of macro operation in pen tables When you specify a BASIC function as part of the output action in a pen table section. it affects the entire plotting process. 3. The element will be reprocessed as part of the next step. all output actions except priority are applied to the element.Using Macros to Specify Pen Table Output Actions Using Macros to Specify Pen Table Output Actions A BASIC macro can be assigned as part of a pen table output action for plotting. in BASIC you can edit text and text node element strings in any imaginable way. This flexibility does not come without a cost. If the BASIC macro contains a Main subroutine it is executed. resorting to macros only when necessary. then the element is set aside with the priority level assigned by the called function. When the actual plotting process is started. the element is ignored and dropped from the plot output. It is most efficient to implement as many element manipulations as possible using core pen table features. using macros is slow. initial plot data (plot border and comment) is outputted. If this function returns with MBE_ElemPrioritize. 5. any MicroStation BASIC macros specified as part in the pen table sections are automatically loaded. 4-18 MicroStation BASIC Guide . 4. If the Pen Table Plot Element Hook entry point function returns with an MBE_Ignore. The actual plotting process is started by clicking the OK button of the Plot settings box or choosing the Preview option.

9. 5. the macro can be accessed at a number of steps in the plotting process. (Optional) Create the Main subroutine section which is automatically executed when the plotting process invokes the macro. Save the macro file (creates . The plot termination commands are sent to the output file or device from the plotting program. 2. this function should be left to the core output action operation of the same name. it is imperative the macro is optimized to minimize unnecessary or duplicate processing. MicroStation BASIC Guide 4-19 Macro Interactions With MicroStation 4 The Main subroutine is optional in plotting . 3.Using Macros to Specify Pen Table Output Actions 7. 4. If it is present.The plotting process concludes. Activate the BASIC Editor window (Utilities menu/Macros) and open or create the BASIC macro. 10. Once all elements have been processed. it will be executed upon macro load.bas and . the macros’ post-plot hook functions will be executed. Create at least one Function code segment containing the operations to be performed during the macro’s execution.ba files). 8. Known as prioritization. The macros’ Plot Finished hook entry point function in each section is finally executed. A macro that uses the entry points below may. or may not. General Procedure for Creating a Macro for Pen Table Use 1. Although you can use a macro to perform the prioritization function. Working with element priorities in macros One of the common features a pen table is called upon to perform is the reordering of elements in the plot sequence. for the best output performance. this feature is commonly performed as part of the output action definition in each section. Because of this intimate involvement in the plotting process. As you can see. have a Main subroutine. Set the program entry point (Edit menu/Program Entry Point) to one of the four standard plotting related settings.

due to the complex nature of particular element selection criteria. As noted in the plotting steps. The first time the function receives the element object its priority will always be 0. when the element is passed to your function for the second time. Pen Table Plot Element Hook function return values To differentiate between the various results possible with a macro used in plotting. If by convention you never assign a priority of 0 to an element. and then exit without performing any element manipulations. your function can tell that an element is being passed to your BASIC function for the first time by testing the priority for a value of 0. a BASIC function that prioritizes an element will have that element passed to it again later. The priority of 0 would tell your function to make the decisions necessary to determine the desired priority for the element. Your function can then proceed to perform any desired element manipulations. all Pen Table Plot Element Hook functions return 4-20 MicroStation BASIC Guide . you may have to prioritize an element using a macro. This occurs after other unprioritized elements and elements with a lower priority have already been completely processed. When this becomes necessary you should organize your function so that the priority is determined before any other processing is done.Using Macros to Specify Pen Table Output Actions However. Later. your function will find that the element has a non-zero priority (it will have whatever priority that was assigned to it before).

it causes all text and text-node elements in reference file 4 to be ignored (not plotted). Any value that may have been assigned to elm.displayPriority = 10000 floatTextAndUsePlottingFonts = MBE_ElemPrioritize Exit Function MicroStation BASIC Guide 4-21 Macro Interactions With MicroStation 4 . After the function has returned this value the element will be plotted. the function sets the appropriate return value of MBE_ElemPrioritize.Using Macros to Specify Pen Table Output Actions a value to the plot process as part of their operation. The element remains unprioritized—it will plot prior to any prioritized elements. and it performs certain font substitutions. When this value is returned the plotting order of the element is determined by elm.displayPriority = 0 Then elm. which will probably be set by the function just prior to returning. It is therefore wasted effort to perform manipulations on an element if you return this value. This return value tells the system to exclude the element from the plot. There are three such values: MBE_ElemNormal This is the most benign value your function can return. In each case.displayPriority has no effect when this return value is used. MBE_ElemIgnore MBE_ElemPrioritize The function must specifically set the output of the function to the appropriate value: basicUpdateHook_element = MBE_ElemNormal A macro plot function example The following is an example BASIC function that does three things: it prioritizes text elements so that they are always drawn last.type = MBE_Text Or elm.displayPriority. MBE_ElemIgnore or MBE_ElemNormal as just described: Function floatTextAndUsePlottingFonts (elm as MbeElement) As Long dim ts$ as String If elm. Any manipulations performed on the element will be reflected in the plot.type = MBE_TextNode Then ' Check if this is first pass on the element If elm.

Select the macro that is to contain pen table program entry points. choose Program Entry Point. program entry points must be defined. From the Edit menu.fontName = "CHAR_FAST_FONT" Then elm. 2. From the Utilities menu. The Macros settings box opens. ➤ To designate pen table program entry points 1. There are four such entry points described below. and click the Edit button. choose Macros.fileNum = 4 Then floatTextAndUsePlottingFonts = MBE_ElemIgnore Exit Function End If ' Check if font associated with this text is CHAR_FAST_FONT If elm.fontName = "ARCHITECTURAL" End If End If floatTextAndUsePlottingFonts = MBE_ElemNormal End Function Pen table program entry points As part of the preparation of a macro for use with the plotting process. 4-22 MicroStation BASIC Guide . The BASIC Editor dialog box will appear with the contents of the selected macro in its editing area.Using Macros to Specify Pen Table Output Actions End If ' Check if this text is part of reference file 4 If elm. To set a function as an entry point requires the use of the BASIC Editor window. 3.fontName = "BLOCK_OUTLINE" Else elm.

6. Click the New button to add a new entry point. MicroStation BASIC Guide 4-23 Macro Interactions With MicroStation 4 4.Using Macros to Specify Pen Table Output Actions The Select Entry Point dialog box opens. Pen Table PlotElement Hook. For most functions. This is the name as found on the Function line in your macros. Select the Entry Point type from the list on the left side of this dialog box. this will be the first entry. Edit BASIC Macro Entry Point dialog box 5. Example (name shown in bold): Function floatTextAndUsePlottingFonts (elm as MbeElement) As Long 7. Click the OK button to add the new entry point to the list. key in the BASIC function name. If any of the functions were previously defined they will appear in the listing portion of this dialog box. Select Entry Point dialog box The Edit BASIC Macro Entry Point dialog box opens. In the Name field. .

the Pen Table Plot Element Hook gets called for each element being processed for plotting. There may be multiple entry points of this type in a single macro. As with the Pre-Plot Hook. Depending on the entry point type. Only one entry point of this type may be defined per macro. Pen Table Plot Element Hook This is the entry point type you must create for a function that is associated with a pen table section. MicroStation has written initialization commands to the plotfile. The function declaration must be of the form: Function userPlot_pre As Long Post-Plot Hook At the time that this entry point is called. Unlike the other entry points that get called only once per plotting operation. Returning any value other than MBE_Success will cause the plot to be aborted. MicroStation has completed writing drawing commands to the plotfile but has not yet written termination commands and the plotfile is open. Only one entry point of this type may be defined per macro. The function declaration must be of the form: Function userPlot_element (elm as MbeElement) As Long This is the most commonly used program entry point.Using Macros to Specify Pen Table Output Actions The different program entry points and their function There are currently four different types of entry points that are unique to plotting. Below are the descriptions of these entry points and an example of the function line format required for each. A macro can use this entry point to add graphic to the plot that do not exist in the design. The function declaration must be of the form: Function userPlot_post As Long 4-24 MicroStation BASIC Guide . Pre-Plot Hook At the time that this entry point is called. the plot method of an MbeElement object can be used here to add its graphic to the plot. possibly drawn border and raster components but has yet to produce any other plot output. the function definition changes slightly. This function should always return MBE_Success.

you would combine the check for the priority and the reference file into one conditional If/then evaluation like this: Example If elm. the program returned control to the plotting process. however. this macro contains an unnecessary processing step which. Only one entry point of this type may be defined per macro.displayPriority = 10000 floatTextAndUsePlottingFonts = MBE_ElemPrioritize End If MicroStation BASIC Guide 4-25 Macro Interactions With MicroStation 4 . In the example. the plot has been completed and the plotfile is closed. The function declaration must be of the form: Function userPlot_finished As Long The function names shown in the examples above (userPlot_…) are for illustration only. This was done with the If conditional check: If elm.Using Macros to Specify Pen Table Output Actions Plot Finished Hook At the time that this entry point is called.displayPriority = 10000 floatTextAndUsePlottingFonts = MBE_ElemPrioritize Exit Function End If Once the priority of the element is changed. if used with a large design. could waste a significant amount of time. The actual names used are up to the developer. In reality.fileNum = 4 Then floatTextAndUsePlottingFonts = MBE_ElemIgnore Exit Function End If In reality. a test is made to see if the element has been prioritized. Optimizing the macro for plotting In the example given earlier. that the check for the reference file and the subsequent non-output is cycled through in a separate loop.displayPriority = 0 Then If elm. This function should always return MBE_Success. the structure shown was very straightforward and was provided for illustration purposes.displayPriority = 0 Then elm. If elm.fileNum = 4 Then floatTextAndUsePlottingFonts = MBE_ElemIgnore Else elm. Note.

ltScale Values MBE_Linestyle. “REFLOGNAME-LEVEL5”.bas macro or a user specified macro. If the layer is never used.Using Macros to Perform DWG Import/Export Exit Function End If This would result in only one pass on any elements that are not destined for the plotfile.refNameInLayer MBE_ON. Objects for specifying import and export settings There are two objects for DWG import and export settings: MbeDWGImportSettings and MbeDWGExportSettings. If on.polylineWidthAs . It overrides the Line Terminator Scale value in the seed file if one is specified. Object MbeDWGImport Settings MbeDWGExport Settings Settings .ignoreEmptyLayers . MBE_OFF Description Width to weight mapping support has been dropped.DXFPrecision . the reference file logical name is placed in layer name preceding a hyphen. Integer in the range 1-20 Any reasonable positive floating point . Using Macros to Perform DWG Import/Export A number of DWG import and export settings are accessible only through the dwg. This value is placed in the DWG/ DXF header for line type scale. Sets how many digits after decimal point in DXF file. ignore it. MBE_Shape MBE_ON. the level name or number follows the hyphen — for example. MBE_OFF 4-26 MicroStation BASIC Guide . Following is a list of properties for each of these objects.

0.addImportEntry "romanc". add a single AutoCAD to MicroStation font entry into both the import and export font translation table. read in a list of AutoCAD / MicroStation font entries from a specified ASCII text file and place them into both the import and export translation tables.addExportEntry "romanc". The AutoCAD font names must be enclosed in quotation marks. Note there is no equivalent to these arguments in the Import DWG/DXF operation. Both are used to place additional information in the output DWG/DXF file for these AutoCAD related font attributes. MbeFontNameTable. read in a list of AutoCAD / MicroStation font entries from a specified ASCII text file and place them into the import font translation table. read in a list of AutoCAD / MicroStation font entries from a specified ASCII text file and place them into the export font translation table. add a single AutoCAD to MicroStation font entry into the import font translation table. 3. MbeFontNameTable. as the order of “AutoCAD fontname”. 30. MbeFontNameTable methods addExportEntry addImportEntry addImportExportEntry Used to add a single AutoCAD to MicroStation font entry into the export font translation table.Using Macros to Perform DWG Import/Export Object for specifying font cross-reference information A macro-driven interface utilizes six macro objects to input font cross reference information. MicroStation font number is the same regardless of whether import or export is the intended operation. addImportEntryFromFile addExportEntryFromFile addImportExportEntryFromFile Each object/method ending in “Entry” takes as required arguments the AutoCAD font name followed by the MicroStation font number. 2. There are two additional optional arguments associated with exporting a MicroStation font to AutoCAD: width factor and oblique angle.0 MicroStation BASIC Guide 4-27 Macro Interactions With MicroStation 4 . 3 This last statement is important.

The MBE font objects ending in FromFile process a list of AutoCAD font names and MicroStation font numbers from the file defined by the first and required argument. this file will be sought in the directory defined by the environment variable.bas macro. That is. Using an ASCII file as input To maintain compatibility with the existing table-driven interface. If a match is found. MS_DWGTABLES. Objects for specifying cell/block cross-reference information When the export DWG/DXF process encounters a cell. “MS_DWGTABLES” The internal format of the input file is as follows: AutoCADfontname MicroStationFontNumber WidthFactor ObliqueAngle As with the . the WidthFactor and ObliqueAngle arguments are optional. Should additional parameters be needed in manipulating fonts. it attempts to find a match in its table as loaded from the dwg. with the second argument optional: . When the import DWG/DXF process encounters a block name. 4-28 MicroStation BASIC Guide .addExportEntry method. By default.Using Macros to Perform DWG Import/Export ✍ You must specify a value for the width factor in order to specify the optional oblique angle. the ASCII input file is invoked as follows. the file-name. MicroStation still generates a block definition based on the cell contents. all that is required is additional parameters in the input ASCII file and a modification to the macro. The contents of the cell is created from the block definition found in the DWG/DXF source file. An optional argument provides an environment variable name that points to a specific subdirectory where the file can be found. it attempts to find a match in the import table loaded from the dwg.. It should be noted that one of the features of using the macro interface is future expandability.bas macro.FromFile “Filename”.. there are three additional methods associated with using an ASCII list file for the font names translation table. the equivalent AutoCAD block name is used instead of the cell name.

as in the following example: MbeBlockNameTable.Using Macros to Perform DWG Import/Export To load the import and export block/cell table the following MBE objects and methods are used: MbeBlockNameTable methods addExportEntry Used to add a single AutoCAD-to-MicroStation block entry into the export block translation table. add a single AutoCAD-to-MicroStation block entry into the import block translation table. add a single AutoCAD-to-MicroStation block entry into both the import and export block translation tables. one of the DWG translators must have been run at least once. “symbol1” Editing and compiling “dwg.method ending in Entry takes as required arguments the AutoCAD block name followed by the cell name. read in a list of AutoCAD / MicroStation block entries from a specified ASCII text file and place them into the import block translation table.addImportEntry “callout”. click the Edit button. The block and cell names must be enclosed in quotation marks.bas” As a BASIC macro. addImportEntry addImportExportEntry addImportEntryFromFile addExportEntryFromFile addImportExportEntryFromFile Each object. read in a list of AutoCAD / MicroStation block entries from a specified ASCII text file and place them into the export block translation table.bas can be edited using the BASIC Editor window (Utilities menu/Macros).bas. This last statement is important. dwg. as the order of AutoCAD and MicroStation arguments is the same regardless of whether import or export is the intended operation. In order to compile and run dwg. Do not double-click the filename or click the Run button. The DWG extensions in this macro source file will only compile when one of the DWG import or export applications is loaded. read in a list of AutoCAD / MicroStation block entries from a specified ASCII text file and place them into both the import and export block translation tables. This allows the DWG translator MicroStation BASIC Guide 4-29 Macro Interactions With MicroStation 4 . Once the file is highlighted.

Error numbers The following table shows the defined run-time error codes. If there is a compile error. an error number is returned. the file can be compiled and run as any other macro.Using Macros to Perform DWG Import/Export to register the DWG macro extensions. These error numbers are defined below. If a run-time error occurs. In this case. Once this is done. Error number 1901 1902 1903 1904 1905 1906 Meaning Invalid Block name Invalid Cell Name Cannot open table file Invalid font file name Invalid font number Invalid settings value 4-30 MicroStation BASIC Guide . The translator will automatically load the macro file for each translation. If a compile or run-time error occurs. Then save the change and restart the translator. the error and line number are provided. It is not necessary to edit the macro file before each translation. just bring up the editor as described above and go the line number to fix the problem. an alert box displays containing the error and line number after which the translation halts.

and description. a user’s interaction is not limited to generating datapoints and selecting elements. allowing a user to enter a datapoint while in the process of locating an element. When calling these functions. However. MbeMessageBox. For detailed information on these extensions. These functions invoke the standard MicroStation File Open and File Create dialogs. the reply is immediately stored in a string variable supplied by the macro. or information icons (i). Examples include the STOP. depending on the type of response needed from the user. The MbeInputBox extension allows a macro to display a general purpose dialog with a message prompt. The descriptions of the standard dialog extensions below are only meant to highlight their functionality. MicroStation BASIC Guide 5-1 . At the same time.5 Adding Dialog Boxes to Macros There are several ways a macro may need to interact with a user. OK and Cancel buttons. you can display one of several icons (or no icon at all) in the same dialog. allows a macro to display a general purpose message dialog in a variety of push-button and information icon configurations. file filter. Standard Dialog Boxes In many instances the Standard Dialog extensions described here eliminate the need to design custom dialogs in a macro. see “Dialog Box Statements” on page 8-145. After the user enters an answer in the text field and clicks the OK button. warning (!). question (?). and an OK button. For example. Yes and No buttons. a text field in which the user may enter free-form string data. A macro can display a message in a dialog box with an OK button.” or “Would you like to continue?” Several general purpose dialog boxes allow a macro to collect information of this nature. the macro may supply default values for filename. and so on. Another extension. You may need to collect more general information like “Please provide a file name. Use the MbeFileOpen and MbeFileCreate extensions to help create and open files.

The macro relies on access strings to set BASIC variables while the dialog is displayed.Custom Dialog Boxes The MbeSelectBox is a general purpose dialog used for displaying a list of items. the macro can reference the associated BASIC variables to see what information was provided by the user in the dialog box. OK). if the access string for a text item specifies a string variable. If the access string specifies a Double variable. Data type characteristics are dynamically assigned to text items in BASIC custom dialogs. This implies that all custom dialogs must have at least one push-button defined to dismiss the dialog (for example. the text field treats information provided by the user as double-precision floating point.ba file. Custom dialog boxes in macros are always modal. That means a macro displaying a custom dialog box is suspended until the user dismisses the dialog box. This is also true for integer and long integer values. The user selects one item from the list and clicks the OK button. Custom Dialog Boxes The five standard dialogs described above will satisfy most data collection requirements of macros. For example. you may wish to define a custom dialog. After a custom dialog has been defined using the Dialog Builder window. However. 3. a macro can display the dialog box by calling the 5-2 MicroStation BASIC Guide . BASIC custom dialog boxes do not have hook functions. The type of information accepted by the text item is determined by the data type of the BASIC variable associated with the text item. All dialogs and dialog items for macros are defined graphically and stored as binary information in the macro’s . which is invoked from the BASIC Editor window by choosing Edit > Custom Dialog > Edit. The facility to define custom dialog boxes is called the Dialog Builder. 2. When the dialog is dismissed. then the text item takes on the characteristics of a string text field. Then control is returned to the macro. There is no textual dialog box definition for a Custom Dialog box in MicroStation BASIC. in cases where the collected data is too complex for these standard dialogs. The index of the selected item is returned to the macro. Custom dialogs for BASIC macros are similar to dialog boxes used throughout MicroStation with the following exceptions: 1.

are given the “N” flag. “N”ew and “R”ead only.ba. compiled macro file (. ID number.Dialog Builder MbeOpenModalDialog function. the default file is specified by the path where the file is located and by the name of the user-defined macro <macro name>. Any item in a standard dialog can be placed and manipulated and the dialog itself can be resized. The top list box contains a list of currently opened dialog boxes and provides details of the status. When you launch Builder from the Basic Editor. “M”odified. Status is a one-character field preceding the Title field with the following flags: “ “-blank. the dialog boxes of a macro named Table would be stored in the file table. Builder dialog box and macro Tools tool box The main dialog box contains two list boxes. This flag is retained until MicroStation BASIC Guide 5-3 5 Adding Dialog Boxes to Macros . This line is a call to the MbeOpenModalDialog function. All created dialog boxes are saved to the default file. An automated way of generating this function call is to use the Edit > Custom Dialog > Insert… menu to bring up a list of all custom dialogs defined for a macro. Dialog Builder The Dialog Builder window allows you to create and modify dialog resources and save the changes or new resource items to a binary . The .ba) will permanently destroy W Deleting a box definitions for the macro.ba file.ba. They cannot be all the dialog recovered except to completely reconstruct them using the Dialog Box Builder. Choosing a dialog from this list causes a line of text to be automatically inserted into the macro. and resource file to which they belong. name. So.ba extension file contains the dialog box resources for the macro. or dialogs opened as copies of the original. Newly opened dialogs.

The new dialog is associated with the default file.Dialog Builder the dialog is saved. the dialog within the file to open. Save a created dialog box to a file. During an editing session. To Create a new dialog box in the default file. Open an existing dialog resource in the current file. the dialog is not associated with any file until you choose “Save Dialog” or “Save Dialog To New. when the flag is cleared.ba). Choose from the Dialog menu New Load… Close Save Save to Existing Save to New… Delete New Creates a new. The bottom list box contains a list of all the items in the currently selected dialog box. use Dialog > Load… to open many dialogs at one time. Close an existing dialog box. untitled dialog box. and the mode in which the dialog will be opened. This allows you to compare dialog layouts for consistency and to cut and paste items between dialogs to ensure that they are identical. This dialog lets you select the file from which to open the dialog box. If no default file exists. Save a dialog box to a new file. Delete a dialog box from a file.” Load… Opens the Load Dialog dialog box. Dialog menu The Dialog menu contains selections for creating and loading dialog boxes to be edited and for deleting and saving dialogs in a file. Save a dialog box to an existing resource file (. If the 5-4 MicroStation BASIC Guide .

Dialog Builder user opens a dialog box with a dialog ID that is already open. Close Closes the currently selected dialog box. You are given the option of saving the dialog before closing (Yes). and none of the “Save …” menu options can be chosen from the File menu. the OK button in change dialogs is disabled. and cancelling the close operation (Cancel). Load Dialog dialog box Load Dialog Box As Read Only Open a dialog box for editing or reviewing. an alert box is displayed. a copy of the selected dialog box with no associated file is made. MicroStation BASIC Guide 5-5 5 Adding Dialog Boxes to Macros . closing without saving (No). items cannot be dragged. When a modified dialog box is closed. This dialog box is treated as a new dialog and any changes made are not applied to the original dialog. Save … Saves the dialog to the assigned file destination. the dialog box is opened as a copy. If on. Save Dialog… is disabled if no changes have been made to the dialog box or if the dialog was opened as read-only. the dialog box cannot be resized. If no destination exists. users cannot modify the dialog box. Load Dialog Box As A Copy Of Original If on. the dialog can be saved to the file of your choosing.

Associated attributes are cut with the items. This item is disabled if the file has been opened as readonly. selecting and arranging dialog items. ✍ The push-buttons in the Builder window (New. Send the selected dialog item(s) behind any other dialog items in the same area. This item is disabled if the file has been opened as readonly. To Cut the selected dialog item(s) to the clipboard. Copy and Paste between multiple dialog boxes for accelerated dialog box creation. Delete Deletes the currently selected dialog box from the file to which it belongs. copying. Delete the selected dialog item(s). Choose from the Edit menu Cut Copy Paste Delete Select All Bring To Front Send To Back Cut Cuts the selected item(s) from the dialog and places the items in the clipboard. Select all the items in the current dialog. Load and Save…) operate the same as their menu counterparts in the File menu. This item is disabled if the dialog box does not belong to a file. Save To Existing… Saves the dialog to an already existing resource file that you choose. from which you can paste them into any open dialog. Edit menu The Edit menu contains selections for moving. Copy the selected dialog item(s) to the clipboard. Cut items are removed from the dialog item list. Use Cut. 5-6 MicroStation BASIC Guide . This becomes the default file to which newly opened dialog boxes are saved. deleting.Dialog Builder Save To New… Saves the dialog to a newly created file of your choosing. Paste dialog item(s) from the clipboard into the current dialog. Bring the selected dialog item(s) to the front.

MicroStation BASIC Guide 5-7 5 . An item’s front or back location affects its selectability when the dialog is edited and used. Adding Dialog Boxes to Macros Paste Pastes the item(s) in the clipboard into the dialog that has the input focus. Associated attributes are copied with the item. Associated attributes are pasted with the item. Send To Back Positions the selected item(s) behind all other overlapping items. Use this command. Use this command to control which items are selected first when you click an area occupied by more than one item. Bring To Front Brings the selected item(s) in front of all other items in the dialog. You can paste copies of the clipboard items into any open dialog. This function is the same as individually selecting each item while holding down the <Shift> key or drawing a selection box around all the items.Dialog Builder Copy Copies the selected item(s) to the clipboard without affecting the original items. to control which items are selected first when you click an area occupied by more than one item. Delete Deletes the selected item(s) from the dialog. Pasted items are added to the end of the dialog item list. Select All Selects all the items in the current dialog. An item’s front or back location affects its selectability when the dialog is edited and used.

By default the dialog box is hidden. Open Dialog Attributes window. By default the tools box is displayed. deleted. In test mode. See “Tool box” on page 5-19. Spacing is measured in dialog units and 1. option buttons can be changed.25 is the default setting. toggle buttons toggled. text in text items can be edited. Edit mode is Builder’s normal mode in which dialogs and the items in them can be added. and modified. such as title. At present the only user-definable preference is Vertical Spacing.Dialog Builder Options menu To Toggle dialog between edit mode and test mode. Toggle display of tool box. Choose from the options menu Test Dialog Preferences Tools Dialog Attributes… Item Attributes… Test Dialog Toggles the dialog between edit and test modes. In this dialog you can change the dialog’s attributes. Toggle display of Preferences dialog box. Open Item Attributes window. 5-8 MicroStation BASIC Guide . Tools Toggles the display of the tools box. and level maps changed. ✍ All linkages to the macro’s BASIC variables are not connected and do not function in Builder’s test mode. the dialog behaves as it would in a macro. Test mode allows the dialog box designer to test the “usability” of the dialog box’s layout. Dialog Attributes… Opens the Dialog Box Attributes dialog box. dimensions and ID number. Preferences Toggles the display of the Preferences dialog box. color pickers selected. Use the tools box to create new dialog items. which controls the amount of space inserted between dialog items when Space Vertically is chosen from the Alignment menu.

Also open item attribute dialogs by double-clicking the item whose attributes are to be changed or by double-clicking an item in the list box containing the items in a dialog box. ID# Specifies the ID value of the dialog box being edited. There are different attribute dialogs for text. Title Specifies the character string that displays in the dialog box’s title bar. Item Attributes… Opens the attributes dialog box that is associated with the type of item that is selected.Dialog Builder Open the Dialog Box Attributes dialog by double-clicking in an unoccupied area of the dialog box or by double-clicking one of the rows in the open dialogs list box. group box. toggle button. Width Specifies the width of the dialog box in dialog coordinate units. Dialog Box Attributes dialog box File… Opens the select file dialog box in which the user can associate a file with the dialog box. label. MicroStation BASIC Guide 5-9 5 Adding Dialog Boxes to Macros . color picker. The dialog box is not automatically saved to the file. option button. Height Specifies the height of the dialog box in dialog coordinate units. level map. radio button and scale items. push-button. The file to which the dialog box belongs is displayed to the right of the push-button.

Dialog Builder

Common item attributes
Each item created in Builder has a dialog box for editing the item attributes. Many of these dialog boxes have common items which will be discussed here rather than with each specific dialog box.

Label
Contains the character string displayed on a text item.

Access String
Specifies the underlying BASIC variable that the item will be used to modify. Upon entry to the dialog, the underlying BASIC variable is used to set the appearance of the item. Upon exiting the reverse is true: the current value of the item is used to update the state of the underlying BASIC variable. The following table shows the data types of the access strings for each of the following items supported by Builder:
Item
ColorPicker Group Box Label LevelMap - Access String LevelMap - Active Level Option Button Push Button Radio Button Scale Text Toggle Button

Data Type of Access String
Long or Integer No Access String No Access String Array of 4 Integers Long or Integer Long or Integer No Access String (uses an action button value) Long or Integer Single or Double String, Long, Integer, Single, or Double Long or Integer

The following items are not supported by Builder: • Button Group Items • Tool Palettes • Color Picker Pull-down Menus • Option Pull-down Menus • Text Pull-down Menus • Separator Items

5-10

MicroStation BASIC Guide

Dialog Builder
• List Box Items • Multiline Text Fields • Popup Menu Items • Scroll Bar Item

Text Editor dialog box
Used to change the attributes of a text item.

Read Only
If on, the contents of the text item is not editable.

Label Above
If on, the label appears above the text item. By default, the label is displayed to the left of the item.

Custom Dialog Boxes
Data type characteristics are dynamically assigned to text items in custom dialogs. The type of information accepted by the text item is determined by the data type of the BASIC variable associated with the text item. For example, if the access string for a text item specifies a string variable, then the text item takes on the characteristics of a string text field. If the access string specifies a Double variable, the text field treats information provided by the user as double-precision floating point. This is also true for integer and long integer values.

Label Editor dialog box
Used to change the attributes of a label item.

Word Wrap
If on, newline characters in a label result in a multiline label.

Bold Font
If on, the label is displayed using a bold font.

MicroStation BASIC Guide

5-11

5

Adding Dialog Boxes to Macros

Dialog Builder Justification
Sets the justification of the label within the item.
Justification
Left Right Center

Meaning
The label is left-justified within the item. The label is right-justified within the item. The label is centered within the item.

Toggle Button Editor dialog box
Used to change the attributes of a toggle button item.

Mask
If invert is TRUE, the bitwise OR operator combines mask with the variable specified by accessStr. If invert is FALSE, the bitwise AND operator combines the ones complement of mask with the variable specified by accessStr.

Invert
If on, indicates a TRUE state for invert.

Option Button Editor dialog box
Used to change the attributes of an option button. An option button item contains a list of the following subitems:

Sub-Items List Box
Contains a description of the label, value, mask, and enabled state of each subitem in the option button. The information is modified in the list box by changing the text items and toggle button item described below.

Icon ID Label
Specifies the text string to be displayed for the subitem.

Value
Determines with mask the currently selected subitem. Only one subitem can be selected at a time.

5-12

MicroStation BASIC Guide

Dialog Builder Mask
Determines with value the currently selected subitem. Mask indicates which bits of the variable specified by accessStr are compared to value. For example, for a mask value of 0xC (1100 binary), bits 2 and 3 of accessStr are compared to value.

Enabled
Determines the state (enabled or disabled) of the subitem when the option button is first created. If this item is set to ON, the subitem can be selected; when it is set to OFF, the subitem will be dimmed (disabled).

Insert
Inserts a copy of the selected subitem to the subitem list of the option button.

Delete
Removes the currently selected subitem from the subitem list of the option button.

The Access String related to an item needs to be an Integer.

Push Button Editor
Used to change the attributes of a push-button. All the dialog boxes created for the BASIC environment are modal. That means all user interactions must be focused within that single dialog and that the dialog box manager will ignore mouse presses while the pointer is outside the dialog box. Each activated push-button— except for Reset—dismisses the modal dialog and passes a return action value to the macro. This action value is handled by the programmer and used to determine the operation requested by the user.

MicroStation BASIC Guide

5-13

5

Adding Dialog Boxes to Macros

Dialog Builder Default Attributes
Sets the attributes of the push-button. The choices are:
Normal Default The push-button is not a Default or a Cancel push-button. The push-button is a dialog box’s default button outlined with a recessed rectangle. The button is automatically activated when the user presses the <Return> key. The push-button is a dialog box’s cancel button. The button is automatically activated when the user presses the <Esc> key and typically means that the operations to be performed using the dialog box should be aborted.

Cancel

Push Button Type
Sets the type of push-button. Each type returns a different action ID. The programmer uses this return value from the push-button to carry out a specified action. Once any type of push-button is pressed, the dialog box that contains the push-button closes. Types of push-button include:
Type of push-button
User Defined

Details
Returns an ID value that is specified by the user. When the user selects this option choice, the Action ID# text item is displayed. The push-button returns an ID equal to the Action ID#. Returns an ID of MBE_BUTTON_APPLY. Has an ID of MBE_BUTTON_RESET. The modal dialog box is not closed. The Reset button sets all the items to the state they were in when the dialog box was first opened.

Apply Reset

The return ID’s of the other push-button include
MBE_BUTTON_OK, MBE_BUTTON_CANCEL, MBE_BUTTON_DEFAULT, MBE_BUTTON_YES, MBE_BUTTON_NO, MBE_BUTTON_STOP, MBE_BUTTON_HELP, MBE_BUTTON_RETRY.

Action ID#
This text item is displayed if the push-button type is User Defined. The user sets this ID value, which is the value returned from the modal dialog box when the dialog box is closed. This ID value must be greater than or equal to 1000.

Color Picker dialog box
Used to change the attributes of a color picker item.

5-14

MicroStation BASIC Guide

Dialog Builder Mask
Indicates the bits of the variable specified by accessStr that are used to determine the current color index. Usually, mask should be set to 0xFFFFFFFF, which indicates that the entire variable will be used to derive the color index.

Associated Text Item ID #
Sets the resource ID of a text item that will be associated with the color picker item. As the user drags the mouse over the popped up color palette, the associated text item will be dynamically set to the index of the color square the pointer is on.

Level Map Editor dialog box
Used to change the attributes of a level map item.

Access String
Sets the name of the BASIC variable (a 4-element array of type Integer) used to represent the level map.

Active Level Access String
Sets the name of the BASIC variable used to represent the active level. The active level is indicated with a circle and is selected with a double-click. If an active level is not applicable, specify an empty string for this item.

Scale Editor dialog box
Used to change the attributes of a scale item.

Increment Amount
Sets the amount the current value of the scale is changed when the user clicks on the scale arrows.

Page Increment Amount
Sets the amount the current value of the scale is changed when the user clicks in the page area of the scale. The page areas are the areas between the slider and the scale arrows.

Minimum
Sets the value associated with the minimum position of the scale slider.

MicroStation BASIC Guide

5-15

5

Adding Dialog Boxes to Macros

Dialog Builder Maximum
Sets the value associated with the maximum position of the scale slider.

Min Label
Sets the text string to be used as the label for the minimum value of the scale item.

Max Label
Sets the text string to be used as the label for the maximum value of the scale item.

To Display Format
Describes a format string to convert the value of the scale item into a display value when Show Value is on.

Associated Text ID
Sets the resource ID of the text item associated with the scale item. As the user drags the mouse on the slider, the associated text item will be dynamically set to the value of the scale based on the current slider position.

Orientation
Indicates whether the item is a vertical or a horizontal scale item. The choices are:
Horizontal Vertical The item is a horizontal scale item. The item is a vertical scale item.

Has Arrows
If on, the scale item is drawn with single step adjustment arrows at each end of the scale.

Show Value
If on, the current scale value should be displayed alongside the slider.

Limits On Side
If on, the range limits for the scale are to be displayed at the side of the scale item and not at the ends. By default, scale ranges are displayed at the ends of the scale item.

5-16

MicroStation BASIC Guide

Group Box Editor dialog box

Group Box Editor dialog box
Used to change the attributes of a group box item. The group box contains only the label text item.

Used to change the attributes of a radio button item.

Mask
The mask text item with value determines the currently selected subitem. If the entire variable specified by accessStr is being compared to value, set this text item to 0xFFFFFFFF.

Value
The text item with mask determines the currently selected radio button subitem. Each subitem is a member in a list of radio buttons. Only one subitem can be selected at a time. Mask indicates the relevant bits of the variable specified by accessStr. For example, for a mask value of 0xC (1100 binary), bits 2 and 3 of accessStr are compared to value.

List ID
Associates radio buttons with other radio buttons in a list that groups all radio buttons together. The List ID text item specifies the ID of the list to which this radio button belongs.

MicroStation BASIC Guide

5-17

5

Adding Dialog Boxes to Macros

Radio Button Editor dialog box

Radio Button Editor dialog box

Alignment menu
The Alignment menu contains selections that will help you create dialog boxes with aligned items for consistency. Many of the selections, when used together, can save time otherwise spent manually aligning dialog items.
To
Align two or more items by left, right, top, or bottom edges Horizontally center selected items Vertically center selected items Spread selected item(s) equally across width of the dialog box Spread selected item(s) equally across height of the dialog box Space selected items adjacent to one another vertically Make each selected item the same size as the first item selected

Choose from the Alignment menu
Align> Left|Right|Top|Bottom Center on Horizontal Center on Vertical Spread Horizontally Spread Vertically Space Vertically Make Same Size

Align [Left|Right|Top|Bottom] Aligns the selected items by left, right, top or bottom edges. Left and right alignment does not affect vertical position, also top and bottom alignment does not affect horizontal position. The position to which the items are aligned is determined by the first item selected. Center on Horizontal, Center on Vertical Aligns the selected items about a common horizontal or vertical axis. Horizontal centering does not affect vertical position and vertical centering does not affect horizontal position. Spread Horizontally, Spread Vertically Spreads the selected item(s) an equal distance apart and from the edges of the dialog box. Horizontal spreading does not affect vertical position and vertical spreading does not affect horizontal position. Space Vertically Positions the selected items so they are evenly spaced vertically. Set Vertical spacing by choosing Preferences from the Options menu. Horizontal position is not affected.

5-18

MicroStation BASIC Guide

Radio Button Editor dialog box Make Same Size Resizes the selected items to the same size as the first item selected. Vertical and horizontal position are not affected.

Dialog items are placed using the tools listed. Items are placed with generic names and sizes. Names and other item attributes can be changed using the methods described in “Common item attributes” on page 5-10. Item sizes and positions can be manipulated in the main Builder window.
To
Select one or more items to be modified. Add a single-line user-editable text box. Add a static text label. Add a toggle button. Add a labeled box that groups related items. Add a user-selectable option button. Add a push-button. Add a color-picker item. Add a level map item. Add a scale item. Add a radio button.

In the tool box, select
Item Selection Tool Place Text Item Place Label Item Place Toggle Button Item Place Group Box Item Place Option Button Item Place Push Button Item Place Color Picker Item Place Level Map Item Place Scale Item Place Radio Button 

The default item placement mode is “single shot.” If you singleclick on the item placement tool, only one occurrence of the item can be placed before Builder reverts to the Item Selection tool. However, if you double-click on an item placement tool, Builder enters a mode where every click in the dialog places another occurrence of the item. Resetting returns to the Item Selection tool.

MicroStation BASIC Guide

5-19

5

Adding Dialog Boxes to Macros

Tool box

Radio Button Editor dialog box Manipulation of Items Items can be manipulated with the mouse by clicking and dragging. Move an item by clicking within the rectangular area of the item. Resize an item by clicking on the edge of an item. Appropriate resizing restrictions apply to some items. For example a text item may only be resized horizontally.

Exiting Builder
When the user exits Builder, the Save Before Exiting dialog box is displayed. It contains the list of modified dialogs and the Save, Save All, Save To and Save None push-buttons.

Save Before Exiting dialog box

Save Saves the dialog box that is selected in the list box. Save All Saves all the modified dialogs. Save To… Opens a dialog box which is used to save the dialog box that is selected in the list box to a file. Save None Exits Builder without saving any dialog boxes.

5-20

MicroStation BASIC Guide

MDL is the language of choice for the vast majority of new application development. MicroStation BASIC Guide 6-1 . On-line documentation for MDE is included with MicroStation. MDL has much to recommend it as a development facility. If your organization requires it. you can also develop your own application software. The rest of this chapter consists of a brief description of MDE and MDL. MDL combines a full set of development tools with direct access to the MicroStation “CAD engine” through built-in functions. In addition to BASIC. see the on-line documentation for MDE. which includes the MicroStation Development Language (MDL). but it may not be right for you.6 The MDL Alternative The most sophisticated way to customize MicroStation is to use application software that supplements the core functionality. MDE is included with MicroStation and provides these tools: 1 • Compiler. MicroStation includes the MicroStation Development Environment (MDE). linker and “Make” utility • Object librarian • Resource compiler and librarian • Tools for building graphical user interfaces • Symbolic debugger that is optimized for use with MicroStation 1. For information about obtaining printed MDE documentation. MicroStation Development Environment MDE is an environment for developing MDL applications. with guidelines for choosing between MDL and MicroStation BASIC.

In fact. • Knowledge of programming is a necessity. MDL built-in functions The real power of MDL is in its built-in functions. MDL applications are run from inside MicroStation and appear to be part of MicroStation itself. here are some of the most important built-in function categories: • Cells • Current transformation • Database • Dimensioning • Element creation • Element descriptor • Element extraction • Input handling • Mathematical • Output • Parsing • Reference files • State control • User interface 6-2 MicroStation BASIC Guide . MDL is the C programming language executed by MicroStation. To give you a better idea of how completely MDL applications can access MicroStation’s “CAD engine” through built-in functions. • C is a well-known language. • They have excellent performance. • They can be written so that they run without modification on all platforms on which MicroStation runs. An MDL application can call built-in functions to: • Interface with the user. much of MicroStation is implemented as MDL applications. • Synchronize with MicroStation and other applications. • They are easy to debug with the supplied tools. Only a recompilation of the application is necessary.MicroStation Development Environment MicroStation Development Language Essentially. Advantages of MDL applications are as follows: • They directly access MicroStation’s “CAD engine” through builtin functions. • Create and manipulate graphic elements. Disadvantages of MDL applications are as follows: • They cannot be ported to IGDS without extensive recoding.

MDL dialog box and dialog item hook functions would be used in this case.MicroStation Development Environment • Element location and manipulation • External program communication • View control When to use MDL instead of BASIC • the application must communicate directly with an executable external to MicroStation through a messaging interface. • the application requires non-modal dialog boxes. Note that there are no create element functions in MicroStation BASIC. • the application requires more control over its user interface than is supported in BASIC. • the application must call functions within a dynamic link module. • the application must create new elements and use dynamics. MicroStation BASIC Guide 6-3 6 The MDL Alternative .

MicroStation Development Environment 6-4 MicroStation BASIC Guide .

Part II: Macro Language Reference .

.

This chapter describes the BASIC keywords. Subtract one value from another. see “BASIC Command Overview” on page 7-1 • In alphabetical order.7 Standard BASIC Reference Elements belonging to the standard BASIC language are referred to as keywords. Divide one value by another. To find a keyword: • By function. MicroStation BASIC Guide 7-1 . Windows platforms only Operators Keyword & * + / Used To Concatenate two strings Multiply two values Add two numeric values or concatenate two strings. see “A to Z Reference” on page 7-11 BASIC Command Overview The BASIC commands are listed in the following function groups: • Operators • Constants and special keywords • Math and numerical operators • Array handling • System • Miscellaneous • Program control • Variable control • Character and string manipulation • File handling • Date and time • Business calculations • Dynamic Data Exchange (DDE).

Calculate the double-precision equivalent of an expression. Reverse the logical value or perform a bitwise NOT. Perform a logical or bitwise implication.BASIC Command Overview Keyword < <= <> = > >= \ ^ And Eqv Imp Is Like Mod Not Or Xor Used To Determine if one value or string is less than another. Perform a logical or bitwise AND. Determine if one value or string is equal to another. Perform a logical or bitwise exclusive OR. Perform integer division on two values.) Continue a line. Calculate a remainder. Raise a value to a power. Calculate the arctangent of a value. Determine if one value or string is greater than or equal to another. Perform a logical or bitwise OR. Determine if one value or string is less than or equal to another. Perform a logical or bitwise equivalence. Compare a string with a pattern. 7-2 MicroStation BASIC Guide . 3. Constants and special keywords Keyword ' _ False (constant) PI (constant) REM (statement) True (constant) Used To Denote a comment (makes the interpreter skip the rest of the line. Represent the value of one or a valid situation. Determine if one value or string is not equal to another. Math and numerical operators Keyword Abs (function) Atn (function) CDbl (function) Used to Calculate the absolute value of a number.14159… Make the interpreter skip the entire line. Represent the value of pi (π). Represent the value of zero or an untrue situation. Determine if one value or string is greater than another. Determine if two object variables refer to the same object.

Calculate the natural logarithm of a value. Determine the lower bound for a dimension of an array. Calculate the long version of a value. equal to. Generate a random number between 0 to 1. Generate a random number within the range of two values. Calculate the sine of an angle. Determine the upper bound for a dimension of an array. Calculate the square root of a value. Calculate the tangent of an angle. . Eliminate the members of an array. (statement) Rnd (function) Sgn (function) Sin (function) Sqr (function) Tan (function) Array handling Keyword ArrayDims Used to Return the number of dimensions in an array. Initialize the random number generator with a new seed. Sort a single-dimensional array. Raise e to the power of a value. Redimension an array. Int also truncates numbers in a negative direction. Calculate the integer portion of a value. specifying new upper & lower bounds for each dimension. (function) ArraySort (statement) Erase (statement) LBound (function) Option Base (statement) ReDim (statement) UBound (function) MicroStation BASIC Guide 7-3 7 Standard BASIC Reference Determine if a number is less than. Calculate the cosine of an angle.BASIC Command Overview Keyword CInt (function) CLng (function) Cos (function) CSng (function) Exp (function) Fix (function) Int (function) Log (function) Random (function) Randomize Used to Convert an expression to an integer. Set the default lower bound for all array declarations. or greater than zero. Calculate the single-precision version of a value. Calculate the integer portion of a value.

Capability% (method) Basic. Repeat a block of statements while or until a condition is true. Obtain the text corresponding to a run-time error.. Pause for a specified length of time. Print a specified number of spaces to an output device..FreeMemory (property) Basic. Obtain the value of the run-time error.OS (property) Basic.) Induce a particular run-time error. Return 0 (for compatibility with other versions of BASIC). Determine the host machine operating environment. Determine available memory in BASIC’s data space. 7-4 MicroStation BASIC Guide .Eoln$ (property) Basic. Print the number of spaces necessary to reach a specified column. Set the value of the current run-time error (for use with the Error statement.BASIC Command Overview System Keyword Basic. Determine the file system path separator used by the host machine. Program control Keyword Call (statement) Declare (statement) Do. Create a prototype for a routine that occurs later in the source module. Print text to an output device.PathSeparator$ (property) Err (function) Err (statement) Error (statement) Error$ (function) Used to Determine the capabilities of the host machine.Loop (statement) Used to Transfer program control to a subroutine. Miscellaneous Keyword Beep (statement) Erl (function) Print (statement) Sleep (statement) Spc (function) Tab (function) Used to Cause the system to beep once. Determine the EOL character sequence of the host machine.

Terminate a Do…Loop statement. Terminate execution of a subroutine.End Function (statement) GoSub (statement) Goto (statement) If. (statement) Stop (statement) Sub.Next (statement) Function.Else (statement) On Error (statement) Resume (statement) Return (statement) Select. Obtain the value of an environment variable. Establish default variable types. Declare global or public variables. MicroStation BASIC Guide 7-5 7 While.... Declare a constant. Terminate execution of a function.Then. Declare a list of local variables and their corresponding types and sizes. Repeat a block of statements a specific number of times.End Sub (statement) Variable control Keyword Command$ (function) Const (statement) DEF… (statement) Dim (statement) Environ$ (function) Global (statement) Used to Obtain a string containing the arguments passed to the macro from the command line when the macro was started.. Terminate a For…Next statement..BASIC Command Overview Keyword End (statement) Exit Do (statement) Exit For (statement) Exit Function Used to Terminate execution of the current macro. Execute a block of statements based on the value of an expression... Standard BASIC Reference Main (statement) Define the subroutine that initially receives control when macro execution commences.. End the current error handler and continue execution. Suspend execution of the macro and break into the debugger.. Transfer program control to a specific point with the intent to return to the statement following.. (statement) Exit Sub (statement) For.. Define a user subroutine. Define a user function.. Unconditionally transfer program control to a specific point... Conditionally execute a block of statements.Case Define the action taken when a run-time error occurs.Wend (statement) Repeat a block of statements while a condition is true. Transfer program control to the statement following the most recent GoSub. .

Obtain a specified number of characters from the right end of a string. Declare private variables. Assign a value to an object variable. Convert a numeric value into an octal string. Establish whether string comparisons are to be case sensitive or not. Determine the number of lines in a text buffer. Define a structure that can be subsequently used by the Dim statement to declare a variable of that type. Convert a string to lower case. Replace a substring of a string. Obtain a substring from a string. Obtain the character for a numeric code. Obtain items from within a formatted list.BASIC Command Overview Keyword Let (statement) Private (statement) Public (statement) Set (statement) Type (statement) Used to Assign the result of an expression to a variable. Convert an expression into a string without leaving white space. Obtain one or more lines from a text buffer. Determine the length of a string or the number of bytes in a nonstring variable. Format a string. A string that contains no characters and requires no storage. Obtain the position of a string within another string. Declare public or global variables. Convert a numeric value into a hexadecimal string. Determine how many items are in a formatted list. Obtain a specified number of characters from the left end of a string. Copy a string padding with spaces at the beginning. Remove leading spaces from a string. Copy a string padding with spaces at the end or copy a structure. Character and string manipulation Keyword Asc (function) Chr$ (function) CStr (function) Format$ (function) Hex$ (function) InStr (function) Item$ (function) ItemCount (function) LCase$ (function) Left$ (function) Len (function) Line$ (function) LineCount (function) LSet (statement) LTrim$ (function) Mid$ (function) Mid$ (statement) Null (function) Oct$ (function) Option Compare Used to Obtain the numeric code for a character. (statement) Right$ (function) RSet (statement) 7-6 MicroStation BASIC Guide .

File handling Standard BASIC Reference Keyword Close (statement) Dir$ (function) ebArchive (constant) ebDirectory (constant) ebHidden (constant) ebNone (constant) ebNormal (constant) ebReadOnly (constant) ebSystem (constant) ebVolume (constant) Eof (function) FileAttr (function) FileCopy (statement) FileDateTime Used to Close opened files. Fill an array with filenames from disk. Obtain a file’s date and time. Obtain the file mode or file handle. Determine if the end of a file has been reached. Obtain one or more complete words from a string. read only. Fill an array with directory names from disk. Copy a file. Convert a string into a number. (function) FileDirs (statement) FileExists (function) FileLen (function) FileList (statement) FileParse$ (function) MicroStation BASIC Guide 7-7 7 . Compare two strings.BASIC Command Overview Keyword RTrim$ (function) Space$ (function) Str$ (function) StrComp (function) String$ (function) Trim$ (function) UCase$ (function) Val (function) Word$ (function) WordCount (function) Used to Remove trailing spaces from a string. Extract a portion of a filename from a filename string. Determine if a file exists. Archived file attribute. Select Normal files — archive. Volume attribute. Create a string containing a specified number of spaces. Determine the length of a file in bytes. Create a string containing a specified number of a specific character. Directory attribute. Count the number of words in a string. Hidden file attribute. System file attribute. Select files with no attributes. Obtain a list of the files in a directory. Read only file attribute. Convert an expression into a string. Convert a string to upper case. or no attribute. volume. Remove both leading and trailing spaces from a string.

Close all open files. Retrieve text from a sequential file. Set the position of the file pointer. Write formatted text to a sequential file. Open a file for read and/or write operations. Create a new directory on the disk. Obtain the position of the file pointer. Write text to a sequential file. Add a time interval to a date. Delete file(s). Determine the length of a file. Obtain a portion of a date/time expression. Convert a specific date to “days since December 30. Determine the position of a file’s file pointer. Obtain a file’s attributes. (statement) Loc (function) Lock (statement) Lof (function) MkDir (statement) Name (statement) Open (function) Print# (statement) Put (statement) Reset (statement) RmDir (statement) Seek (function) Seek (statement) SetAttr (statement) UnLock (statement) Width# (statement) Write # (statement) Date and time Keyword Date$ (function) Date$ (statement) DateAdd (function) DateDiff (function) DatePart (function) DateSerial (function) Used to Obtain the current system date as a 10-character string. Delete a directory. Write data to a random or binary file.BASIC Command Overview Keyword FreeFile (function) Get (statement) GetAttr (function) Input # (statement) Input$ (function) Kill (statement) Line Input # Used to Obtain the next available file number for use with the Open command. Determines the number of time intervals between two dates. 1899” format. Restore access by other processes to a locked portion of a file. 7-8 MicroStation BASIC Guide . Prevent a section of a file from being accessed by other processes. Specify the line width for a sequential file. Change a file’s attributes. Rename a file. Retrieve data from a random or binary file. Set the system date. Retrieve formatted text from a file. Retrieve an entire line of text from a file.

Obtain the month of the year from a date value. . Convert a specific time to “days since December 30. MicroStation BASIC Guide 7-9 7 Standard BASIC Reference Convert a time from a string to a value. from a date value. Calculate the payments for an annuity. Obtain the current date and time in “days since December 30. Obtain the hour of the day (24 hour format) from a time value. Calculate the rate of interest for each period of an annuity. Obtain the day of the month from a date value. Calculate the present value of an annuity. Business calculations Keyword DDB (function) Fv (function) IPmt (function) IRR (function) MIRR (function) NPer (function) Npv (function) Pmt (function) PPmt (function) Pv (function) Rate (function) Sln (function) SYD (function) Used to Calculate the depreciation of an asset using the double-declining balance method. Obtain the minute of the hour from a time value. Calculate the net present value of an annuity. Calculate the number of periods of an annuity. Calculate the internal rate of return for a series of payments and receipts.BASIC Command Overview Keyword DateValue (function) Day (function) Hour (function) Minute (function) Month (function) Now (function) Second (function) Time$ (function) Time$ (statement) Timer (function) TimeSerial (function) TimeValue (function) Weekday (function) Year (function) Used to Convert a date from a string to a double-precision value. Calculate the modified internal rate of return for a series of payments and receipts. Obtain the current time as an 8-character string. Obtain the year from a date value. 1899” format. Calculate the straight-line depreciation of an asset. Set the system time. Obtain the day of the week. Calculate the principal payment for a given period of an annuity. Calculate the future value of an annuity. Obtain the second of the minute from a time value. Calculate the sum of year’s digits depreciation of an asset. Calculate the interest payments for an annuity. Obtain the number of seconds since midnight. 1899” format.

Set the timeout for DDE command completion.BASIC Command Overview Dynamic Data Exchange (DDE). 7-10 MicroStation BASIC Guide . Initiate a conversation with a DDE server application. Close all DDE channels. Set the value of a data item in another application. Windows platforms only Keyword DDEExecute DDEInitiate DDEPoke DDERequest DDESend DDETerminate DDETerminateAll DDETimeOut Used to Send an execute message to another application. Close a DDE channel. Get a string value associated with a data item. Initialize a DDE link to another application.

A to Z Reference

A to Z Reference
This section contains a complete, alphabetical reference to all commands in the standard BASIC language. When syntax is described, the following notations are used:
Notation
keyword

Description
Elements belonging to the standard BASIC language, referred to in this manual as keywords, appear in the typeface shown to the left. Items that are to be replaced with information that you supply appear in italics. The type of replacement is indicated in the following description. The presence of a type-declaration character following a parameter signifies that the parameter must be a variable of that type or an expression that evaluates to that type. A function’s return type is indicated by a type-declaration character. This is strictly informative and does not mean that the function must be accompanied by that type-declaration character. Functions that return strings are an exception to this rule. In their case, the $ character is required. Square brackets indicate that the enclosed items are optional. Braces indicate that you must choose one of the enclosed items, which are separated by a vertical bar. Words that must appear as part of a statement’s syntax are shown without type-declaration characters (for example, To).

variable

text$

rnd#

[parameter%] {Input | Binary} start% To end%

&
string_expression1 & string_expression2

Adds string_expression2 to the end of string_expression1 and returns a string with a length that is the sum of the lengths of string_expression1 and string_expression2. This operator can be used interchangeably with the plus (+) operator when used with string operands and is provided for clarity of code. Example Sub Main()
'Assign a concatenated string to variable s$ and a string to s2$, 'then concatenate the two variables and display in a dialog box. s$ = "This string" & " is concatenated" s2$ = " with the & operator" MbeMessageBox s$ & s2$ End Sub

MicroStation BASIC Guide

7-11

7

Descr. Returns the concatenation of string_expression1 and string_expression2.

Standard BASIC Reference

A to Z Reference

'
'text

Descr. Causes the compiler to skip all characters between this character and the end of the current line. This is very useful for commenting your code to make it more readable. Example Const crlf = Chr$(13) + Chr$(10)
Sub Main() 'This whole line is treated as a comment. i$ = "Strings" 'This is a valid assignment with a comment. This line will cause an error (the apostrophe is missing). End Sub

*
expression1 * expression2

Descr. Returns the product of expression1 and expression2. The operands can be expressions of any numeric data type. Example Sub Main()
'This example assigns values to two variables and their product to 'a third variable, then displays the product of S * T. S# = 123.55 T# = 2.55 U# = S * T MbeMessageBox Str$(S * T) End Sub

+
expression1 + expression2

Descr. If expression1 and expression2 are both numeric, then this operator returns the sum of expression1 and expression2. If both expressions are strings, then this operator returns a new string representing the concatenation of expression1 and expression2. Mixed string and numeric operands are invalid. For string operands, the plus (+) is interchangeable with the & operator. (See & [operator].) Example Sub Main()
'This example assigns string and numeric variable values and 'then uses the + operator to concatenate the strings and form the 'sums of numeric variables. i$ = "Strings" + " can be concatenated" j% = 120 + 5 'addition of numeric literals k# = j% + 2.7 'addition of numeric variable MbeMessageBox i$ + Str$(j%) + Str$(k#) End Sub

7-12

MicroStation BASIC Guide

A to Z Reference

expression1 - expression2

Descr. Returns the difference between expression1 and expression2. Example Sub Main()
'This example assigns values to two numeric variables and their 'difference to a third variable, then displays the result. I% = 100 J# = 22.55 K# = I - J MbeMessageBox "The difference is: " + Str$(K#) End Sub

/
expression1 / expression2

Example Sub Main()
'This example assigns values to two variables and their quotient to a 'third variable, then displays the result. I% = 100 J# = 22.55 K# = I / J MbeMessageBox "The quotient of I/J is: " + Str$(K#) End Sub

<
Descr. Returns TRUE if expression1 is less than expression2; otherwise, returns FALSE. If both expressions are strings, the < operator performs a case-sensitive comparison between the two string expressions, returning TRUE if expression1 is less than expression2. Lowercase characters in a string sort higher than uppercase characters, so a comparison of ‘a’ and ‘A’ would indicate that ‘A’ is less than ‘a’. Example Sub Main()
'Test two literals and display the result. If 5 < 2 Then MbeMessageBox "Five is less than Two" Else MbeMessageBox "Five is not less than Two" End If 'Test two strings and display the result.

MicroStation BASIC Guide

7-13

7

expression1 < expression2

Standard BASIC Reference

Descr. Returns the quotient of expression1 and expression2.

A to Z Reference
If "This string expression" < "That string" Then MbeMessageBox "This is less than That" Else MbeMessageBox "That is less than This" End If End Sub

<=
expression1 <= expression2

Descr. Returns TRUE if expression1 is less than or equal to expression2; otherwise, returns FALSE. If both expressions are strings, the <= operator performs a case-sensitive comparison between the two expressions, returning TRUE if expression1 is less than or equal to expression2. Lowercase characters in a string sort higher than uppercase characters, so a comparison of ‘a’ and ‘A’ would indicate that ‘A’ is less than ‘a’. Example Sub Main()
'Test two literals and display the result. If 5 <= 2 Then MbeMessageBox "Five is less than or equal to Two" Else MbeMessageBox "Five is not less than or equal to Two" End If 'Test two strings and display the result. If "This string" <= "That string" Then MbeMessageBox "This is less than or equal to That" Else MbeMessageBox "That is less than or equal to This" End If End Sub

<>
expression1 <> expression2

Descr. Returns TRUE if expression1 is not equal to expression2; otherwise returns FALSE. If the two expressions are strings, the <> operator performs a case-sensitive comparison between the two expressions, returning TRUE if expression1 is not equal to expression2. Lowercase characters in a string sort higher than uppercase characters, so a comparison of ‘a’ and ‘A’ would indicate that ‘A’ is less than ‘a’.

7-14

MicroStation BASIC Guide

A to Z Reference
Example Sub Main()
'Test two literals and display the result. If 5 <> 2 Then MbeMessageBox "Five is not equal to Two" Else MbeMessageBox "Five is equal to Two" End If 'Test two strings and display the result. If "This string" <> "That string" Then MbeMessageBox "This is not equal to That" Else MbeMessageBox "The strings are equal" End If End Sub

=
expression1 = expression2

Descr. Returns TRUE if expression1 is equal to expression2; otherwise returns FALSE. If the two expressions are strings, the = operator performs a case-sensitive comparison between the two expressions, returning TRUE if expression1 is equal to expression2. Strings of different lengths are never equal to one another. This operator is also used for assignment of values to variables. It operates as a logical equivalency operator only in a logical comparison context. Example Sub Main()
'Assignment of values: the variable S is assigned a value of 100.22. S# = 100.22 'Logical equivalence: the value of S is compared to 150.99. If S = 150.99 Then MbeMessageBox "The value of S is 150.99" Else MbeMessageBox "The value of S is not 150.99" End If End Sub

>
expression1 > expression2

MicroStation BASIC Guide

7-15

7

Standard BASIC Reference

A to Z Reference
Descr. Returns TRUE if expression1 is greater than expression2; otherwise returns FALSE. If the two expressions are strings, the > operator performs a case-sensitive comparison between the two expressions, returning TRUE if expression1 is greater than expression2. Example Sub Main()
'Test two literals and display the result. If 5 > 2 Then MbeMessageBox "Five is greater than Two" Else MbeMessageBox "Five is less than or equal to Two" End If 'Test two strings and display the result. If "This string" > "That string" Then MbeMessageBox "This is greater than That" Else MbeMessageBox "That is less than or equal to This" End If End Sub

>=
expression1 >= expression2

Descr. Returns TRUE if expression1 is greater than or equal to expression2; otherwise returns FALSE. If the two expressions are strings, the >= operator performs a case-sensitive comparison between the two expressions, returning TRUE if expression1 is greater than or equal to expression2. Example Sub Main()
'Test two literals and display the result. If 5 >= 2 Then MbeMessageBox "Five is greater than or equal to Two" Else MbeMessageBox "Five is less than Two" End If 'Test two strings and display the result. If "This string" >= "That string" Then MbeMessageBox "This is greater than or equal to That" Else MbeMessageBox "That is less than This" End If End Sub

\
expression1 \ expression2

7-16

MicroStation BASIC Guide

A to Z Reference
Descr. Returns the integer division of expression1 and expression2. This operator operates by rounding expression1 and expression2 prior to division. The integer part of the result is then returned as a nonfractional number. Example Sub Main()
'Assign the quotient of two literals to a variable and display the 'result. s% = 100.99 \ 2.6 MbeMessageBox "Integer divide of 100.99 \ 2.6 is: " & Str$(s) End Sub

^
expression1 ^ expression2

The following are special cases:
Special Case
n^0 0^-n 0^+n 1^n

Value
1 undefined 0 1

It is important to note that raising a number to a negative exponent produces a fractional result (either a Double or a Single). In the statement a% = b%^c%, the variables b and c are first promoted to Doubles, then the power operation is applied, and finally the result converted to an Integer (rounding, if necessary) and stored in a. Example Sub Main()
s# = 2 ^ 5 'Returns 2 to the 5th power. r# = 16 ^ .5 'Returns the square root of 16. MbeMessageBox "Two to the 5th power is: " & Str$(s) End Sub

_
s$ = "This is a very long line that I want to split " + _ "onto two lines"

MicroStation BASIC Guide

7-17

7

Standard BASIC Reference

Descr. Returns expression1 raised to the power specified in expression2. Fractional and negative exponents are allowed.

A to Z Reference
Descr. The ‘_’ character is the line-continuation character. This character allows you to split a single BASIC statement onto more than one line. The line-continuation character cannot be used within strings and must be preceded by white space (either a space or a tab). Example Const crlf = Chr$(13) + Chr$(10)
Sub Main() 'The line-continuation operator is useful when concatenating long 'strings. Msg$ = "This line is a line of text that" + crlf + "extends beyond " + "borders of the editor" + crlf + "so it is split into " _ + "multiple lines" 'It is also useful for separating and continuing long calculation 'lines: b# = .124 a# = .223 S# = ( (((Sin(b) ^ 2) + (Cos(a) ^ 2)) ^ .5) / _ (((Sin(a) ^ 2) + (Cos(b) ^ 2)) ^ .5) ) * 2.00 MbeMessageBox Msg + crlf + "The value of S is: " + Str$(S) End Sub

_

Abs
Abs%(number%) Abs&(number&) Abs!(number!) Abs#(number#)

Descr. Returns the absolute value of a given number. When Integer variables are assigned the absolute value of real numbers, the real number is rounded first, and the absolute value of the rounded number is returned. Example Sub Main()
'Assign absolute values to variables of 4 types and display the result. S1% = Abs(- 10.55) S2& = Abs(- 10.55) S3! = Abs(- 10.55) S4# = Abs(- 10.55) MbeMessageBox Str$(S1) + Str$(S2) + Str$(S3) + Str$(S4) End Sub

7-18

MicroStation BASIC Guide

A to Z Reference

And
expression1 And expression2

Descr. Returns TRUE if both expression1 and expression2 are TRUE. If either expression is FALSE, then the And operator returns FALSE. If the two expressions are numeric, then the result is the bitwise And of the two arguments. If either of the two operands is a floating-point number, then the two operands are first converted to Longs, then a bitwise And is performed. Example Sub Main()
N1 = 1001 N2 = 1000 B1 = True B2 = False 'Perform a numeric bitwise And operation and store the result in N3. N3 = N1 And N2 'Perform a logical And comparing B1 and B2 and display the result. If B1 And B2 Then MbeMessageBox "B1 and B2 is True; N3 is: " + Str$(N3) Else MbeMessageBox "B1 and B2 is False; N3 is: " + Str$(N3) End If End Sub

ArrayDims
ArrayDims%(arrayvariable)

Descr. Returns the number of dimensions of a given array. This function can be used to determine whether a given array contains any elements if the array is initially dimensioned with null dimensions and then redimensioned by another function, such as the FileList function, as shown in the following example. Example Sub Main()
'Allocate an empty (null-dimensioned) 'array; fill the array with a list of 'filenames, which resizes the array; then test the array dimension and 'display an appropriate message. Dim f$() FileList f$,"C:\*.BAT" If ArrayDims(f$) = 0 Then

MicroStation BASIC Guide

7-19

7

Standard BASIC Reference

A to Z Reference
MbeMessageBox "The array is empty" Else MbeMessageBox "The array size is: " + Str$(ArrayDims(F$)) End If End Sub

ArraySort
ArraySort s$() ArraySort a%() ArraySort a&() ArraySort a!() ArraySort a#()

Descr. Sorts a single-dimensioned array. If a string array is specified, then the routine sorts alphabetically in ascending order (using case-sensitive string comparisons). If a numeric array is specified, the ArraySort statement sorts smaller numbers to the lowest array index locations. A run-time error is generated if you specify an array with more than one dimension. Example Sub Main()
'Dimension an array and fill it with filenames using FileList, 'then sort the array and display it. Dim F$() FileList f$,"C:\*.*" ArraySort f$ result = MbeSelectBox% ("Choose a file", f$) End Sub

Asc
Asc%(text$)

Descr. Returns the numeric code for the first character of the given string. The return value is an Integer between 0 and 255. Example Sub Main()
s$ = "ABC" Dim a%(3) 'Fill the array with the ASCII values of the string s components and 'display the result. For i = 1 To 3 a%(i) = Asc(Mid$(s$,i,1))

7-20

MicroStation BASIC Guide

A to Z Reference
Next i MbeMessageBox Str$(a%(1)) + Str$(a%(2)) + Str$(a%(3)) End Sub

Atn
atn#(number#)

Descr. Returns the angle (in radians) whose tangent is number. Pi (3.1415926536) radians = 180 degrees. One radian = 57.2957795131 degrees. One degree = .0174532925 radians. Example Sub Main()

Basic.Capability%
Basic.Capability%(which%)

Descr. This method returns TRUE if the specified capability exists on the host operating environment; otherwise, this function returns FALSE. The which parameter specifies which capability to test for. It can be any of the following values:
Value
1 2 3 4 5 6

Returns TRUE if the platform supports
Disk drives System file attribute (ebSystem) Hidden file attribute (ebHidden) Volume label file attribute (ebVolume) Archive file attribute (ebArchive) Denormalized floating-point math

Example Sub Main()
'Test to see whether your current environment supports disk drives and 'hidden file attributes and display the result. Msg$ = "This OS " If Basic.Capability(1) Then

MicroStation BASIC Guide

7-21

7

Standard BASIC Reference

'Find the angle whose tangent is 1 (45 degrees) and display the result. a# = Atn(1.00) MbeMessageBox "1.00 is the tangent of " + Str$(a#) + " radians (45 degrees)" End Sub

A to Z Reference Msg = Msg + "supports disk drives. Before this number is returned.OS Basic. Returns a string containing the end-of-line character sequence appropriate to the host operating environment. This function returns the size of the largest free block in BASIC’s data space. BASIC's data space contains strings and dynamic arrays. consolidating free space into a single contiguous free block. Returns the number of bytes of free memory in BASIC’s data space.OS 7-22 MicroStation BASIC Guide . MbeMessageBox "The free memory space is: " + Str$(Basic. MbeMessageBox "This is the first line of text " + Basic. or a line-feed.FreeMemory Basic. the data space is compacted.Eoln$ Basic.FreeMemory& Descr. a carriage-return linefeed. Example Sub Main() 'Display free memory in a dialog box.Eoln$ + _ "The second line" End Sub Basic. This string will be either a carriage-return.FreeMemory) End Sub Basic. Example Sub Main() 'This example writes two lines of text in a message box." else Msg = Msg + "does not support disk drives.Eoln$ Descr." End If MbeMessageBox Msg End Sub Basic.

OS Select Case o% Case 2 S$ = "Win32" Case 12 S$ = "DOS" Case Else S$ = "Neither Win32 nor DOS" End Select MbeMessageBox "The current version was created for " + S$ End Sub Basic. NT. a backslash ‘\’.PathSeparator$ End Sub MicroStation BASIC Guide 7-23 7 Standard BASIC Reference . Value 2 3 4 5 7 8 10 12 13 Constant ebWin32 ebSolaris ebSunOS ebHPUX ebIrix ebAIX ebMacintosh ebDOS32 ebClix Platform Microsoft Win32 (’95. Returns a string containing the path separator appropriate for the host operating environment. Returns a number indicating the host operating environment. Win32s) Sun Solaris 2. o% = Basic.A to Z Reference Descr.PathSeparator$ Basic.x SunOS HP/UX Silicon Graphics IRIX IBM AIX Apple Macintosh MS-DOS Intergraph Clix Example Sub Main() 'Determine the OS this version was created for and display the 'appropriate message. Example Sub Main() MbeMessageBox "The path separator for this environment is: " + _ Basic. The returned string will be a slash ‘/’.PathSeparator$ Descr. or a colon ‘:’.

S$ = "Display this text" Example_Call "Display this text" Call Example_Call ("Second form of Call statement") End Sub CDbl CDbl#(number#) 7-24 MicroStation BASIC Guide . optionally passing the specified arguments. Example Sub Example_Call (S$) 'This subroutine is declared externally to Main and displays the text 'passed in the parameter S$. MbeMessageBox "Example CALL: " + S$ End Sub Sub Main() 'Assign a string variable to display. Makes a single system beep. The subroutine to which control is transferred by Call must be declared outside of the Main procedure. passing parameter S$ to be displayed in a 'message box within the subroutine. then call subroutine 'Example_Call.A to Z Reference Beep Beep Descr. as shown in the following example. Example Sub Main() 'Beep five times and display a reminder message. For i = 1 To 5 Beep Sleep(500) Next i MbeMessageBox "Do you have an upcoming appointment?" End Sub Call Call subroutine_name [(arguments)] Descr. Using this statement is equivalent to: subroutine_name [arguments] Use of the Call statement is optional. Transfers control to the given subroutine.

This function has the same effect as assigning the numeric expression number to a double-precision variable.44 MbeMessageBox Str$(CDbl(i * j)) MbeMessageBox Str$(CDbl(i) * j) MbeMessageBox Str$(CDbl(i) * CDbl(j)) End Sub Chr$ Chr$(Code%) Descr. Code must be an integer between 0 and 255. In addition. The Chr$ function can be used within constant declarations. as in the following example: Example Const crlf$ = Chr$(13) + Chr$(10) Sub Main() 'Concatenate carriage return (13) and line feed (10) to clf$. Dim a%(3) For i = 1 To 3 a%(i) = (64 + i) Next i MbeMessageBox Chr$(a(1)) + Chr$(a(2)) + Chr$(a(3)) End Sub CInt CInt%(number#) MicroStation BASIC Guide 7-25 7 Standard BASIC Reference . Returns the double-precision equivalent of the passed numeric expression (number). Returns the character whose value is Code. Code cannot be an expression.A to Z Reference Descr. CLF$ = Chr$(13) + Chr$(10) MbeMessageBox ("First line" + CLF + "Second line") 'Fill an array with the ASCII characters for ABC and display their 'corresponding characters. Example Sub Main() i% = 100 j! = 123. 'then display a multiple-line message using clf$ to separate lines.

55 and 100. The passed numeric expression must be within the following range: -2147483648 <= number <= 2147483647 A run-time error results if the passed expression is not within the above range. j# = 100.22 is: " + Str$(k)) End Sub CLng CLng&(number#) Descr. Returns the integer portion of the given expression.35 k% = CInt(I + J) MbeMessageBox("The integer sum of 50. then display '(note rounding).22 MbeMessageBox "CInt J = " + Str$(CInt(J)) '(3) Assign K (integer) to the CInt sum of I and J and display K (201).35 and 100. k% = CInt(I + J) MbeMessageBox("The integer sum of 100. CInt has the same effect as assigning a numeric expression to a variable of type Integer. i# = 100. Example Sub Main() 'This example demonstrates the various results of integer manipulation 'with CInt. '(1) Assign i to 100.22 is: " + Str$(k)) '(4) Reassign i to 50. CInt differs from the Fix and Int functions in that CInt rounds instead of truncating.A to Z Reference Descr.55 and display its integer representation (101). The passed numeric expression must be within the following range: -32768 <= number <= 32767 A run-time error results if the passed expression is not within the above range.35 and recalculate K. i# = 50. 7-26 MicroStation BASIC Guide . Returns a Long representing the result of the given numeric expression.22 and display the CInt representation (100).55 MbeMessageBox "CInt I = " + Str$(CInt(I)) '(2) Set J to 100. CLng has the same effect as assigning a numeric expression to a Long variable.

#3 Close End Sub and close them in various combinations. this statement closes all files."/s")) <> 0 Then MbeMessageBox "Macro started with /s switch" Else MbeMessageBox "Macro started without /s switch" End If MbeMessageBox "Startup line was: " + CMD$ End Sub MicroStation BASIC Guide 7-27 7 Standard BASIC Reference . 'Closes files 2 and 3. MbeMessageBox Str$(CLng(i * j)) 'Displays 12367. If no arguments are specified.[#] filenumber%]] Descr. the Close statement closes each specified file. Command$ Command$ Descr. Returns a string representing the argument from the command line used to start the macro. Input Access Read Lock Read Write as #1 len=128 Output as #2 Random as #3 Binary as #4 'Closes file 1 only. MbeMessageBox Str$(CLng(i) * CLng(j)) 'Displays 12400.666 'Display results for various conversions of i and j (note rounding).A to Z Reference Example Sub Main() i% = 100 j& = 123. End Sub Close Close [[#] filenumber% [. CMD$ = Command$ If (InStr(Cmd. and display the result. 'Closes all remaining files (4). Example Sub Main() 'Get the command line and parameters. Otherwise. MbeMessageBox Str$(CLng(i) * j) 'Displays 12366. Example Sub Main() 'Open four files Open "Test1" for Open "Test2" for Open "Test3" for Open "Test4" for Close #1 Close #2. check to see whether the string ' "/s" is present.

14159 / 4) MbeMessageBox "The cosine of 45 degrees is: " + Str$(C) End Sub CSng CSng!(number#) Descr.. Example Sub Main() 'Assign variables of different types and display their CSng 'conversions. Example Const CRLF = Chr$(13) + Chr$(10) Const T$ = "This is a constant" Sub Main() 'Display the declared constants in a dialog box (CRLF produces a new 'line in the dialog box).name = expression]. Returns the cosine of a given angle. 7-28 MicroStation BASIC Guide . Descr.. Declares a constant for use within the current macro. ✍ The constants are declared before the Sub Main declaration. The angle parameter is given in radians. name is only valid within the current BASIC macro. MbeMessageBox T + CRLF + "The constants are shown above" End Sub Cos Cos#(angle#) Descr. Example Sub Main() 'Assign the cosine of PI/4 radians (45 degrees) to C# and display its 'value. Calls to functions are not allowed except calls to the Chr$ function when used in the declarations part of the code or outside the Sub Main. C# = Cos(3. Returns a single representing the result of the given numeric expression number. expression must be assembled from literals or other constants..End Sub..A to Z Reference Const const name = expression [. This function has the same effect as assigning a numeric expression to a single variable.

A# = 123. the string returned by CStr will not contain a leading space if the expression is positive.A to Z Reference S1# = CSng(150. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'Assign two variables and display them using CStr conversions. Unlike Str$.456 MbeMessageBox CStr(A) + crlf + CStr(B) End Sub Date$ Date$[()] Date$ = newdate$ Descr.456 B# = -123.61010101) S2& = CSng(150.62020202) S3% = CSng(150. Returns a string representing the result of the given expression. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() ' This example saves the current date to Cdate$. Cdate$ = Date$() Date$ = "01/01/94" MbeMessageBox("Saved date is: " + Cdate + crlf + "Changed date is: " + _ Date$()) Date$ = Cdate MbeMessageBox("Restored date to: " + Cdate) End Sub MicroStation BASIC Guide 7-29 7 Standard BASIC Reference . The result is returned in floating point ‘E’ notation. The Date$ function returns the current system date as a 10-character string. then changes ‘ the date and displays the result.64040404) MbeMessageBox Str$(S1) + Str$(S2) + Str$(S3) + Str$(S4) End Sub CStr CStr(number#) Descr. The statement form of Date$ sets the system date to the specified date. It then changes the date back ' to the saved date and displays the result. if the result is very small or very large. The format for the date used by Date$ is MM-DD-YYYY.63030303) S4! = CSng(150.

day of the year. DateAdd adds a specified number (increment) of time intervals (interval$) to the specified date (date1).A to Z Reference DateAdd DateAdd#(interval$. a double-precision number that indicates the number of time intervals you wish to add. It can be any of the following: Time "y" "yyyy" "d" "m" "q" "ww" "h" "n" "s" "w" Interval Day of the year Year Day Month Quarter Week Hour Minute Second Weekday To add days to a date. a double-precision number or a valid date/time. 1992") 7-30 MicroStation BASIC Guide . 2. String expression. The DateAdd function returns a double-precision number representing the sum of date1 and a specified number (increment) of a specified time interval (interval$). "December 31. as they are all equivalent ("d". increment&. DateAdd will never return an invalid date/time expression. Positive values result in dates in the future. The following example adds two months to December 31. 1993.” date1 The interval$ parameter specifies what unit of time is to be added to the given date. date1$ | date1#) Descr. negative values result in dates in the past. you may use either day. "y". The following table describes the parameters to the DateAdd function: Parameter interval$ increment Description a string expression that indicates the time interval used in the addition. "w"). 1992: s# = DateAdd("m". or weekday. An example of a valid date/time string would be “January 1.

Dim dDate# Dim sDate$ sDate$ = Date$ NewDate# = DateAdd("yyyy". A run-time error is generated if you attempt to subtract a time interval that is larger than the time value of the date. 2. and two days to it. 1993". The following table describes the parameters: Parameter interval$ date1 Description a string expression that indicates the specific time interval you wish to find the difference between. 1993". date2$ | date2#) Descr. a double-precision number or a valid date/time string expression. one week. NewDate) NewDate = DateAdd("dd". Example Sub Main() 'This example gets today's date using the Date$ function. date2 MicroStation BASIC Guide 7-31 7 Standard BASIC Reference . sDate) NewDate = DateAdd("mm". not "February 31. adds one 'year. An example of a valid date/time string would be "January 1. and then displays the 'result in a dialog box. "long date") MbeMessageBox s$ End Sub DateDiff DateDiff&(interval$. 1. two months. s is returned as the double-precision number equal to "February 28. NewDate) NewDate = DateAdd("ww". 1993". two months. 1993". date1$ | date1#.A to Z Reference In this example. and two days from now will be: " s$ = s$ + format$(NewDate. An example of a valid date/time string would be "January 1. one week. The DateDiff function will return the number of days or the number of whole weeks between two dates. NewDate) s$ = "One year. Returns a double-precision number representing the number of given time intervals between date1 and date2. a double-precision number or a valid date/time string expression. 3. 2.

A to Z Reference The following table lists the valid time interval strings and the meanings of each. The time interval weekday ("w") will return the number of weekdays occurring between date1 and date2. the function will return the number of calendar weeks between date1 and date2. you may use either day or day of the year. 10. Today$ = Date$ TodayR# = DateValue(Date$) NextWeek# = DateAdd("d". If date1 falls on a Sunday. but if date2 falls on a Sunday. then that day is counted. as they are both equivalent ("d". Today. Today. NextWeek) Difweek# = DateDiff("ww". DateDiff will return a negative date/time value if date1 occurs later in time than date2. However. it is not counted. The Format$ function uses the same expressions. It then 'calculates the difference between the two dates in days and weeks 'and displays the result. if the time interval is week ("ww"). counting the first occurrence but not the last. Time "y" "yyyy" "d" "m" "q" "ww" "h" "n" "s" "w" Interval Day of the year Year Day Month Quarter Week Hour Minute Second Weekday To find the number of days between two dates. NextWeek) S$ = "The difference between " + Str$(Today) + " and " + Str$(NextWeek) S$ = S$ + " is: " + Str$(Difdays) + " days or " + Str$(DifWeek) + _ " weeks" 7-32 MicroStation BASIC Guide . "y"). Example Sub Main() 'This example gets today's date and adds 10 days to it. Today) Difdays# = DateDiff("d". counting the number of Sundays.

The Format$ function uses the same expressions.Today) Mo = DatePart("m".Today) S$ = "Quarter: " + Str$(Qtr) + crlf MicroStation BASIC Guide 7-33 7 Standard BASIC Reference either a double-precision number or a valid date/ time string expression. Returns a number representing a specified part of a valid date/time expression.Today) Wk = DatePart("ww".Today) Da = DatePart("d".A to Z Reference MbeMessageBox S$ End Sub DatePart DatePart%(interval$. The following table lists the valid time interval strings and the meanings of each. 1993". Time "y" "yyyy" "d" "m" "q" "ww" Interval Day of the year Year Day Month Quarter Week The weekday expression starts with Sunday as 1 and ends with Saturday as 7. The DatePart function decomposes the given date and returns a given date/time element. date1$ | date1#) Descr. Example const crlf = chr$(13) + chr$(10) Sub Main() 'This example displays the parts of the current date Today$ = Date$ Qtr = DatePart("q". The following table describes the parameters: Parameter interval$ date1 Description a string expression that indicates the specific time interval you wish to identify within the given date. . An example of a valid date/ time string would be "January 1.Today) Yr = DatePart("yyyy".

Returns a double-precision number representing the date contained in the specified string argument. Example Sub Main() 'This example converts a date to a real number representing the 'serial date in days since Dec 30. Tdate$ = Date$ TDay! = Day(DateValue(Tdate)) MbeMessageBox ("The day part of " + Tdate + " is: " + Str$(TDay)) End Sub 7-34 MicroStation BASIC Guide . Tdate$ = Date$ TDay = DateValue(Tdate) MbeMessageBox Tdate + "The date value is: " + Str$(Tday) End Sub Day Day%(serial#) Descr. is: " + Str$(Tdate) End Sub DateValue DateValue#(date_string$) Descr. Returns the day of the date encoded in the specified serial parameter.22) MbeMessageBox "DateSerial value for Aug 22. month%.08. The DateSerial function returns a double-precision number representing the specified date. Example Sub Main() 'This example returns the day of the month for today's date. 1990. Example Sub Main() 'This example returns the day of the month for today's date.A to Z Reference S$ = S$ + "Year S$ = S$ + "Month S$ = S$ + "Week S$ = S$ + "Day MbeMessageBox S$ End Sub : : : : " " " " + + + + Str$(Yr) Str$(Mo) Str$(Wk) Str$(Da) + + + + crlf crlf crlf crlf DateSerial DateSerial#(year%. Tdate# = DateSerial(1990. The value returned is between 1 and 31 inclusive. 1899 (which is day 0). where Dec 30. 1899 is 0. The number is returned in days. day%) Descr.

Salvage#. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example calculates the depreciation for capital equipment 'that cost $10. 2000. Life#. This function calculates the depreciation of an asset for a specified Period of time using the double-declining balance method.A to Z Reference DDB DDB#(Cost#. S$ = "Depreciation Table" + crlf + crlf For yy = 1 To 4 CurDep# = DDB(10000.0. 10.000. The double-declining balance method calculates the depreciation of an asset at an accelerated rate. Period#) Descr. The depreciation is at its highest in the first period and becomes progressively lower in each additional period. then Period must also be expressed in months. DDB uses the following formula to calculate the depreciation: DDB =((Cost . yy) S$ = S$ + "Year " + Str$(yy) + " : " + Str$(CurDep) + crlf Next yy MbeMessageBox S$ End Sub MicroStation BASIC Guide 7-35 7 Standard BASIC Reference a double-precision number that represents the initial cost of the asset . The dialog box displays the depreciation for each 'of the first 4 years. If Life is expressed in months.000 as scrap. has a service life of 10 years.0.Total_depreciation_from_all_other_periods) * 2)/Life DDB uses the following parameters: Parameter Cost Salvage Life Period Description a double-precision number that represents the estimated value of the asset at the end of its predicted useful life a number that represents the predicted length of the asset's useful life a number that represents the period for which you wish to calculate the depreciation Life and Period must be expressed using the same units. and is worth '$2.

A to Z Reference

DDEExecute
DDEExecute channel%, command$

Descr. Sends an execute message to another application. The channel must first be initiated using DDEInitiate. An error will result if channel is invalid. If the receiving application does not execute the instructions, BASIC generates a run-time error. The format of command$ depends on the receiving application. Win32 is the platform that applies to DDEExecute. The DDEML library is required for DDE support. This library is loaded when the first DDEInitiate statement is encountered and remains loaded until the BASIC system is terminated. Thus, the DDEML library is required only if DDE statements are used within a macro. Example Sub Main()
Dim ch As Integer q$ = Chr$(34) ch = DDEInitiate(“Excel”, “C:\SHEETS\TEST.XLS”) CMD$ = “[SELECT(“ + q$ + “R1C1:R8C1” + q$ + “)]” DDEExecute ch,cmd$ DDETerminate ch End Sub

DDEInitiate
DDEInitiate%(app$, topic$)

Descr. Initializes a DDE link to another application and returns a unique number subsequently used to refer to the open DDE channel. The function returns 0 if BASIC cannot establish the link. This will occur under any of the following circumstances: 1. The specified application is not running. 2. The topic was invalid for that application. 3. Memory or system resources are insufficient to establish the DDE link. app$ specifies the name of the application (the server) with which a DDE conversion will be established. topic$ specifies the name of the topic for the conversation. The possible values for

7-36

MicroStation BASIC Guide

A to Z Reference
this parameter are described in the documentation for the server application. Win32 is the platform that applies to DDEInitiate. The DDEML library is required for DDE support. This library is loaded when the first DDEInitiate statement is encountered and remains loaded until the BASIC system is terminated. Thus, the DDEML library is required only if DDE statements are used within a macro. Example Sub Main()
Dim ch As Integer q$ = Chr$(34) ch = DDEInitiate(“Excel”, “C:\SHEETS\TEST.XLS”) CMD$ = “[SELECT(“ + q$ + “R1C1:R8C1” + q$ + “)]” DDEExecute ch, cmd$ DDETerminate ch End Sub

DDEPoke
DDEPoke channel%, dataItem$, value$

Descr. Sets the value of a data item in the receiving application associated with an open DDE link. The channel must first be initiated using DDEInitiate. An error will result if channel is invalid. The format for dataItem$ and value$ depends on the receiving application. Win32 is the platform that applies to DDEPoke. The DDEML library is required for DDE support. This library is loaded when the first DDEInitiate statement is encountered and remains loaded until the BASIC system is terminated. Thus, the DDEML library is required only if DDE statements are used within a macro. Example Sub Main()
ch = DDEInitiate(“Excel”, “C:\SHEETS\TEST.XLS”) DDEPoke ch, “R1C1”, “980” DDETerminate ch End Sub

MicroStation BASIC Guide

7-37

7

Standard BASIC Reference

A to Z Reference

DDERequest
DDERequest$ (channel%, dataItem$)

Descr. Returns a string representing the value of the given data item in the receiving application associated with the open DDE channel. The channel must first be initiated using DDEInitiate. An error will result if channel is invalid. The formats for dataItem$ and the returned value depend on the receiving application. Win32 is the platform that applies to DDERequest. The DDEML library is required for DDE support. This library is loaded when the first DDEInitiate statement is encountered and remains loaded until the BASIC system is terminated. Thus, the DDEML library is required only if DDE statements are used within a macro. Example Sub Main()
ch = DDEInitiate(“Excel”, “C:\SHEETS\TEST.XLS”) s$ = DDERequest$(ch, “R1C1”) DDETerminate ch MbeMsgBox s$ End Sub

DDESend
DDESend application$, topic$, item$, data$

Descr. Initiates a DDE conversation with the server as specified by application$ and topic$ and sends that server a new value for the specified item. The DDESend statement performs the equivalent of the following statements:
ch% = DDEInitiate(application$, topic$) DDEPoke ch$, item$, data$ DDETerminate ch%

Win32 is the platform that applies to DDESend. The DDEML library is required for DDE support. This library is loaded when the first DDEInitiate statement is encountered and remains loaded until the BASIC system is terminated. Thus, the DDEML library is required only if DDE statements are used within a macro. Example ‘ The following code fragment sets the content of the first cell in an
‘ Excel spreadsheet.

7-38

MicroStation BASIC Guide

A to Z Reference
On Error Goto Trap1 DDESend “Excel”, “C:\EXCEL\TEST.XLS”, “R1C1”, “Hello, world.” On Error Goto 0 ‘ Add more lines here ... Trap1: MbeMsgBox “Error sending data to Excel.” Exit Sub ‘Reset error handler

DDETerminate
DDETerminate channel%

Descr. Closes the specified DDE channel. The channel must first be initiated using DDEInitiate. An error will result if channel is invalid.

Win32 is the platform that applies to DDETerminate. The DDEML library is required for DDE support. This library is loaded when the first DDEInitiate statement is encountered and remains loaded until the BASIC system is terminated. Thus, the DDEML library is required only if DDE statements are used within a macro. Example Sub Main()
Dim ch As Integer q$ = Chr$(34) ch = DDEInitiate(“Excel”, “C:\SHEETS\TEST.XLS”) CMD$ = “[SELECT(“ + q$ + “R1C1:R8C1” + q$ + “)]” DDEExecute ch, cmd$ DDETerminate ch End Sub

DDETerminateAll
DDETerminateAll

Descr. Closes all open DDE channels. All open DDE channels are automatically terminated when the macro ends. Win32 is the platform that applies to DDETerminateAll. The DDEML library is required for DDE support. This library is loaded when the first DDEInitiate statement is encountered and remains
MicroStation BASIC Guide

7-39

7

Standard BASIC Reference

All open DDE channels are automatically terminated when the macro ends.

A to Z Reference
loaded until the BASIC system is terminated. Thus, the DDEML library is required only if DDE statements are used within a macro. Example Sub Main()
Dim ch As Integer q$ = Chr$(34) ch = DDEInitiate(“Excel”, “C:\SHEETS\TEST.XLS”) CMD$ = “[SELECT(“ + q$ + “R1C1:R8C1” + q$ + “)]” DDEExecute ch, cmd$ DDETerminateAll End Sub

DDETimeOut
DDETimeOut milliseconds&

Descr. This statement sets the number of milliseconds that must elapse before a DDE command times out. The default is 10,000 (10 seconds). Win32 is the platform that applies to DDETimeOut. The DDEML library is required for DDE support. This library is loaded when the first DDEInitiate statement is encountered and remains loaded until the BASIC system is terminated. Thus, the DDEML library is required only if DDE statements are used within a macro. Example Sub Main()
Dim ch As Integer q$ = Chr$(34) ch = DDEInitiate(“Excel”, “C:\SHEETS\TEST.XLS”) DDETimeOut (20000) CMD$ = “[SELECT(“ + q$ + “R1C1:R8C1” + q$ + “)]” DDEExecute ch, cmd$ DDETerminate ch End Sub

Declare
Declare Sub name [([argumentlist])] Declare Function name [([argumentlist])] [As type]

Descr. You can use the Declare statement to create a prototype for a BASIC routine that occurs later in the source module. The name parameter is any valid BASIC name. When you declare functions, you can include a type-declaration character to indicate the return type.

7-40

MicroStation BASIC Guide

A to Z Reference
The optional argumentlist specifies the arguments received by the routine. By default, arguments are passed by reference. When a routine requires a value rather than a reference, include the ByVal keyword. For example, the following subroutine:
Sub MessageBeep (ByVal numBeeps%, message#)

would be declared as follows:
Declare Sub MessageBeep (ByVal numBeeps%, message#)

For function declarations, the return type can be specified using a type-declaration character (i.e., $, % or &) or by specifying the [As type] clause. The valid types are Integer, Long and String.
Declare statements must appear outside of any Sub or Function declaration. Declare statements are only valid during the life of that macro.

DEF…
DEFInt letterrange DEFLng letterrange DEFStr letterrange DEFsng letterrange DEFdbl letterrange

Descr. Establishes the default type assigned to undeclared or untyped variables. The DEF… statement controls automatic type declaration of variables. Normally, if a variable is encountered that hasn't yet been declared with the Dim statement or does not appear with an explicit type-declaration character, then that variable is declared implicitly as an integer (DEFInt A-Z). This can be changed using the DEF… statement to specify starting letter ranges for type other than integer. The letterrange parameter is used to specify starting letters. Thus, any variable that begins with a specified character will be declared using the specified type. The syntax for letterrange is:
letter [-letter] [,letter [-letter]]... DEF… variable types are superseded by an explicit type

declaration—using either a type-declaration character or the Dim statement.

MicroStation BASIC Guide

7-41

7

Standard BASIC Reference

A to Z Reference
DEF… only affects how macros are compiled and has no effect at run time. DEF… can only appear outside all Sub and Function

declarations. Example DEFStr a-l
DEFLng m-r DEFSng s-u DEFDbl v-w DEFInt x-z Sub Main() a = "This stuff" m = 100.52 s = 100.52 v = 100.55 x = 100.52 MbeMessageBox a & Str$(m) & Str$(s) & Str$(v) & Str$(x) End Sub

Dim
Dim name [(<subscripts>)] [As [New] type] [,name [(<subscripts>)] _ [As [New] type]]...

Descr. Declares a list of local variables and their corresponding types and sizes. If a type-declaration character is used when specifying name (such as %, &, $ or !), the optional [As type] expression is not allowed. For example, the following are allowed: Example Dim Temperature As Integer
Dim Temperature%

The subscripts parameter allows the declaration of dynamic and fixed arrays. subscripts uses the following syntax:
[lower to] upper [,[lower to] upper]...

The lower and upper parameters are Integers specifying the lower and upper bounds of the array. If lower is not specified, then the lower bound as specified by Option Base is used (or 0 if no Option Base statement has been encountered). BASIC supports a maximum of 60 array dimensions. The total size of an array (not counting space for strings) is limited to 64K. Dynamic arrays are declared by not specifying any bounds: Example
Dim a()

7-42

MicroStation BASIC Guide

A to Z Reference
The type parameter specifies the type of the data item being declared. It can be any of the following data types: String, Integer, Long, Single, Double, Object, application-defined object, application-defined data type, or any user-defined data type. A Dim statement within a subroutine or function declares variables local to that subroutine or function. If the Dim statement appears outside of any subroutine or function declaration, then that variable has the same scope as variables declared with the Private statement.

Creating New Objects The optional [New] keyword is used to declare a new instance of the specified application-defined object. This keyword can only be used with application-defined object data types. Furthermore, this keyword cannot be used when declaring arrays.
At run time, the application or extension that defines that object type is notified that a new object is being defined. The application should respond by creating a new physical object (within the appropriate context) and returning a reference to that object, which is immediately assigned to the variable being declared. When that variable goes out of scope (i.e., the Sub or Function procedure in which the variable is declared ends), the application is notified. The application can choose any appropriate actions, such as destroying the physical object. Example Sub Main()
'The following are examples using the Dim statement to declare various 'variable types. Dim a As integer Dim a% Dim b As long Dim b&

MicroStation BASIC Guide

7-43

7

Standard BASIC Reference

Implicit Variable Declaration If BASIC encounters a variable that has not been explicitly declared with Dim, then the variable will be implicitly declared using the specified type-declaration character (%, $ or &). If the variable appears without a type-declaration character, then the first letter is matched against any pending DEF… statements, using the specified type if found. If no DEF… statement has been encountered corresponding to the first letter of the variable name, then Integer is used.

A to Z Reference
Dim c As string Dim c$ Dim MyArray(10) As integer Dim MyStrings$(2,10) Dim FileNames$(5 to 10) Dim Values(1 to 10, 100 to 200) End Sub

Dir$
Dir$[(filespec$ [,attributes])]

Descr. If filespec$ is specified, then the Dir$ function returns the first file matching that filespec$. If filespec$ is not specified, then Dir$ returns the next file matching the initial filespec$ as shown in the example. The filespec$ argument can include wild cards, such as * and ?. The * character matches any sequence of zero or more characters, whereas the ? character matches any single character. Multiple *'s and ?'s can appear within the expression to form complete searching patterns. The following table shows some examples:
This pattern
*S*.TXT

Matches these files
SAMPLE.TXT GOOSE.TXT SAMS.TXT CAT.TXT ACATS.TXT CAT CAP.TXT CAT CUT CT (All files)

Doesn’t match these files
SAMPLE SAMPLE.DAT CAP.TXT CAT.DOC CAT.TXT CAPIT

C*T.TXT C*T C?T

*

An error is generated if Dir$ is called without first calling it with a valid filespec$. If there is no matching filespec$, then an empty string is returned. If no path is specified on filespec$, then the current directory is used.

7-44

MicroStation BASIC Guide

A to Z Reference
You can control which files are included in the search by specifying the optional attributes parameter. This parameter contains any OR’ed combination of the following attributes:
Constant
ebNormal ebReadOnly ebHidden ebSystem ebArchive

Value
0 1 2 4 32

Includes
Clear the read-only and archive attributes Set read-only attribute Set hidden attribute Set system file attribute Set archive attribute

Example Const crlf = Chr$(13) + Chr$(10)
Sub Main() 'This example dimensions a null array and fills it with directory 'entries. The result is displayed in a dialog box. Dim a$(10) a(1) = Dir$("*.*") i% = 1 While (a(i) <> "") And (i < 10) i = i+1 a(i) = Dir$ Wend MbeMessageBox a(1) + crlf + a(2) + crlf + a(3) + crlf + a(4) End Sub

Do...Loop
Do {While | Until} condition statements Loop Do statements Loop {While | Until} condition Do statements Loop

Descr. Repeats a block of BASIC statements while a condition is TRUE or until a condition is TRUE. If the {While | Until} conditional clause is not specified, then the loop repeats the statements forever (or until BASIC encounters an Exit Do statement). The condition parameter specifies any Boolean expression. Example Const crlf = Chr$(13) + Chr$(10)
Sub Main() 'The first example uses the Do...While statement, which performs the 'iteration, then checks the condition, and repeats if the condition

MicroStation BASIC Guide

7-45

7

Standard BASIC Reference

A to Z Reference
'is True. Dim a$(100) i% = 0 Do i = i+1 If i = 1 Then a(i) = Dir$("*.*") Else a(i) = Dir$ End If Loop While (a(i) <> "") Msg$ = "There are " + Str$(i) + " files found" + crlf MbeMessageBox Msg + a(1) + crlf + a(2) + crlf + a(3) + crlf + a(10) 'The second example uses the Do While...Loop, which checks the 'condition and then repeats if the condition is True. Dim a$(100) i% = 1 a(i) = Dir$("*.*") Do While a(i) <> "" i = i+1 a(i) = Dir$ Loop Msg$ = "There are " + Str$(i) + " files found" + crlf MbeMessageBox Msg + a(1) + crlf + a(2) + crlf + a(3) + crlf + a(10) 'The third example uses the Do Until...Loop, which does the iteration 'and then checks the condition and repeats if the condition is True. Dim a$(100) i% = 1 a(i) = Dir$("*.*") Do Until a(i) = "" i = i+1 a(i) = Dir$ Loop Msg$ = "There are " + Str$(i) + " files found" + crlf MbeMessageBox Msg + a(1) + crlf + a(2) + crlf + a(3) + crlf + a(10) 'The last example uses the Do...Until Loop, which performs the 'iteration first, checks the condition, and repeats if the condition 'is True. Dim a$(100) i% = 0 Do i = i+1 If i = 1 Then a(i) = Dir$("*.*") Else a(i) = Dir$ End If

7-46

MicroStation BASIC Guide

"Directories") If a >= 0 Then MbeMessageBox "You selected directory " + S$(a) Else MbeMessageBox "No selection made" End If End Sub ebHidden Descr.*". If a >= 0 Then 'If a% is -1. ebDirectory a% = MbeSelectBox("Choose One". Dim s$() FileList(S$). "*. Dim s$() FileList(s$). ebArchive a% = SelectBox("Archived Files". Example Sub Main() 'Dimension an array and fill it with directory names using the 'ebDirectory constant. then MbeMessageBox "You selected ARCHIVE file " Else MbeMessageBox "No selection made" End If End Sub with Archive bit set. ebHidden MicroStation BASIC Guide 7-47 7 Standard BASIC Reference . 16-bit position of a file attribute indicating that a file is a directory entry. 32-bit position of a file attribute indicating that a file hasn't been backed up. Example Sub Main() 'Dimension an array and fill it with filenames using ‘the ebHidden attribute.A to Z Reference Loop Until (a(i) = "") Msg$ = "There are " + Str$(i) + " files found" + crlf MbeMessageBox Msg + a(1) + crlf + a(2) + crlf + a(3) + crlf + a(10) End Sub ebArchive Descr.*". s$) user pressed Cancel. s().*". + s$(a) ebDirectory Descr. "*. "Choose one". 2-bit position of a file attribute indicating that a file is hidden. "*. Example Sub Main() 'Dimension an array and fill it with filenames Dim s$() FileList(s$).

S$) If a >= 0 Then MbeMessageBox "You selected hidden file " + S$(a) Else MbeMessageBox "No selection made" End If End Sub ebNone Descr. ebNormal a% = SelectBox("Normal Files". 64-bit value used to select files with no other attributes. "Choose one". ebNone a% = SelectBox("No Attributes"."Choose one". Example Sub Main() 'Dimension an array and fill it Dim s$() FileList(S$). S$) file " + S$(a) made" ebNormal Descr. 0 Value used to search for "normal" files. "Choose one". These functions will return only files with no attributes set when used with this constant."*. It will not match files with Hidden. "*. This value can be used with the Dir$ and FileList commands and will return files with the Archive.A to Z Reference a% = SelectBox("Hidden Files". S$) If a >= 0 Then MbeMessageBox "You selected file " + S$(a) Else MbeMessageBox "No selection made" End If End Sub 7-48 MicroStation BASIC Guide . Example Sub Main() 'Dimension an array and fill it with filenames with Normal attributes. If a >= 0 Then MbeMessageBox "You selected Else MbeMessageBox "No selection End If End Sub with filenames with no attributes set. This value can be used with the Dir$ and FileList commands. ReadOnly or no attributes set. Dim s$() FileList(S$).*". System or Directory attributes. Volume.*".

Bit[1] position of a file attribute indicating that a file is read-only.*". "*. Dim s$() FileList(S$).*". Bit[8] position of a file attribute indicating that a file is the volume label. "*. ebReadOnly a% = SelectBox("ReadOnly". Bit[4] position of a file attribute indicating that a file is a system file. Example Sub Main() 'Dimension an array and fill it with filenames with System attributes. ebVolume If ArrayDims(a) > 0 Then MbeMessageBox "The volume name is: " + a(1) Else MbeMessageBox "No volumes found" End If End Sub MicroStation BASIC Guide 7-49 7 Standard BASIC Reference .A to Z Reference ebReadOnly Descr. Dim s$() FileList(S$). "Choose one". S$) If a >= 0 Then MbeMessageBox "You selected file " + S$(a) Else MbeMessageBox "No selection made" End If End Sub ebSystem Descr. S$) If a >= 0 Then MbeMessageBox "You selected file " + S$(a) Else MbeMessageBox "No selection made" End If End Sub ebVolume Descr. "*. Dim s$() FileList(S$). Example Sub Main() 'Dimension an array and fill it with filenames with Volume attributes. Example Sub Main() 'Dimension an array & fill it with filenames with ReadOnly attributes. "Choose one".*". ebSystem a% = SelectBox("System Files".

an empty string is returned. then this function looks for the nth variable within the environment (the first variable being number 1). If there is no such environment variable. If variable$ is specified. Eof Eof%(filenumber%) 7-50 MicroStation BASIC Guide . If variable$ cannot be found. the entire entry from the environment is returned in the following format: variable = value Example Sub Main() 'This example looks for the DOS Comspec variable and displays the 'value in a dialog box. See also MbeGetConfigVar. Example Sub Main() MbeMessageBox "The next line will terminate the script" End End Sub Environ$ Environ$(variable$) Environ$(VariableNumber%) Descr. Returns the value of the specified environment variable. use the MicroStation BASIC extensions: MbeGetConfigVar (page 8-143) and MbeDefineConfigVar. Dim a$(1) a(1) = Environ$("COMSPEC") MbeMessageBox a(1) End Sub To retrieve and set the values of MicroStation configuration variables. then this function looks for that variable$ in the environment. then an empty string is returned. If VariableNumber is specified. All open files are closed. MbeSetConfigVar. Terminates execution of the current macro. Otherwise.A to Z Reference End End Descr.

. Example Sub Main() 'This example opens the Autoexec. With Random or Binary files. Dim S$ Open "C:\AUTOEXEC.S Loop Close MbeMessageBox "The last line was" + crlf + S End Sub Eqv expression1 Eqv expression2 Descr. Eof returns TRUE when the end of the file has been reached (i. otherwise Eqv returns FALSE. either both TRUE or both FALSE). the two operands are converted to Longs.. otherwise returns FALSE.e. then Eqv returns the logical equivalence of expression1 and expression2.A to Z Reference Descr. then a bitwise Eqv is performed.e. Thus. bitwise Eqv works as follows: Bit in expression1 1 0 1 0 Bit in expression2 1 1 0 0 Bit in result 1 0 0 1 MicroStation BASIC Guide 7-51 7 Standard BASIC Reference . With sequential files. the next file read command will result in a run-time error). Eof returns TRUE after an attempt has been made to read beyond the end of the file. The filenumber parameter is a number that is used to refer to the open file—the number passed to the Open statement. Eof will only return TRUE when Get was unable to read the entire record. Returns TRUE if the end of file has been reached for the given file. For numeric operands. Eqv returns TRUE if expression1 and expression2 are the same (i.BAT" For Input As 1 Do While Not Eof(1) Input #1. If both operands are numeric.Bat file and reads lines from the 'file until the end of file is reached. If both operands are relational. then the result is the bitwise Eqv of the arguments. If either of the two operands is a floating-point number.

Thus. Up to 32 parameters can be specified with the Erase statement. For dynamic arrays.0. Decrements the reference count and sets the element to Nothing. The Erase statement erases the elements of the specified arrays.0.array2].A to Z Reference Example Sub Main() 'This example assigns False to A. and False is equivalent to 0. Sets each structure element as a separate variable. Object User-defined types Example Sub Main() Dim a$(1) 7-52 MicroStation BASIC Guide . performs some equivalent operations.. the array will contain no elements and no dimensions. the elements are erased and the array is redimensioned to have no dimensions (and therefore no elements). Sets the element to 0. Since A is equivalent to 'False. before the array can be used by your program. For fixed arrays. only the elements are erased. 'and displays a dialog box with the result. the array dimensions are not changed.. The meaning of erasing an array element depends on the type of element being erased: Element type Integer Long Double Single String What Erase does to that element Sets the element to 0. Sets the element to 0. and by definition. Frees the string. A = 0. Descr. then 'the dialog box will display "A is False". After a dynamic array is erased. A = False If ((A Eqv False) And (False Eqv 0) And (A = 0)) Then MbeMessageBox "A is False" Else MbeMessageBox "A is True" End If End Sub Erase Erase array1 [. then sets the element to an empty string. the dimensions must be reestablished using the Redim statement. Sets the element to 0.

" Else MicroStation BASIC Guide 7-53 7 Standard BASIC Reference . TestError tests the error and. with a subsequent transfer to 'the TestError label. Returns 0 (BASIC does not support line numbers). Example Sub Main() 'This example forces error 10.A to Z Reference a(1) = Dir$("*. Example Sub Main() 'Since the Erl function normally specifies a line number. resets Err to 999 (user-defined error) and returns to 'the Main subroutine. On Error Goto TestError Error 10 MbeMessageBox("The returned error is: " + Str$(Err()) + " : " + Error$) Exit Sub TestError: If Err = 55 Then 'File already open. When a function or statement ends. as shown below. if not 'error 55. The Err function returns an Integer representing the run time error that caused the current error trap.*") MbeMessageBox a Erase a MbeMessageBox a(1) End Sub Erl Erl%[()] Descr. Close it and try again. it will 'always return 0 within this product. a = Erl If a = 0 Then MbeMessageBox "Returned 0" Else MbeMessageBox "Returned non-0" + Str$(a) End If End Sub Err (function) Err%[()] Descr. the value returned by Err is reset to 0. MbeMessageBox "Cannot copy an open file. Err can only be used while within an error trap.

if not 'error 55.A to Z Reference MbeMessageBox "Error " + Str$(Err) + " has occurred" Err = 999 End If Resume Next End Sub Err (statement) Err = value% Descr. Setting value to -1 has the side effect of resetting the error state. with a subsequent transfer to 'the TestError label. TestError tests the error and. The errornumber parameter can be a built-in error number or a user-defined error number. Err can be used within the error trap handler to determine the value of the error. MbeMessageBox "Cannot copy an open file. This function simulates the occurrence of the given run-time error. The statement form of Err sets the value returned by the Err function to a specific value. On Error Goto TestError Error 10 MbeMessageBox("The returned error is: " + Str$(Err()) + " : " + Error$) Exit Sub TestError: If Err = 55 Then 'File already open." Else MbeMessageBox "Error " + Str$(Err) + " has occurred" Err = 999 End If Resume Next End Sub Error Error errornumber% Descr. 7-54 MicroStation BASIC Guide . resets Err to 999 (user-defined error) and returns to 'the Main subroutine. Only positive values less than 32767 are valid. This allows you to perform error trapping within an error handler. Close it and try again. Example Sub Main() 'This example forces error 10.

if not 'error 55. Returns the text corresponding to the given error number or the most recent error. TestError tests the error and. resets Err to 999 (user-defined error) and returns to 'the Main subroutine. then the function returns the text corresponding to the most recent run-time error. resets Err to 999 (user-defined error) and returns to 'the Main subroutine. then this function will return an empty string (""). with a subsequent transfer to 'the TestError label. If no run-time error has occurred. then an empty string ("") is returned. If the Error statement was used to generate a user-defined runtime error. If errornumber is omitted. On Error Goto TestError Error 10 MbeMessageBox("The returned error is: " + Str$(Err()) + " : " + Error$) Exit Sub TestError: If Err = 55 Then 'File already open." Else MbeMessageBox "Error " + Str$(Err) + " has occurred" Err = 999 End If Resume Next End Sub Error$ Error$ [(errornumber%)] Descr. Close it and try again. MbeMessageBox "Cannot copy an open file. TestError tests the error and. with a subsequent transfer to 'the TestError label. if not 'error 55. MbeMessageBox "Cannot copy an open file." Else MbeMessageBox "Error " + Str$(Err) + " has occurred" Err = 999 End If MicroStation BASIC Guide 7-55 7 Standard BASIC Reference . Example Sub Main() 'This example forces error 10. Close it and try again.A to Z Reference Example Sub Main() 'This example forces error 10. On Error Goto TestError Error 10 MbeMessageBox("The returned error is: " + Str$(Err()) + " : " + Error$) Exit Sub TestError: If Err = 55 Then 'File already open.

A to Z Reference Resume Next End Sub Exit Do Exit Do Descr.. This statement can only appear within a For. This statement can only appear within a Do.. Execution will continue on the line immediately after the Next statement.. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example will fill an array with directory entries ‘until a null entry is encountered or 100 entries have been 7-56 MicroStation BASIC Guide . a dialog box displays the count.*") Else a(i) = Dir$ End If If i >= 3 Then Exit Do Loop While (a(i) <> "") If i <> 3 Then MbeMessageBox "There are " + Str$(i) + " files found" Else MbeMessageBox "Exited on i = 3" End If MbeMessageBox a(1) + crlf + a(2) + crlf + a(3) + crlf + a(10) End Sub Exit For Exit For Descr. Example Sub Main() 'This example will load an array with directory entries unless there 'are more than three entries. 'otherwise.. a dialog box displays "More than three entries found. in which case. 'If fewer than 3 entries are found." Dim a$(5) i% = 0 Do i = i+1 If i = 1 Then a(i) = Dir$("*. It causes execution to continue on the next statement after the Loop clause.. the Exit Do terminates 'the loop..Next block. This statement ends the For.Next block in which it appears.Loop statement.

*") Else a(i) = Dir$ End If If (a(i) = "") Or (i >= 100) Then Exit For Next i Msg$ = "There are " + Str$(i) + " files found" + crlf MbeMessageBox Msg + a(1) + crlf + a(2) + crlf + a(3) + crlf + a(10) End Sub Exit Function Descr. This statement can only appear within a function. It cannot appear within a function. Dim a$(100) Dim i% For i% = 1 To 100 If i = 1 Then a(i) = Dir$("*.A to Z Reference ‘processed. Execution is transferred to the statement following the call to the current subroutine. MicroStation BASIC Guide 7-57 7 Standard BASIC Reference Exit Function . Execution will continue on the statement or function following the call to this function. This statement ends the current subroutine. MbeMessageBox("Testing function exit: returning to Main") Test_Exit = 0 Exit Function MbeMessageBox("This line should never execute") End Function Sub Main() a% = Test_Exit() MbeMessageBox "This is the last line of Main" End Sub Exit Sub Exit Sub Descr. This statement ends execution of the function in which it appears. This statement can appear anywhere within a subroutine. The dialog box displays a count of files found and ‘then some entries from the array. Example Function Test_Exit () As Integer 'This function displays a message & then terminates with Exit Function.

performs some equivalent operations. Returns the value of e raised to the power of value. a# = Exp(12. A = False if ((A = False) and (False Eqv 0) And (A = 0)) Then MbeMessageBox "A is False" Else MbeMessageBox "A is True" End If End Sub FileAttr FileAttr%(filenumber%. Range of value: 0 <= value <= 709. used in conditionals and Boolean expressions. Example Sub Main() 'This example assigns a to e raised to the 12. The last line should 'never execute because of the Exit Sub statement. 'and displays a dialog box with the result. 0. then 'the dialog box will display "A is False".782712893.4 power is: " + Str$(a) End Sub False Descr. and by definition.40) MbeMessageBox "e to the 12. attribute%) 7-58 MicroStation BASIC Guide . A = 0. and False is equivalent to 0. Example Sub Main() 'This example assigns False to A. Since A is equivalent to 'False.4 power and displays it 'in a dialog box. MbeMessageBox("Terminating Main") Exit Sub MbeMessageBox("Still here in Main") End Sub Exp Exp#(value#) Descr. A run-time error is generated if value is out of the range specified above.A to Z Reference Example Sub Main() 'This example displays a dialog box & then exits.

and 'determines the file mode for which it was opened.BAT" For Input As 1 a% = FileAttr(1.A to Z Reference Descr. If attribute is 1. Example Sub Main() 'This example opens a file for input. destination$ Descr. It cannot contain wild cards (? or *) but may contain path information.1) Select Case a Case 1 MbeMessageBox "Opened for input" Case 2 MbeMessageBox "Opened for output" Case 3 MbeMessageBox "Opened for random" Case 4 MbeMessageBox "Opened for append" Case 32 MbeMessageBox "Opened for binary" Case Else MbeMessageBox "Unknown file mode" End Select a = FileAttr(1.2) MbeMessageBox "File handle is: " + Str$(a) Close End Sub FileCopy FileCopy source$. Open "C:\AUTOEXEC. then one of the following values is returned: 1 2 4 8 32 Input Output Random Append Binary The filenumber parameter is a number that is used to refer to the open file—the number passed to the Open statement. reads the file attributes. The source$ parameter must specify a single file. Returns the file mode (if attribute is 1) or the operating system file handle (if attribute is 2). The FileCopy command copies a source$ file to a destination$ file. The result is 'displayed in a dialog box. MicroStation BASIC Guide 7-59 7 Standard BASIC Reference .

Bat" Then A# = FileDateTime("C:\AUTOEXEC.SAV" For Input As # 1 FileCopy "C:\AUTOEXEC. The number is returned in days.e. A run-time error results if the file does not exist. Weekday. MbeMessageBox "Cannot copy an open file. Close it and try again. The file will be copied and renamed if the source$ and destination$ filenames are not the same. then 'opens the copied file and tries to copy it again. Hour) to extract the individual elements. 1899 is 0. unique destination file and may contain drive and path specifiers.SV2" Close Exit Sub ErrHandler: If Err = 55 Then 'File already open.BAT". Example Sub Main() 'This example gets the file date/time of the Autoexec. The value returned can be used with the date/time functions (i. where Dec 30. Minute.Bat file to "AUTOEXEC. Month.Bat file and 'displays it in a dialog box. generating an error. Note that some platforms do not support drive letters and may not support dots to indicate current and parent directories. Second. FileDateTime retrieves the date and time of the file specified by filename$.SAV".SAV" Open "C:\AUTOEXEC.SAV".A to Z Reference The destination$ specifies a single.. "C:\AUTOEXEC." Else MbeMessageBox "An unspecified file copy error has occurred" End If Resume Next End Sub FileDateTime FileDateTime#(filename$) Descr. On Error Goto ErrHandler FileCopy "C:\AUTOEXEC. Year. "C:\AUTOEXEC. The FileDateTime function returns a double-precision number representing the date and time of the given file. Example Sub Main() 'This example copies the Autoexec.BAT") MbeMessageBox Str$(Year(A)) + Str$(Month(A)) + Str$(Day(A)) Else MbeMessageBox "The file does not exist" End If End Sub 7-60 MicroStation BASIC Guide . If FileExists "C:\Autoexec. Day.

FileExists will return FALSE if filename$ specifies a subdirectory. then it will be redimensioned to exactly hold the new number of elements. This statement fills an array$ with directory names from disk. If the array is dynamic.BAT") Then a# = FileDateTime("C:\AUTOEXEC."C:\*. then * is used.* If dirspec$ is not specified. If there are fewer elements than will fit in the array.Bat file in 'the root directory of the C drive. Example Sub Main() 'This example fills an array with directory entries and displays the 'first one.A to Z Reference FileDirs FileDirs array$() [. FileExists determines whether a given filename$ is valid. C:\*. then the remaining elements are unused. each array element is first erased.dirspec$] Descr. If the array is fixed. T*. which fills the array with all the subdirectory names within the current directory.BAT") MicroStation BASIC Guide 7-61 7 Standard BASIC Reference The dirspec$ parameter specifies the file search mask. array$() is any previously declared string array. Dim A$() FileDirs A. The FileDirs function reallocates this array to exactly hold all the directory names matching a given specification. array$ must specify either a 0. TRUE if the filename$ is a valid file. If FileExists("C:\AUTOEXEC. then the new elements are placed into the array. then displays either its date and 'time of creation or the fact that it does not exist.*" MbeMessageBox A(1) End Sub FileExists FileExists%(filename$) Descr. A run-time error results if the array is too small to hold the new elements. such as: . Example Sub Main() 'This example checks to see whether there is an Autoexec. FALSE otherwise.or a 1-dimensioned dynamic array or a single-dimensioned fixed array.

whereas the ? character matches any single character.BAT") And _ (FileLen("C:\AUTOEXEC. This statement fills an array with filenames from disk. The filespec$ argument can include wild cards.exclude_attr]]] Descr. The * character matches any sequence of zero or more characters. Example Sub Main() 'This example checks to see whether there is a C:\AUTOEXEC. If (FileExists("C:\AUTOEXEC. The FileList function reallocates this array to exactly hold all the files matching a given filespec$. A run-time error results if the file does not exist. This function is used in place of Lof to retrieve the length of a file without first opening the file.BAT") MbeMessageBox "The length of Autoexec. Returns the length of the given filename$ in bytes.BAT") <> 0)) Then b% = FileLen("C:\AUTOEXEC.BAT file 'and. The filenames must conform to an eight character filename handle and three character filename extension (8. Multiple *s and ?s can appear within the expression to form 7-62 MicroStation BASIC Guide .Bat is: " + Str$(B) Else MbeMessageBox "File does not exist" End If End Sub FileList FileList array$() [. or an MDL abort will occur.3 DOS format).include_attr% [.filespec$ [. The array$() is any previously declared string array.A to Z Reference MbeMessageBox Str$(Year(A#)) + Str$(Month(A#)) + Str$(Day(A#)) Else MbeMessageBox "File does not exist" End If End Sub FileLen FileLen&(filename$) Descr. displays the length of the file. such as * and ?. if there is.

* is used. Similarly. If exclude_attr is not specified.TXT C*T C?T * Thus. These numbers can be any combination of the following: Constant ebNormal ebReadOnly ebHidden ebSystem ebVolume ebDirectory ebArchive ebNone Value 0 1 2 4 8 16 32 64 Includes Read-only.DOC CAT.TXT CAT CAP.TXT CAPIT C*T.DAT CAP.TXT ACATS. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example fills an array a with the directory of the current drive 'for all files that have normal or no attributes and excludes those MicroStation BASIC Guide 7-63 7 Standard BASIC Reference .A to Z Reference complete searching patterns. if filespec$ is not specified. subdir. then hidden files and subdirectories are excluded from the list (18).TXT GOOSE. The following table shows some examples: This pattern *S*.TXT CAT.TXT CAT.TXT CAT CUT CT (All files) Doesn’t match these files SAMPLE SAMPLE.TXT Matches these files SAMPLE. exclude_attr specifies attributes of files you want excluded from the list. then the value 97 is used (ebReadOnly Or ebArchive Or ebNone).TXT SAMS. include_attr is a number indicating what types of files you want included in the list. none Read-only files Hidden files System files Volume label DOS subdirectories Files that have changed since the last backup Files with no attributes If include_attr is not specified. archive.

The dialog box displays four filenames from 'the array. ebSystem If ArrayDims(a) > 0 Then MbeMessageBox a(1) + crlf + a(2) + crlf + a(3) + crlf + a(4) Else MbeMessageBox "No files found" End If End Sub FileParse$ FileParse$(filename$[.. 0 1 2 3 4 5 Full name Drive Path Name Root Extension c:\sheets\test.dat C:\sheets\test.\test. It can be any of the following values.A to Z Reference 'with system attributes. This statement takes a filename and extracts a given portion of the filename from it.dat The optional operation parameter specifies which portion of the filename$ to extract. filename$ can specify any valid filename (it does not have to exist).Bat" into its 'component parts and displays them in a dialog box. Dim a$() FileList a. For example: . (ebNormal + ebNone).i-1) 7-64 MicroStation BASIC Guide . A runtime error will result if operation is not one of the above values. A runtime error results if filename$ is empty.*".dat c c:\sheets test. then the full name is returned.dat test dat If operation is not specified. operation]) Descr.Bat"."*. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example parses the file string "C:\TestSub\Autoexec.dat test. Dim a$(6) Dim i% For i = 1 To 5 a(i) = FileParse$("C:\TestSub\Autoexec.

Returns the integer part of number. a# = -19923... 'then displays the result in a dialog box. Example Sub Main() For. Changing the step during execution of the loop will have no effect.Next statement continues executing until an Exit For statement is encountered when counter is greater than end. The For.Next For counter = start To end [Step increment] [statements] [Exit For] [statements] Next [counter] Descr. Thus.45 is: " + Str$(b)) End Sub . Each time through the loop. If increment is not specified. The expression given as increment is evaluated only once. changing the end expression during execution of the loop will have no effect. Fix differs from the Int function in that Fix truncates negative numbers in a positive direction. The first time through the loop..45 b% = Fix(a) MbeMessageBox ("The fixed portion of 19923.A to Z Reference Next i MbeMessageBox a(1)+ crlf + a(2) + crlf + a(3) + crlf + a(4) + crlf + a(5) End Sub Fix Fix%(number#) Descr. This function returns the integer part of the given value by removing the fractional part. then 1 is assumed. The expression specified by end is evaluated only once. Repeats a block of statements a specified number of times. counter is equal to start. The sign is preserved. increment is added to counter by the amount specified in increment. incrementing a loop counter by a given increment each time through the loop. MicroStation BASIC Guide 7-65 7 Standard BASIC Reference 'This example returns the fixed part of a number and assigns it to b..

The Next [counter] can be optimized for next loops by separating each counter with a comma."0") + " OR " Msg = Msg + Format$(Abs(Y)... then increment must be negative. then increment must be positive.j Example Function Factorial (n%) As Integer 'Calculate N factorial. MbeMessageBox "5 factorial is: " + Str$(Factorial(5)) 'Constructs a truth table for the OR statement using nested loops..A to Z Reference If end is greater than start. For.. f% = n For i% = n To 2 Step -1 f = f * i Next i Factorial = f End Function Sub Main() 'This example calculates the value of 5 factorial using a For. If end is less than start."0") + " = " Msg = Msg + Format$(Z... The ordering of the counters must be consistent with the nesting order (innermost counter appearing before outermost counter): Next i. the Next [counter] statement applies to the innermost For.Next 'loop in function factorial. Msg$ = Null For X% = True To False For Y% = True To False Z = X Or Y Msg = Msg + Format$(Abs(X)."True/False") + crlf Next Y Next X MbeMessageBox Msg End Sub Format$ Format$(Expression [.Next statements can be nested.Userformat$]) 7-66 MicroStation BASIC Guide .Next. In such a case.

consisting of: Expression A string or numeric expression to be formatted. . Display Yes for all other values. or a string. numeric. you can specify one of the builtin formats. Returns a string formatted to user specification. One digit appears before the decimal separator and two after. String. The numeric expression can be entered as a double. except that it does not preserve a leading space for positive values. with no additional formatting. A percent sign (%) will appear at the right of the formatted output. The actual formatted output depends on the Currency settings in the International section of the Control Panel. There are two categories of built-in formats: one deals with numeric expressions and the other with date/time values.The following tables list the built-in numeric and date/time format strings. Two digits are displayed to the right of the decimal separator. Userformat$ If no Userformat$ parameter is given and the expression is numeric. The Format$ function has two parts. a long. with thousand separator if necessary. Numeric Format General Number Currency Description Display the numeric expression as is. an integer. followed by an explanation of what each does. Display the numeric expression as currency. a scientific notation. then Format$ performs the same function as the Str$ command. Display at least one digit to the left of the decimal separator and two digits to the right. Fixed Standard Percent Scientific Yes/No MicroStation BASIC Guide 7-67 7 Standard BASIC Reference Built-In Formats To format numeric expressions. and date/time formats cannot be mixed in a single Userformat$ expression. a single. Display the number using scientific notation. Display at least one digit to the left of the decimal separator and two digits to the right.A to Z Reference Descr. Display the numeric expression with thousand separator if necessary. A format expression that can be either one of the built-in BASIC formats or a user-defined format consisting of characters that specify how the expression should be displayed. Display No if the numeric expression is 0. Display the numeric expression multiplied by 100.

Display the long time. the Expression argument should be a double-precision floating point value. Output is in the following form: 1/1/93 01:00:00 AM. The following tables list the 7-68 MicroStation BASIC Guide .When Format$ is used to format a time value. Display a long date. When Format$ is used to format a time value. as specified in the International section of the Control Panel. the Expression argument should be a double-precision floating point value. If there is no fractional part in the numeric expression. Display the time using the 24-hour clock. Date formats are listed in the following table: Date Format General Date Description Display the date and time. Such a value can be obtained using the TimeValue function. by using characters that have special meaning when used in a format expression. you can also specify a userdefined format. the Expression argument should be a doubleprecision floating point value. then only the date is displayed. Display Off if the numeric expression is 0. Such a value can be obtained using the TimeValue function. When Format$ is used to format a time value. only print out the abbreviated name of the month. Display a short date. as specified in the International section of the Control Panel. Hours and minutes are displayed. Long Date Medium Date Short Date Long Time Medium Time Short Time User-Defined Formats In addition to the built-in formats. Display the time using the 12-hour clock. then only the time is displayed. Display a short date. as specified in the International section of the Control Panel. If there is no integral part in the numeric expression. Hours and minutes are displayed. Display True for all other values. as defined in the International section of the control panel. and the AM/PM designator is at the end. Display On for all other values.A to Z Reference Numeric Format True/False On/Off Description Display False if the numeric expression is 0. Such a value can be obtained using the TimeValue function. The default is: h:mm:ss.

Leading and trailing 0s are not displayed. the thousand separator must be surrounded by digit placeholders. and the percent character is inserted in the same position as it appears in the user-defined format string. string. with no additional formatting. This is a digit placeholder. the number will be displayed. Commas appearing before any digit placeholders are specified are just displayed. This is the decimal placeholder. If there are more 0s in the format string than there are digits. Character Empty string 0 Meaning This displays the numeric expression as is. % This is the percentage operator. nothing will be displayed. the leading and trailing 0s are displayed without modification. If there exists a number in the numeric expression in the position where the pound sign appears.000 for each adjacent comma in the format string. This is the thousand separator. . and date/time formats and explain their functions.A to Z Reference characters you can use for numeric. . The common use for the thousand separator is to separate thousands from hundreds. MicroStation BASIC Guide 7-69 7 Standard BASIC Reference . To specify this use. A comma immediately to the left of the decimal has the same function. a 0 will be displayed. This will display a number or a 0. Otherwise. Adjacent commas with no digit placeholders specified between them and the decimal mean divide the number by 1. This designates the number of digits to the left of the decimal and the number of digits to the right. If there exists a number in the numeric expression in the position where the 0 appears. The character used in the formatted string depends on the decimal placeholder character specified in the International section of the Control Panel. The actual thousand separator character used depends on the character specified in the International section of the Control Panel. # This is a digit placeholder. Otherwise. The numeric expression is multiplied by 100. the number will be displayed. This will display a number or nothing.

At least one digit placeholder must exist to the left of E-. or e+. The text between the quotation marks is displayed. "ABC" This displays the text between the quotation marks. Using E+ or e+ places a + in front of positive exponents and a .or e. precede them with a backslash. you should precede it with a backslash or enclose it in quotes. If you specify one format. Numeric formats can contain one to three parts. The actual character used depends on the character specified in the International section of the Control Panel.in front of negative exponents. * This will display the next character as the fill character.A to Z Reference Character E-E+e-e+ Meaning These are the scientific notation operators. e-. and seconds when time values are being formatted. use two backslashes. This displays the number in scientific notation. -+$()space These are the literal characters you can display. Using E. Numeric formatting characters. Any empty space in a field will be filled with the specified fill character.in front of negative exponents and nothing in front of positive exponents. and years when date values are being formatted. If you specify two formats. minutes. This separates months. E+. it applies to all values. days. E+. date/time formatting characters. \ This designates the next character as a displayed character.places a . Double quotation marks can also be used to display characters. To display a backslash. and string formatting characters cannot be displayed without a preceding backslash. but the quotation marks are not. Each part is separated by a semicolon. e-. the first applies to positive values and the second to negative values. To display any other character. or e+ determine the number of digits displayed in the exponent. the first applies to positive values. Any digit placeholders displayed to the left of E-. To designate a double quotation mark within a format string. The actual character used depends on the character specified in the International section of the Control Panel. the second to negative 7-70 MicroStation BASIC Guide . : This is the time separator. If you specify three formats. This separates hours. use two adjacent double quotation marks. To display characters. / This is the date separator.

Only the time is displayed if no integral portion exists in the numeric expression. Display the week of the year (1-53). Display the date as a Short Date. d dd ddd dddd ddddd dddddd w ww MicroStation BASIC Guide 7-71 7 Standard BASIC Reference . it will display nothing. Display the day of the week abbreviated (Sun-Sat). it will display a space. as specified in the International section of the Control Panel. Display the number of the day of the week (1-7). Only the date is displayed if no fractional part exists in the numeric expression. The default is right to left. Placeholders are filled from right to left unless the format string specifies left to right. the format for positive values is used. All characters in the expression are displayed in uppercase. Saturday is 7. This will display a character if one exists in the expression in the same position. Sunday is 1. Placeholders are filled from right to left unless the format string specifies left to right. Display the day without a leading 0 (1-31). ! This character forces placeholders to be filled from left to right. Display the date as a Long Date. All characters in the expression are displayed in lowercase. > This character forces uppercase. < This character forces lowercase. Display the day of the week (Sunday-Saturday). Date/time formats are listed in the following table: Character c Meaning Display the date as ddddd and the time as ttttt. as specified in the International section of the Control Panel. & This is a character placeholder. This will display a character if one exists in the expression in the same position. Otherwise. and the third to 0s. Otherwise. String formats are listed in the following table: Character @ Meaning This is a character placeholder. If you include semicolons with no format between them. Display the day with a leading 0 (01-31).A to Z Reference values.

Display the time according the International section of the Control Panel."Yes/No") 7-72 MicroStation BASIC Guide . Display the time using a 12-hour clock. Display the minute with a leading 0 (00-59). Display the time using a 12-hour clock.A to Z Reference Character m mm Meaning Display the month without a leading 0 (1-12). Display the month with a leading 0 (01-12)."Currency") Format$(a."Scientific") Format$(True."General Number") Format$(a. Display an uppercase AM for time values before 12 noon. Display the month (January-December). If m immediately follows h or hh. Display the time using a 12-hour clock. Display the second without a leading 0 (0-59). Display the time using a 12-hour clock. not the century (00-99)."Fixed") Format$(a. Display the hour without a leading 0 (0-24). Display the quarter of the year (1-4). m is treated as minutes (0-59). Display an uppercase PM for time values after 12 noon and before 12 midnight. Display the time using a 12-hour clock. and append a lowercase am or pm. Display the hour with a leading 0 (00-24). Display the year (1000-9999). Display the year. mm is treated as minutes with a leading 0 (0059). and append an uppercase A or P. A leading 0 is displayed if specified in the Control Panel. Display the string s1159 for values before 12 noon and s2359 for values after 12 noon and before 12 midnight. and append a lowercase a or p."Percent") Format$(a. mmm mmmm q y yy yyyy h hh n nn s ss ttttt AM/PM am/pm A/P a/p AMPM Example Sub Main() a# = 1199. Display the second with a leading 0 (00-59). Display the day of the year (1-366). Display the month abbreviated (Jan-Dec). Display the minute without a leading 0 (0-59). If mm immediately follows h or hh."Standard") Format$(a.234 MbeMessageBox MbeMessageBox MbeMessageBox MbeMessageBox MbeMessageBox MbeMessageBox MbeMessageBox Format$(a.

. MicroStation BASIC Guide 7-73 7 Standard BASIC Reference ."Medium Date") MbeMessageBox Format$(da. Returns the next available file number. Creates a user-defined function.)] [As type] name = expression End Function Descr. The return value is determined by the following statement: name = expression The name of the function follows BASIC naming conventions."Long Date") MbeMessageBox Format$(da."##."Short Time") A# = 12445601.0.. A = FreeFile MbeMessageBox "The next free file number is: " + Str$(A) End Sub Function.###."Long Time") MbeMessageBox Format$(tiDouble.###") End Sub FreeFile FreeFile%[()] Descr. & and $. Example Sub Main() 'This example assigns A to the next free file number and displays it 'in a dialog box."Medium Time") MbeMessageBox Format$(tiDouble. It can include type-declaration characters: %."Short Date") ti$ = Time$ tiDouble# = TimeValue(ti) MbeMessageBox Format$(tiDouble."True/False") MbeMessageBox Format$(True.."0. The value returned will always be between 1 and 255 inclusive..A to Z Reference MbeMessageBox Format$(True."General Date") MbeMessageBox Format$(da.###. This number is suitable for use in the Open statement.234 MbeMessageBox Format$(A."On/Off") da$ = Date$ MbeMessageBox Format$(da.00") MbeMessageBox Format$(A.End Function Function name[(parameter [As type].

meaning that any modifications to a passed parameter change that variable in the caller. then 0 will be returned for numeric functions. As an alternative. Example Function Factorial(n%) As Integer 'This function calculates N! (N-factorial).A to Z Reference If no assignment is encountered before the function exits. World" End Function Parameters are passed to a function by reference. A% = 0 7-74 MicroStation BASIC Guide .(j)) If a function is not to receive a parameter by reference. World" End Function Function Test$() Test = "Hello. To avoid this. and an empty string will be returned for string functions. as in the following example function calls: i = UserFunction(10. f% = 1 For i = n To 2 Step -1 f = f * i Next i Factoral = f End Function Sub Main() 'This example calls user-defined function Factorial and displays ‘the result in a dialog box. then the optional ByVal keyword can be used: Function Test(ByVal filename As String) As String statements End Function A function returns to the caller when either of the following statements is encountered: End Function Exit Function Functions can be recursive. simply enclose variable names in parentheses. The type of the return value is determined by the As type clause on the Function statement itself. a typedeclaration character can be added to the Function name: Function Test() As String Test = "Hello.12.

An annuity is a series of fixed payments made to an insurance company or other investment company over a period of time. a double-precision number representing the amount of each payment per period. the present value would be the amount of the fund. If Rate is an annual rate. Positive numbers represent cash received. In the case of a loan. whereas in the case of a retirement annuity. then NPer must also be expressed in months. Nper#. Due%) Descr.A to Z Reference Do While A% < 2 A% = MbeInputBox("Enter an integer number greater than 2: ") Next B = factorial(A) MbeMessageBox "The factorial of " + Str$(A) + " is: " + Str$(B) End Sub Fv Fv#(Rate#. a double-precision number representing the present value of your annuity. whereas a 1 indicates payment at the start of each period. then the NPer must also be given in years. whereas negative numbers represent cash paid out. A 0 specifies payment at the end of each period. MicroStation BASIC Guide 7-75 7 Standard BASIC Reference Fv requires the following parameters: . Pmt#.Pv#. Parameter Rate Description a double-precision number representing the interest rate per period. This function calculates the future value of an annuity based on periodic fixed payments and a constant rate of interest. Make sure that annual rates are normalized for monthly periods (divided by 12). indicates when payments are due for each payment period. whereas receipts are entered as positive values. a double-precision number representing the total number of payments (periods) in the annuity. Payments are entered as negative values. Examples of annuities are mortgages and monthly savings plans. NPer Pmt Pv Due Rate and NPer values must be expressed in the same units. the present value would be the amount of the loan. If Rate is expressed as a percentage per month.

This storage is different from variable-length strings outside of user-defined types.A to Z Reference Example Sub Main() 'This example calculates the future value of 100 dollars paid 'periodically for a period of 10 years (120 months) at a rate of '10% per year (or . the record length must be greater than or equal to the combined size of each element within the data type. Object variables cannot be read from a file using the Get statement. Each member of a user-defined data type is read individually. a# = Fv((.0. The variable parameter is the name of any variable of any of the following types: Variable type Integer Long String File storage description 2 bytes are read from the file. this number represents the first byte to be read starting with the beginning of the file (the 7-76 MicroStation BASIC Guide . 8 bytes are read from file (IEEE format).00.10/12). In binary files. variable-length strings within user-defined types are read by first reading a 2-byte length followed by the string's content. variable-length strings are read by first reading a 2-byte length and then reading that many characters from the file.10/12 per month) with payments made on the 'first of the month. Double Single User-defined Arrays Objects The optional recordnumber parameter specifies which record is to be read from the file. 'Note that payments are negative values. Arrays cannot be read from a file using the Get statement. 4 bytes are read from the file.120. The value is displayed in a dialog box.1) MbeMessageBox "Future value is: " + Format$(a."Currency") End Sub Get Get [#] filenumber% [. When reading user-defined types. variable Descr. In binary files. For binary files. Retrieves data from a random or binary file and stores that data into the specified variable.-100.recordnumber%]. In random files. 4 bytes are read from file (IEEE format). variable-length strings are read by first determining the specified string variable's length and then reading that many bytes from the file.

This value ranges from 1 to 2147483647.50..X. the next record is read from the file (if no records have been read yet.X Pstr = Pstr + "Record " + Str$(Y) + ": " + Str$(X) + crlf Next Y MbeMessageBox Pstr Close End Sub MicroStation BASIC Guide 7-77 7 Standard BASIC Reference . the file pointer is advanced to the start of the next record. this number represents the record number starting with the beginning of the file (the first record is 1). as in the following example: Example Get #1. the data elements being read are contiguous—the file pointer is never advanced. then writes 10 'records into the file with the values 10.A to Z Reference first byte is 1). With random files.Y Next X Close Pstr$ = "" Open "Test2. it overrides any previous change in file position specified with the Seek statement.y. If the length of the data being read is less than the record length. and the 'records are read with the Get statement.Dat" For Random Access Read As #1 For Y = 1 to 5 Get #1. The result is displayed 'in a dialog box.recvar If recordnumber is specified. then the first record in the file is read).Dat" For Random Access Write As #1 For X% = 1 to 10 Y% = X * 10 Put #1. Open "Test2. If recordnumber is not specified. If recordnumber is not specified. Example Const Crlf = Chr$(13) + Chr$(10) Sub Main() 'This example opens a file for random write. For random files. Then the file 'is closed and reopened in random mode for read. a run-time error will occur if the length of the data being read exceeds the reclen parameter specified with the Open statement.. the commas must still appear.. With binary files.

Dat") If Y And ebNone Then Msg = Msg + "No Archive bit is set" + crlf If Y And ebRead Then Msg = Msg + "The Read-Only bit is set" + crlf If Y And ebHidden Then Msg = Msg + "The Hidden bit is set" + crlf If Y And ebSystem Then Msg = Msg + "The System bit is set" + crlf If Y And ebVolume Then Msg = Msg + "The Volume bit is set" + crlf If Y And ebDirectory Then Msg = Msg + "The Directory bit is set" + crlf If Y And ebArchive Then Msg = Msg + "The Archive bit is set" MbeMessageBox Msg End Sub 7-78 MicroStation BASIC Guide . and the result is displayed. none Read-only files Hidden files System files Volume label DOS subdirectories Files that have changed since the last backup Files with no attributes To determine whether a particular attribute is set. The value of each attribute is as follows: Constant ebNormal ebReadOnly ebHidden ebSystem ebVolume ebDirectory ebArchive ebNone Value 0 1 2 4 8 16 32 64 Includes Read-only. the attribute is set.Dat") Then Open "Test2. 'then it creates the file. The attribute value returned is the sum of the attribute bits set for the file. If it does not. This function returns an Integer containing the attributes of the specified file. subdir.DAT exists.A to Z Reference GetAttr GetAttr%(filename$) Descr. If the result is TRUE.Dat" For Random Access Write As #1 Close End If Msg$ = "" Y% = GetAttr("Test2. you can And the values shown above with the value returned by GetAttr. The file attributes are then 'retrieved with the GetAttr function. If Not FileExists("Test2. Example Sub Main() 'This example tests to see whether Test2. archive.

A to Z Reference Global Descr. the name is set to Michael. " + UName Exit Sub CheckName: If (UName$ = "") Then GoSub BlankName ElseIf UName = "MICHAEL" Then GoSub RightName Else GoSub OtherName End If Return BlankName: MbeMessageBox "No name? Clicked Cancel? I'm shutting down" Exit Sub RightName: Return OtherName: MbeMessageBox "I am renaming you Michael!" UName = "MICHAEL" Return End Sub MicroStation BASIC Guide 7-79 7 Standard BASIC Reference . If the user clicks Cancel or enters a null name. This statement causes execution to continue at the specified label. otherwise. 'the program terminates. Execution can later be returned to the statement following the GoSub by using the Return statement. GoSub GoSub label Descr. GoSub outside the context of the current function or subroutine is not allowed. UName$ = Ucase$(MbeInputBox$("Enter your name: ")) GoSub CheckName MbeMessageBox "Hello. 'and a message is displayed. The label parameter must be a label within the current function or subroutine. See Public. Example Sub Main() 'This example gets a name from the user and then branches ‘to a subroutine 'to check the input.

'the program displays a message and terminates. 'depending on the input name. it is reset 'to Michael unless it is null or the user clicks Cancel--in which case. Transfers execution to the line containing the specified label. Keywords cannot be used as labels. Returns a string containing the hexadecimal equivalent of the specified number. 7-80 MicroStation BASIC Guide . UName$ = Ucase$(MbeInputBox$("Enter your name: ")) If Uname = "MICHAEL" Then Goto RightName Else Goto WrongName End If WrongName: If (UName$ = "") Then MbeMessageBox "No name? Clicked Cancel? I'm shutting down" Else MbeMessageBox "I am renaming you Michael!" UName = "MICHAEL" Goto RightName End If Exit Sub RightName: MbeMessageBox "Hello. The compiler will produce an error if label does not exist. Example Sub Main() 'This example gets a name from the user and then branches to ‘a statement. Labels must begin with a letter and end with a colon. Labels are not case-sensitive. The returned string contains only the number of hexadecimal digits necessary to represent the number. The label must appear within the same subroutine or function as the Goto. If the name is not Michael. Michael!" End Sub Hex$ Hex$(number&) Descr.A to Z Reference Goto Goto label Descr. up to a maximum of eight.

XT# = TimeValue(Time$()) XH# = Hour(XT) XM# = Minute(XT) XS# = Second(XT) MbeMessageBox "Current time is: " + Str$(XH)+":"+Str$(XM)+":"+Str$(XS) End Sub If. Example Sub Main() 'This example takes the current time..Then. and second. 'minute.Else Syntax 1 If condition Then statement [Else statement] MicroStation BASIC Guide 7-81 7 Standard BASIC Reference . then a maximum of four digits are returned. Do XS$ = MbeInputBox$("Enter a number: ") X = Val(XS) If X <> 0 Then MbeMessageBox "Dec:" + Str$(X) + " Hex: " + Hex$(X) Else MbeMessageBox "Terminating program" End If Loop While X <> 0 End Sub Hour Hour%(serial#) Descr. Example Sub Main() 'This example inputs a number and displays it in decimal and 'hex until the input number is 0 or an invalid input. The value returned is between 0 and 23 inclusive. and displays them as the current time.. otherwise.A to Z Reference The number parameter can be any type but is rounded to the nearest whole number before converting to hex. If the passed number is an Integer.. up to eight digits can be returned. Returns the hour of the day encoded in the specified serial parameter.. extracts the hour.

Conditionally executes a statement or group of statements. " + UName + "!" Return End Sub 7-82 MicroStation BASIC Guide . Example Sub Main() 'This example inputs a name from the user and checks to see whether it 'is Michael or Mike using three forms of ‘the If. or many statements can be separated using the colon (:). In the single-line version. 'It then branches to a statement that displays a welcome message 'depending on the user's name.Else statement.. UName$ = Ucase$(MbeInputBox$("Enter your name: ")) If UName$ = "MICHAEL" Then GoSub MikeName If UName = "MIKE" Then GoSub MikeName Exit Sub End If If UName = "" Then MbeMessageBox ("Your name can't be <null>.A to Z Reference Syntax 2 If condition Then [statement] [ElseIf condition Then [statement]] [Else [statement]] End If Descr. the statement can either be a single statement..Then. Michael!" Return OtherName: MbeMessageBox "Hello.. I'll call you Mike!") UName = "MIKE" GoSub MikeName ElseIf UName = "MICHAEL" Then GoSub MikeName Else GoSub OtherName End If Exit Sub MikeName: MbeMessageBox "Hello..

If either of the two operands is a floating-point number. then Imp returns the logical implication of expression1 and expression2. then the two operands are first converted to Longs. then a bitwise Imp is performed. a=10 b=20 c=30 d=40 If (a < b) Imp (c < d) Then MbeMessageBox "a is less than b implies that c is less than d" Else MbeMessageBox “a is less than b does not imply that c is” + _ “less than d” End If If (a < b) Imp (c > d) Then MbeMessageBox “a is less than b implies that c is” + _ “greater than d” Else MbeMessageBox “a is less than b does not imply that c is” + _ “greater than d” End If End Sub MicroStation BASIC Guide 7-83 7 Standard BASIC Reference 1 . If both operands are numeric. For numeric operands. Imp returns TRUE.A to Z Reference Imp expression1 Imp expression2 Descr. Imp returns FALSE when expression1 is TRUE and expression2 is FALSE. If both operands are relational. then the result is the bitwise Imp of the arguments. otherwise. bitwise Imp works as follows: Bit in expression1 1 0 1 0 Bit in expression2 1 1 0 0 Bit in result 1 0 1 Example Sub Main() 'This example compares the result of two expressions to determine 'whether one implies the other.

Open "Test2..Dat" for output as #1 C$ = MbeInputBox$("Enter some text: ") A# = 10.0 7-84 MicroStation BASIC Guide . then 0 is stored into the variable. then characters are read up to the next quotation mark or the end-of-line. 3. 2. Leading white space is ignored (spaces and tabs). 4. End of line is interpreted as either a single line feed or a carriage-return line-feed pair. Descr. When reading strings. It is good practice to use the Write statement to write date elements to files read with the Input statement to ensure that the variable list is consistent between the input and output routines. The resultant number is automatically converted to the same type as the variable into which the value will be placed. text files from any platform can be interpreted using this command. filenumber must reference a file opened in Input mode. if the first character on the line is a quotation mark.Dat and writes a series of 'variables into it.variable]. For example. comma or end-of-line) are not included in the returned string.A to Z Reference Input # Input [#]filenumber%. If the first character read is not a double quotation mark. The filenumber parameter is a number that is used to refer to the open file—the number passed to the Open statement. When reading numbers. Blank lines are read as empty strings. a string variable must be matched to a string in the file. This statement reads data from the file referenced by filenumber into the given variables. If there is an error in conversion. a letter. String delimiters (quotation mark. then characters are read up to the first comma or the end of the line. Each variable must be type-matched to the data in the file. or any other unexpected character) is encountered.. scanning stops when the first nonnumerical character (such as a comma. Numeric errors are ignored while reading numbers from a file. The following parsing rules are observed while reading each variable in the variable list: 1. variable[. whichever comes first. Example Sub Main() 'This example creates a file called Test2. Then the variables are read using ‘the Input # function. Thus. whichever comes first.

Bat" for input as #1 Else MbeMessageBox "File not found or empty" Exit Sub End If If X > 80 Then Ins$ = Input$ (80. find$ [. Example Sub Main() 'This example opens the Autoexec.ST$.#1) End If Close MbeMessageBox "File length: " + Str$(X) + Chr$(13) + Chr$(10) + Ins End Sub InStr InStr([start%. including spaces and end-of-lines.] search$. filenumber is a number that is used to refer to the open file—the number passed to the Open statement.Y%. X = FileLen("C:\Autoexec.A to Z Reference Write #1.compare%]) MicroStation BASIC Guide 7-85 7 Standard BASIC Reference The filenumber parameter must reference a file opened in either Input or Binary mode.Bat") If X > 0 Then Open "C:\Autoexec. Returns a character string containing numbytes characters read from a given sequential file.#1) Else Ins = Input$ (X.X%.A.C.192.Dat" for input as #1 Input #1.Z% MbeMessageBox “Recrd: + Str$(X) + " " + ST + " " + Str$(Y) + " " + Str$(Z) Close End Sub Input$ Input$(numbytes%. A+20 Close Open "Test2. . The Input$ function reads all characters.Bat file and displays it in a 'dialog box.[#]filenumber%) Descr.

Example Sub Main() 'This example checks to see whether one string is in another and.. If not specified. then it copies the string to a variable and displays the 'result. then the search starts at the beginning (start = 1). then string comparisons use the current Option Compare setting. then Binary is used (i. If start is specified. then its character position within search$ is returned. The start parameter must be between 1 and 65535.0) Y% = InStr (A$. If the string is not found or start is greater than the length of search$ or search$ is empty. If the string is found. Returns the first character position of string find$ within string search$. If no Option Compare statement has been encountered.e."Stuart". then 0 is returned.6) MbeMessageBox B + " was found--different case" ExitSub Else MbeMessageBox "String not found" End If End Sub Int Int%(number#) 7-86 MicroStation BASIC Guide ."Stuart".6) MbeMessageBox B + " was found--same case" Exit Sub ElseIf Y <> 0 Then B$ = Mid$(A$. with 1 being the character position of the first character. The compare parameter controls how the strings are compared: 0 1 Any other value String comparisons are case-sensitive. A run-time error is produced.X. If compare is not specified.1) If X <> 0 Then B$ = Mid$(A$. String comparisons are case-insensitive. string comparisons are case-sensitive). then the search starts at that character position within search$. A$ = "This string contains the name Stuart and other characters" X% = InStr (A$.Y. 'if it is.A to Z Reference Descr.

due%) Descr. fv#. Per NPer Pv MicroStation BASIC Guide 7-87 7 Standard BASIC Reference . In the case of a retirement plan. be sure to divide the annual interest rate by 12 to get the monthly rate. Examples of annuities are mortgages. this value would be the current value of the fund because you have a set amount of principal in the plan. in that Int truncates negative numbers in a negative direction. this value would be 20. If you want to know the interest paid or received during period 20 of an annuity. An annuity is a series of fixed payments made to an insurance company or other investment company over a period of time.5224 is: " + Str$(B) End Sub The output of the previous example is: -1235. This is usually expressed in months. If the payment periods are monthly. IPmt IPmt#(rate#. In the case of a loan. per#. monthly savings plans and retirement plans. The following table describes the different parameters: Parameter Rate Description A double-precision number that represents the interest rate per period. A double-precision number that represents the present value of your annuity. This function returns the integer part of a given value by returning the first integer less than the given value. A double-precision number that represents the payment period for which you are calculating the interest payment.A to Z Reference Descr. pv#. A double-precision number that represents the total number of payments in the annuity. fixed payments and a fixed interest rate. A# = -1234. Example Sub Main() 'This example extracts the integer part of a number. the present value would be the amount of the loan because that is the amount of cash you have in the present. Int differs from the Fix function. nper#. and you should be sure that the interest rate given above is for the same period that you enter here. sign is preserved. This function returns the interest payment for a given period of an annuity based on periodic.5224 B% = Int (A) MbeMessageBox "The integer part of -1234.

whereas positive values represent interest paid to you.0. 1000." 0. the future value would be the balance of the account after all payments are made. It is usually used to 7-88 MicroStation BASIC Guide . Payments are due at the beginning of ‘the month. The interest paid during the first 10 months ‘is displayed in a table. This function returns the internal rate of return for a series of periodic payments and receipts.00") + crlf Next x MbeMessageBox Msg End Sub IRR IRR#(ValueArray#(). the end of the month). A parameter that indicates when payments are due. it represents interest you are paying out.000. Due Rate and Nper must be in expressed in the same units. The internal rate of return is the equivalent rate of interest for an investment consisting of a series of positive and/or negative cash flows over a period of regular intervals. In the case of a savings plan. then the period given in Nper should also be in years or the annual Rate should be divided by 12 to represent a monthly rate. 1) Msg = Msg + Format$(X. 36. If this value is 1.10/12) . the future value would be zero because you will have paid it off. If the function returns a negative value. 0. In the case of a loan. then payments are due at the end of each period (usually. Msg = "" For x = 1 to 10 IPM# = IPmt((. If Rate is expressed in percentage paid per month. If this parameter is 0."00") + " : " + Format$(IPM. then payments are due at the start of each period (the beginning of the month).00 loan financed over 36 months with an ‘annual interest rate of 10%. If Rate is an annual rate. Guess#) Descr. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example calculates the amount of interest paid ‘on a $1.A to Z Reference Parameter Fv Description A double-precision number that represents the future value of your annuity. then NPer must also be expressed in months. x.

'The projected incomes for this example are generated in two 'For.Next Loops. There must be at least one positive and one negative value to indicate the initial investment (negative value) and the amount earned by the investment (positive value). For X = 6 To 12 Valu(X) = 100 + (X*10) PStr = PStr + Str$(Valu(X)) + ". Positive values are payments. Guess Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example illustrates the purchase of a lemonade stand for $800 'and a series of incomes from the sale of lemonade over 12 months. After 20 tries. It starts with the value of Guess and cycles through the calculation adjusting Guess until the result is accurate within 0. and negative values are receipts. A number you guess as the value that the IRR function will return.A to Z Reference project the rate of return on a business investment that requires a capital investment up front and a series of investments and returns on investment over time. Retrn# = IRR(Valu... " Next x 'Calcluate the sixth through twelfth months' sales."Percent") End Sub MicroStation BASIC Guide 7-89 7 Standard BASIC Reference The value of IRR is found by iteration. and then the internal rate of return is calculated 'and displayed.800 'initial investment PStr$ = Str$(Valu(1)) + ". . if a result cannot be found. (Not a bad investment!) Dim Valu#(12) Valu(1) = . " 'Calculate the second through fifth months' sales. IRR requires the following parameters: Parameter ValueArray() Description An array of double-precision numbers that represent payments and receipts.1) PStr = "The values: " + crlf + PStr + crlf + crlf MbeMessageBox PStr + "Return rate: " + Format$(Retrn.1 (10 percent). IRR fails. For X = 2 To 5 Valu(X) = 100 + (X*2) PStr = PStr + Str$(Valu(X)) + ". and the user must pick a better guess. " Next x 'Calcluate the equivalent investment return rate. The most common guess is ..00001 percent.

Item$ Item$(text$. end-of-lines or user-defined delimiters.7.11.12) R2List$ = Item$(SList. If first is greater than the number of items in text$.9.4.. The Is operator returns TRUE if the two operands refer to the same object. items are separated by commas and end of lines. The first parameter specifies the first item in the sequence to return.e.14.2.12. Both operands must be object variables of the same type (i. the same application-defined object type or both of type object).15" SList$ = "1/2/3/4/5/6/7/8/9/10/11/12/13/14/15" R5List$ = Item$(IList. This operator is used to determine whether two object variables refer to the same object. This can be changed by specifying different delimiters in the delimiters$ parameter. delimiters$]) Descr. first%. otherwise. then all items from first to the end of text are returned.A to Z Reference Is object Is [object | Nothing] Descr. All items between first and last are returned. If last is greater than the number of items in text$.8.5. By default.5.3.9. Example Const Crlf = Chr$(13) + Chr$(10) Sub Main() 'This example creates two delimited lists and extracts a range from 'each. The reserved word Nothing can be used to determine whether an object variable is uninitialized. Returns all the items between first and last within the specified formatted text list.13. last% [."/") MbeMessageBox "Returned lists are: " + crlf + R5List + crlf + R2List End Sub 7-90 MicroStation BASIC Guide . it returns FALSE. IList$ = "1.10. then displays the result in a dialog box.2. then an empty string is returned. An item is a substring of a delimited text string delimited by commas.6. Uninitialized object variables reference no object.

TXT CAT CAP.15" SList$ = "1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19" R1% = ItemCount(IList) R2% = ItemCount(SList.DAT CAP.TXT SAMS. Returns the number of items in the specified delimited text.3. Multiple *'s and ?'s can appear within the expression to form complex searching patterns.9.5. IList$ = "1. whereas the ? character matches any single character. The following table shows some examples: This pattern *S*.13. delimiters$]) Descr.A to Z Reference ItemCount ItemCount%(text$ [.6. such as * and ?."\") Example Sub Main() 'This example creates two delimited lists and then counts the number 'of items in each.4. to parse items using a backslash: n = ItemCount(text$. Deletes all files matching filespec$."/") MbeMessageBox “Lists contain: " + Str$(R1) +" and " + Str$(R2) +" items” End Sub Kill Kill filespec$ Descr.7. The * character matches any sequence of zero or more characters. This can be changed by specifying different delimiters in the delimiters$ parameter. The filespec$ argument can include wild cards.TXT C*T MicroStation BASIC Guide 7-91 7 Standard BASIC Reference .14.2.TXT Matches these files SAMPLE. The counts are displayed in a dialog box. By default.TXT CAT. Items are substrings of a delimited text string.DOC C*T. For example.11.12.TXT CAT.TXT GOOSE.TXT ACATS.TXT Doesn’t match these files SAMPLE SAMPLE.8.10. items are separated by commas and/or end-of-lines.

TXT CAPIT * Example Sub Main() 'This example looks to see whether file Test1. If Not FileExists("Test1.Dat exists.Dat still exists" Else MbeMessageBox "Test?.Dat") Then Open "Test1. 'a message is generated.Dat successfully deleted" End If End Sub LBound LBound%(ArrayVariable() [. 9 To 20) LBa = LBound(A) LBb = LBound(B. 'If it does not.A to Z Reference C?T CAT CUT CT (All files) CAT.e.Dat") Then MbeMessageBox "File Test1..Dat" End If If FileExists ("Test1. The final 'test looks to see whether they are still 'there and displays the result. the first dimension is assumed (i.Dat exists" Kill "Test?. Dim FL$() 7-92 MicroStation BASIC Guide .Dat") Then MbeMessageBox "File Test1. if they exist.2) MbeMessageBox “Lowr bnd A: " + Str$(LBa) + " Lowr bnd B: “ + Str$(LBb) 'This example uses LBound and UBound to dimension a dynamic array to 'hold a copy of an array redimmed by the FileList statement.Dat. If dimension is not specified. Example Sub Main() 'This example dimensions two arrays and displays their lower bounds.Dat" For Output As #2 Close End If If FileExists ("Test1. then it creates both Test1 and Test2. 'The existence of the files is tested again. dimension%]) Descr. and then they are deleted. Returns the lower bound of the specified dimension of the specified array variable. dimension = 1). Dim A(5 To 12) Dim B(2 To 100.Dat" For Output As #1 Open "Test2.

Returns the leftmost NumChars characters from a given string. NumChars%) Descr. the entire string is returned.2. Example Sub Main() 'This example shows the LCase function used to change uppercase 'names to lowercase with an uppercase first letter.2. If NumChars is 0. Lname$ = "WILLIAMS" Fl$ = Left$(Lname. Example Sub Main() 'This example shows the Left$ function used to change uppercase 'names to lowercase with an uppercase first letter. Lname$ = "WILLIAMS" Fl$ = Left$(Lname.1) Rest$ = Mid$(Lname.Len(Lname)) Lname = Fl + LCase$(Rest) MbeMessageBox "The converted name is: " + Lname End Sub MicroStation BASIC Guide 7-93 7 Standard BASIC Reference . If NumChars is greater than or equal to the number of characters in the specified string."*. then an empty string is returned.A to Z Reference FileList FL. Returns the lowercase equivalent of the specified string.Len(Lname)) Lname = Fl + LCase$(Rest) MbeMessageBox "The converted name is: " + Lname End Sub Left$ Left$(str$.1) Rest$ = Mid$(Lname.*" count = UBound(FL) Redim NL$(LBound(FL) To UBound(FL)) For X = 1 To count NL(X) = FL(X) Next x MbeMessageBox "The last element of the new array is: " + NL(count) End Sub LCase$ LCase$(str) Descr.

Lname$ = "WILLIAMS" Fl$ = Left$(Lname. 0 bytes. Returns the number of characters in a given string.1) Ln% = Len(Lname) Rest$ = Mid$(Lname. If used with a non-String variable. The following table describes the sizes of the individual data elements: Data element Integer Long Float Double String Size 2 bytes. the size of each variable-length string within a structure is 2 bytes. or 0 if the string is empty. The elements for fixed arrays are stored within the structure and therefore require the number of bytes for each array element multiplied by each array dimension: array_element_size * dimension1 * dimension2. 8 bytes. Since variable-length strings are stored elsewhere.Ln) 7-94 MicroStation BASIC Guide .2. 4 bytes... Combined size of each structure member element. Len returns the number of bytes occupied by that variable. The Len function always returns 0 with object variables or any application-defined object variable. the function returns the combined size of each member within the structure. Arrays within structures are fixed in their Objects User-defined type dimensions. Both application-defined object variables and variables of type object are always returned as 0 size. Example Const Crl = Chr$(13) + Chr$(10) Sub Main() 'This example shows the Len function used in a routine to change 'uppercase names to lowercase with an uppercase first letter. Variable-length strings within structures require 2 bytes of storage.A to Z Reference Len Len%(str$) Len%(variable) Descr. 4 bytes. When used with user-defined data types. Number of characters in the string.

returning TRUE if expression$ matches the given pattern$.22 Lns(1) = Len(A) Lns(2) = Len(B) Lns(3) = Len(C) Lns(4) = Len(D) Pstr$ = "Lengths of standard types:" + crlf Pstr = Pstr + "Integer: " + Str$(Lns(1)) + crlf Pstr = Pstr + "Long: " + Str$(Lns(2)) + crlf Pstr = Pstr + "Single: " + Str$(Lns(3)) + crlf Pstr = Pstr + "Double: " + Str$(Lns(4)) + crlf MbeMessageBox Pstr End Sub Let [Let] variable = expression Descr.22 D# = 300. Let is supported for compatibility with other implementations of BASIC. FALSE is returned if the match fails at any point. Example Sub Main() Let A$ = "This is a String" Let B% = 100 Let C# = 1213. Assigns the result of an expression to a variable.A to Z Reference Lname = Fl + LCase$(Rest) MbeMessageBox "The converted name is: " + Lname 'This example returns a table of lengths for standard numeric types.3443 End Sub Like expression$ Like pattern$ Descr. MicroStation BASIC Guide 7-95 7 Standard BASIC Reference . Case sensitivity is controlled by the Option Compare setting. Dim Lns(4) A% = 100 B& = 200 C! = 200. The Like operator compares two strings.

use the syntax [A-Z]. Matches any digit. text$ Descr. "[*]" Example Sub Main() 'This example demonstrates various uses of the Like function.45" If A Like "[A-Z][g-i]*" Then MbeMessageBox "Comparison is True" If B Like "##3. Matches if the character in question is within the specified range. A$ = "This is a string variable of 123456 characters" B$ = "123. The file pointer is positioned after the terminating end of line. Matches one or more characters.##" Then MbeMessageBox "Comparison is True" If A Like "*variable" Then MbeMessageBox "Comparison is True" End Sub Line Input # Line Input [#]filenumber%."#?#" "[[]*]" pattern$ (False) "M* B" "M[a-e]ro" "V[r]?s*N" "###". The following table shows some examples: expression$ "MBE" "MicroStation" "Version" "5. "#?[!0-9]" "[ABC]". This statement reads an entire line into the given string variable text$.A to Z Reference pattern$ can contain special characters that allow more flexible matching: Character ? * # [range] [!range] Evaluates to Matches a single character. but the end-of-line (EOL) character(s) are not returned in the string. Matches if the character in question is not within the specified range. A range specifies a grouping of characters. 7-96 MicroStation BASIC Guide .0" "[ABC]" pattern$ (True) "M*E". such as []*?#. To specify a range of characters.#". The file is read up to the next end of line. Special characters must appear within brackets. use the syntax [ABCDE]. "M*" "M*[a-e]roStation" "V[e]?s*n" "#. To specify a match of any of a group of characters.

Example Const Crlf = Chr$(13) + Chr$(10) Sub Main() 'This example reads five lines of the Autoexec. If first is greater than the number of lines in text$.Bat file and 'displays them in a dialog box.Lin$ Msg$ = Msg + Lin$ + crlf Next x MbeMessageBox Msg End Sub Line$ Line$(text$.Lin$ MicroStation BASIC Guide 7-97 7 If last is not specified. and displays them ‘in a dialog box. only one line is returned.Bat" For Input As #1 For X = 1 To 5 Line Input # 1.Bat file. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example reads five lines of the Autoexec. Returns a single line or a group of lines from a text buffer between first and last.Bat" For Input As #1 For X = 1 To 5 Line Input # 1. Standard BASIC Reference . first%[. This statement recognizes either a single line-feed or a carriagereturn line-feed pair as the EOL delimiter. all lines from first to the end of the text are returned. If last is greater than the number of lines in text$. extracts the ‘third and fourth lines with the Line$ function. an empty string is returned.A to Z Reference The filenumber parameter is a number that is used to refer to the open file—the number passed to the Open statement. The text$ parameter is any string variable reference. Txt$ = Null Open "C:\Autoexec. Lines are delimited by carriage-return line-feed pairs. filenumber must reference a file opened in Input mode. This statement will automatically declare the variable if the specified variable has not yet been used or dimensioned. last%]) Descr. Open "C:\Autoexec.

The filenumber parameter is a number that is used to refer to the open file—the number passed to the Open statement. Returns the position of the file pointer in the given file.Lin$ Txt = Txt + Lin + crlf X = X + 1 Wend Lines! = LineCount(Txt) MbeMessageBox “Number of lines” MbeMessageBox “in Txt is: “ + Str$(Lines) + crlf + crlf + Txt End Sub Loc Loc%(filenumber%) Descr.A to Z Reference Txt = Txt + Lin+ crlf Next x Lines$ = Line$(Txt. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() Txt$ = Null X = 1 Open "C:\Autoexec. current byte position divided by 128. Returns the number of lines in the specified text file. The Loc function returns different values depending on the mode in which the file was opened: File mode Input Output Append Returns current byte position divided by 128.Bat" For Input As #1 While (X < 20) And Not EOF(1) Line Input # 1. or both. line-feed. current byte position divided by 128.3. Lines are delimited by carriage-return. 7-98 MicroStation BASIC Guide .4) MbeMessageBox Lines End Sub LineCount LineCount%(text$) Descr.

The filenumber parameter is a number that is used to refer to the open file—the number passed to the Open statement. The Lock statement locks a section of the specified file. The section of the file is specified using one of the following: Syntax No parameters record& to end& Description Lock the entire file (no record specification is given).A to Z Reference File mode Binary Random Returns position of the last byte read or written.Bat" For Input As #1 For X = 1 To 25 If Not EOF(1) Then Line Input # 1. and displays it in a ‘dialog box. Lock the specified record number (for Random files) or byte (for Binary files).{record& | [start&] To end&}] Descr. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example reads 25 lines of the Autoexec.Lin$ Msg$ = Msg + Lin$ + crlf End If Next x Lc% = Loc(1) Close MbeMessageBox "The file location is: " + Str$(Lc) End Sub Lock Lock [#] filenumber% [. start and end parameters are ignored. Lock from the beginning of the file to the specified record (for Random files) or byte (for Binary files).Bat file. For sequential files. Open "C:\Autoexec. number of the last record read or written. The entire file is locked. start& to end& Lock the specified range of records (for Random files) or bytes (for Binary files). determines the ‘current location of the file pointer. preventing other processes from accessing that section of the file until the Unlock statement is issued. MicroStation BASIC Guide 7-99 7 Standard BASIC Reference . the record.

1. It is a good idea to group the Lock and Unlock statements close together in the code. and each record is locked.Rec Unlock #1. Ranges within files are not unlocked automatically when your script terminates.Dat" For Random Access Read Write Shared As #1 For x = 1 To 10 Rec = Mid$(Rec.x Msg = Msg + Rec + crlf Next x Close MbeMessageBox "The records are: " + crlf + Msg Msg = "" Open "Test2. which can cause file access problems for other processes. both for readability and so subsequent readers can see that the lock and unlock are performed on the same range.. The new records are then 'displayed in a dialog box.A to Z Reference The lock range must be the same as that used to subsequently unlock the file range. Example Const Crlf = Chr$(13) + Chr$(10) Sub Main() 'This example creates Test2. 'modified. These are displayed in a dialog box. This practice also reduces errors in file locks.23) + Str$(11-x) Lock #1.x Msg = Msg + Rec + crlf Next x MbeMessageBox "The records are: " + crlf + Msg Close End Sub 7-100 MicroStation BASIC Guide . and all locked ranges must be unlocked before the file is closed.Dat" For Random Access Write Shared As #1 For x% = 1 To 10 Rec = A + Str$(x) Lock #1.Rec Unlock #1. The file 'is then reopened for read/write.x.Dat and fills it with 10 string 'variable records. rewritten.x Put #1. A$ = "This is record number: " B$ = "0" Rec$ = "" Msg$ = "" Open "Test2. and unlocked.x Put #1.

Dat" For Random Access Read Write Shared As #1 X% = Lof(1) Close MbeMessageBox "The length of Test2.. Returns the number of bytes in the given file. Returns the natural logarithm of a given number. Example Const Crlf = Chr$(13) + Chr$(10) Sub Main() 'This example creates a test file.A to Z Reference Lof Lof%(filenumber%) Descr. X# = Log(100) MbeMessageBox "The natural logarithm of 100 is: " + Str$(X) End Sub MicroStation BASIC Guide 7-101 7 Log Standard BASIC Reference .Dat" For Random Access Write Shared As #1 For x% = 1 To 10 Rec = A + Str$(x) Put #1. The value of number must be greater than 0.71828. A$ = "This is record number: " Rec$ = Null Msg$ = Null Open "Test2. The value of e is 2. 'then finds the length of the file and displays it in a message box. The filenumber parameter is a number that is used to refer to the open file—the number passed to the Open statement. writes 10 records into it.Rec Msg = Msg + Rec + crlf Next x Close Open "Test2.Dat is: " + Str$(X) End Sub Log#(number#) Descr. The file must currently be open. Example Sub Main() 'This example calculates the natural log of 100 and displays it in 'a message box.

Dim Msg$. If source$ is longer in length than dest$. then source$ is truncated. Returns the specified string with leading spaces removed. This is useful for copying structures of different types. the LSet statement copies the source string source$ into the destination string dest$. "*") Msg = "Here are two strings that have been right-" + crlf Msg = Msg + "and left-justified in a 40-character string" Msg = Msg + crlf + crlf RSet TmpStr = "Right->" Msg = Msg & TmpStr & crlf LSet TmpStr = "<-Left" Msg = Msg & TmpStr & crlf MbeMessageBox Msg End Sub LTrim$ LTrim$(str$) Descr.A to Z Reference LSet LSet dest$ = source$ LSet dest_udt_variable = source_udt_variable Descr. Example Const Crlf = Chr$(13) + Chr$(10) Sub Main() 'This example replaces a 40-character string of asterisks (*) with 'an RSet and LSet string and then displays the result. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example displays a right-justified string and its LTrim result. and the remaining characters are padded with spaces. the source structure is copied byte for byte into the destination structure. A$ = " <= This is a right-justified string" B$ = LTrim$(A) MbeMessageBox A + crlf + B End Sub 7-102 MicroStation BASIC Guide . Neither the source structure nor the destination structure can contain strings. TmpStr$ TmpStr = String$(40. In syntax 1. then the string is left-aligned within dest$. In syntax 2. Only the number of bytes of the smaller of the two structures is copied. If source$ is shorter in length than dest$. copying only the leftmost number of characters that will fit in dest$.

then the rest of the string is assumed. for length characters.Len(A$)) Mid$ (B. The newvalue$ parameter is any string or string expression to be inserted into the target string. then the entire string. then an empty string is returned. If start is greater than the length of str$. If length is not specified.1) = "NEW " MbeMessageBox A + crlf + B End Sub MicroStation BASIC Guide 7-103 7 Standard BASIC Reference Descr. The str$ parameter specifies the string variable containing the substring to be copied or replaced. A$ = "This is the Main string containing text" B$ = Mid$(A. This defines the subroutine that receives execution control from the host application. beginning with start.A to Z Reference Main Sub Main() End Sub Descr. length%]) Mid$(str$. The substring within str$ to be operated on starts at the character position specified by start for length number of characters.13. . The resultant string is never longer than the original length of str$. The Mid$ function returns a substring of the specified string. Example Const Crlf = Chr$(13) + Chr$(10) Sub Main() 'This example displays a substring from the middle of a string 'variable using the Mid$ function and replaces the first four 'characters with "NEW " using the Mid$ statement. length%]) = newvalue$ If length is not specified. start%[. starting at start. The statement form of Mid$ replaces one part of a string with another. is returned or replaced. start% [. Example Sub Main() MbeMessageBox "This is a Main subroutine" End Sub Mid$ Mid$(str$.

Example Sub Main() 'This example takes the current time. and negative values are receipts (returns on investment).11. There must be at least one positive (investment) value and one negative (return) value A double-precision number representing the interest rate paid on invested monies (paid out). XT# = TimeValue(Time$()) XH# = Hour(XT) XM# = Minute(XT) XS# = Second(XT) MbeMessageBox "Current time is: " + Str$(XH)+":"+Str$(XM)+":"+Str$(XS) End Sub MIRR MIRR#(ValueArray#(). For example. The MIRR function requires the following parameters: Parameter ValueArray() Description An array of double-precision numbers representing the payments and receipts. Positive values are payments (invested capital).A to Z Reference Minute Minute%(serial#) Descr. extracts the hour. FinanceRate ReinvestRate FinanceRate and ReinvestRate should be expressed as percentages. The interest cost of investment and the rate of interest received on the returns on investment are both factors in the calculations. Returns the minute of the hour encoded in the specified serial parameter. 7-104 MicroStation BASIC Guide . This function returns the modified internal rate of return for a series of periodic payments and receipts. and displays them as the current time. 'minute. The modified internal rate of return is the equivalent rate of return on an investment in which payments and receipts are financed at different rates. A double-precision number representing the rate of interest received on incomes from the investment (receipts). ReinvestRate#) Descr. 11 percent should be expressed as 0. and second. FinanceRate#. The value returned is between 0 and 59 inclusive.

1/12.Next loops.. Example Sub Main() 'This example creates a new directory on the default drive. Notice that the ‘annual rates are normalized to monthly rates by dividing them by 12.A to Z Reference To return the correct value. The incomes are estimated '(generated) over 12 months. Error: " + Str$(Err) End If MicroStation BASIC Guide 7-105 7 MkDir Standard BASIC Reference . then the directory already exists and 'the program terminates. The returns are estimated to 'accelerate as the stand gains popularity. The proceeds are placed 'in a bank at 9 percent interest. If no error. " For X = 2 To 5 Valu(X) = 100 + (X*2) 'incomes months 2-5 PStr = PStr + Str$(Valu(X)) + ". Dim Valu#(12) Valu(1) = -800 'initial investment PStr$ = Str$(Valu(1)) + ". the directory is removed 'with the RmDir statement... On Error Resume Next MkDir "TestDir" If Err = 70 Then 'Check whether directory exists. be sure to order your payments and receipts in the correct sequence. " Next x Retrn# = MIRR (Valu.. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example illustrates the purchase of a lemonade stand for $800 'financed with money borrowed at 10%. Creates a new directory as specified by dir$.09/12) 'note: normalized annual rates PStr = "The values: " + crlf + PStr + crlf + crlf MbeMessageBox PStr + "Modified rate: " + Format$(Retrn. and then the modified 'internal rate of return is calculated and displayed. If 'this causes an error 70. Msg$ = "Directory exists! Error: " + Str$(Err) RmDir "TestDir" Else Msg = "TestDir created. This program first generates the 'income stream array in two For. " Next x For X = 6 To 12 Valu(X) = 100 + (X*10) 'incomes months 6-12 PStr = PStr + Str$(Valu(X)) + "."Percent") End Sub MkDir dir$ Descr.

. Example Sub Main() 'This example returns the current month in a dialog box.TEN.FIVE.SEVEN. The value returned is between 1 and 12 inclusive.EIGHT.52) Value = Card Mod 13 If Value = 0 Then Value = 13 CardNum$ = Item$(Cval. Jul.KING" Randomize Card% = Random(1. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example uses the Mod operator to determine the value of a 'randomly selected card where card 1 is the ace (1) of clubs and 'card 52 is the king (13) of spades. Returns the remainder of expression1 /expression2 as a whole number.. Returns the month of the date encoded in the specified serial parameter. Jun. Since the values recur in a 'sequence of 13 cards within 4 suits. The serial value for a text formatted date can be obtained with the DateValue function. Mar. we can use the Mod function to 'determine the value of any given card number. Nov .A to Z Reference MbeMessageBox Msg End Sub Mod expression1 Mod expression2 Descr. Both operands are converted to whole numbers before performing the modulo operation. Apr.. Oct...NINE. Dec.. CVal$="ACE.QUEEN. Aug..THREE.Value) If Card < 53 Then Suit$ = "spades" If Card < 40 Then Suit$ = "hearts" If Card < 27 Then Suit$ = "diamonds" If Card < 14 Then Suit$ = "clubs" Msg$ = "Card number " + Str$(Card) + " is the " Msg$ = Msg$ + CardNum + " of " + Suit MbeMessageBox Msg End Sub Month Month%(serial#) Descr..TWO.JACK.. Mons$ = "Jan. Sep.FOUR." Tdate$ = Date$ TDay! = Month(DateValue(Tdate)) 7-106 MicroStation BASIC Guide . May.SIX.. Feb.

Dat" As "Test2. MicroStation BASIC Guide 7-107 7 Standard BASIC Reference . otherwise. then a bitwise Not is performed. On Error Resume Next If FileExists ("Test.Dat" If Err <> 0 Then Msg$ = "File created but not renamed! Error: " + Sr$(Err) Else Msg = "File created and renamed to Test2.Dat" For Output As #1 Close Name "Test. it is first converted to a Long. Wild-card characters such as * and ? are not allowed.Dat") Then Name "Test. If the operand is numeric. TRUE if expression1 is FALSE. Example Sub Main() 'This example creates a file called Test. Renames a file.Dat" As "Test2. returns FALSE. Each parameter must specify a single filename.Dat and then renames 'it to Test2.A to Z Reference MbeMessageBox ("The current month is: " + Item$(Mons. If the operand is a floating-point value (either Single or Double).TDay)) End Sub Name Name oldfile$ As newfile$ Descr.Dat" If Err <> 0 Then Msg$ = "File exists and cannot be renamed! Error: " + Str$(Err) Else Msg = "File exists and renamed to Test2. then the result is the bitwise Not of the argument.Dat.Dat" End If End If MbeMessageBox Msg End Sub Not Not expression1 Descr.Dat" End If Else Open "Test.

7-108 MicroStation BASIC Guide . is 0. monthly savings plans. This function returns the number of periods for an annuity based on periodic fixed payments and a constant rate of interest.A to Z Reference Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example demonstrates the use of the Not operator in comparing 'logical expressions and for switching a True/False toggle variable. The number is returned in days where Dec 30. Pmt#. Fv#. A = True B = False SWITCH = True If (A and Not B) And (Not (A = B)) Then Msg$ = "A And Not B = True" + crlf Else Msg = "A And Not B = False" + crlf End If Msg = Msg + "Switch is now " + Format$(Switch. Pv#.Second(T1) MbeMessageBox "Elapsed time was: " + Str$(T3) + " seconds" End Sub NPer NPer#(Rate#."True/False") + crlf Switch = Not Switch Msg = Msg + "Switch is now " + Format$(Switch. An annuity is a series of fixed payments paid to or received from an investment over a period of time. The Now function returns a double-precision number representing the current date and time. T1# = Now() MbeMessageBox "Wait a while and click OK" T2# = Now() T3# = Second(T2) . 1899. Example Sub Main() 'This example shows how the Now function can be used as an elapsed'time counter. Examples of annuities are mortgages. retirement plans. Due%) Descr."True/False") MbeMessageBox Msg End Sub Now Now#[()] Descr. and term loans."True/False") + crlf Switch = Not Switch Msg = Msg + "Switch is now " + Format$(Switch.

ag# = NPer((.10/12). A double-precision number representing the amount of each payment or income.0. Example Sub Main() 'This example calculates the number of $100. Pmt Pv Fv Due Positive numbers represent cash received. and the future value (see below) would be zero.10000. A double-precision number representing the present value of your annuity.A to Z Reference NPer requires the following parameters: Parameter Rate Description A double-precision number representing the interest rate per period. whereas negative numbers represent cash paid out. be sure to normalize annual rates by dividing them by 12. A 0 specifies payment at the end of each period. and the present value would be the amount of the loan. If the periods are monthly."Standard") End Sub MicroStation BASIC Guide 7-109 7 Standard BASIC Reference Parameter that indicates when payments are due for each payment period. the future value would be zero.00 monthly payments ‘necessary to accumulate $10. Payments ‘are made at the beginning of the month. In the case of a loan.000. whereas a 1 indicates payment at the start of each period. whereas payments are represented by negative values.1) MbeMessageBox "Number of monthly periods is: " + Format$(ag.100. Income is represented by positive values. In the case of a loan. A double-precision number representing the future value of your annuity. the present value would be the amount of the loan.00 at an annual rate of 10%. .

and a discount rate. This function calculates the net present value of an annuity based on periodic payments and receipts. and then the net present value '(Npv) is calculated and displayed. For accurate results.. If your first cash flow occurs at the beginning of the first period.A to Z Reference Npv Npv#(Rate#. It should not be included in the array of cash flows. that value must be added to the return value of Npv. There must be at least one positive and one negative value. The incomes are estimated '(generated) over 12 months. Npv requires the following parameters: Parameter Rate Description A double-precision number that represents the interest rate over the length of the period. Positive values are payments. Note normalization of the annual ‘10% rate. ValueArray#()) Descr. whereas negative numbers represent cash paid out. be sure to enter your payments and receipts in the correct order. Pv's cash flows are constant. annual rates must be divided by 12 to normalize them to monthly rates.Next loops. " For X = 2 To 5 'months 2-5 Valu(X) = 100 + (X*2) 7-110 MicroStation BASIC Guide .. If the values are monthly. Npv differs from the Pv function in that the payments are due at the end of the period and the cash flows are variable. ValueArray() Positive numbers represent cash received. The returns are estimated to 'accelerate as the stand gains popularity. and negative values are receipts. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example illustrates the purchase of a lemonade stand for $800 'financed with money borrowed at 10%. This program first generates the income 'stream array in two For. as Npv uses the order of the array values to interpret the order of the payments and receipts. and payment may be made at either the beginning or end of the period. An array of double-precision numbers representing the payments and receipts. Dim Valu#(12) Valu(1) = -800 'initial investment PStr$ = Str$(Valu(1)) + ".

Null strings require no memory. The number parameter can be any type but is rounded to the nearest whole number before converting to the octal equivalent. Example Sub Main() 'This example shows how the Null function can be used to initialize 'and reset strings. . Returns a string containing the octal equivalent of the specified number.A to Z Reference PStr = PStr + Str$(Valu(X)) + ". The returned string contains only the number of octal digits necessary to represent the number. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example displays the octal equivalent of several numbers. " Next x For X = 6 To 12 'months 6-12 Valu(X) = 100 + (X*10) 'accelerated income Pstr = PStr + Str$(Valu(X)) + ". " Next x NetVal# = NPV ((.10/12). St$ = "The octal values are: " + crlf For X% = 1 To 5 MicroStation BASIC Guide 7-111 7 Standard BASIC Reference An empty string ("") can also be used to remove all characters from a string. However."Currency") End Sub Null Null[()] Descr.Valu) PStr = "The values: " + crlf + PStr + crlf + crlf MbeMessageBox PStr + "Net present value: " + Format$(NetVal. A$ = Null() B$ = "This string is several characters long" MbeMessageBox "A: >" + A + "< B: =>" + B + "<=" B = Null MbeMessageBox "A: =>" + A + "<= B: =>" + B + "<=" End Sub Oct$ Oct$(number%) Descr. empty strings still require some memory for storage. Returns a null string (a string that contains no characters and requires no storage).

The form On Error Goto 0 causes any existing error trap to be removed.. The form On Error Resume Next causes execution to continue at the next line after the line that caused the error. and then control should be resumed using the Resume statement.e. If a procedure ends while an error is pending. then the error is fatal. these statements turn off the fact that an error occurred): Resume Err=-1 7-112 MicroStation BASIC Guide . appropriate action should be taken. If an error trap is in effect when the macro ends. An error trap is only active within the subroutine or function in which it appears. then the error handler of the caller (or any procedure in the call stack) will be invoked. Defines the action taken when a trappable run-time error occurs. then an error will be generated. Resume resets the error handler and continues execution. The form On Error Goto label causes execution to transfer to the specified label when a run-time error occurs. causing the macro to stop executing. If there is no such error handler. allowing a procedure to end without displaying an error message. then an error will be generated.) Errors within an Error Handler If an error occurs within the error handler. (The Exit Sub or Exit Function statement also resets the error handler.A to Z Reference Y% = X * 10 St = St + Str$(Y) + " : $" + Oct$(Y) + crlf Next x MbeMessageBox St End Sub On Error On Error {Goto label | Resume Next | Goto 0} Descr. The following statements reset the error state (i. Once an error trap has gained control.

the error trap is reset to Resume Next. if an On Error statement occurs within an error handler. it executes the error trap and changes the message. and the RmDir is executed again (to create an error 'for this example). Thus. the next line resets the error trap with On 'Error Goto 0. The Err=-1 statement allows explicit resetting of the error state so that the script can continue normal execution without resuming to the statement that caused the error condition. 'which ignores the error (if any) and tries to remove the directory. 'If it is successful. 'If there is an error. it has the effect of changing the location of a new error handler for any new errors that may occur once the error has been reset.A to Z Reference Resume forces execution to continue either on the same line or on the line following the line that generated the error. After 'performing this twice. The On Error statement will not reset the error. Msg$ = Null On Error Goto DirError For X = 1 To 2 Msg = "Directory created" MkDir "TestDir" MbeMessageBox Msg Next x RmDir "TestDir" On Error Resume Next RmDir "TestDir" MbeMessageBox "No error trap: RmDir failed" On Error Goto 0 RmDir "TestDir" Exit Sub DirError: If Err = 70 Then Msg$ = "Directory exists! Error: " + Str$(Err) RmDir "TestDir" Resume Next Else Msg$ = "Unspecified error (remove directory)! " + Str$(Err) Resume Next End If End Sub MicroStation BASIC Guide 7-113 7 Standard BASIC Reference . Example Sub Main() 'This example tries to create a new subdirectory in the current path. The last RemDir statement will cause a run-time 'error that is not trapped." 'Otherwise. then it displays a message "Directory created.

The value of accessmode. Open existing or create a new file for binary I/O. The accessmode parameter determines what type of I/O operations can be performed on the file: Access Read Write Description Opens the file for reading only. The value of accessmode. filenumber is a number between 1 and 255. Open an existing or create a new file for sequential output. The mode parameter determines the type of operations that can be performed on that file: File mode Input Output Description Opens an existing file for sequential input (filename$ must exist). must be Write. The FreeFile function can be used to determine an available file number. if specified. Opens the file for both reading and writing. if specified. Existing random files are truncated only if accessmode is Write. The reclen parameter determines the record length for I/O operations. The value of accessmode. Random or Input mode. Open an existing or create a new file for sequential output. Random or Append mode.A to Z Reference Open Open filename$ [For mode] [Access accessmode] [lock] As [#] filenumber% [Len = reclen%] _ Descr. Random is used. must be Read Write. positioning the file pointer at the end of the file. Append Binary Random If mode is missing. assigning the open file to the supplied filenumber. if specified. Read Write 7-114 MicroStation BASIC Guide . This value is valid only for files opened in Binary. truncating its length to zero. if specified. Opens the file for writing only. Open existing or create a new file for record I/O. Random or Output mode. must be Read. The value of accessmode. This value is valid only for files opened in Binary. The Open statement opens a file for a given mode. The filename$ parameter is a string expression that contains a valid filename. This value is valid only for files opened in Binary. Existing binary files are never truncated in length. Opening a file in Random mode with accessmode set to Write truncates the file's length to 0. determines how the file can subsequently be accessed.

Read Same as Binary files Random Lock value Shared Lock Read Lock Write Lock Read Write Description Another process can both read this file and write to it. then 128 used. (Deny write) Another process is prevented both from reading this file and from writing to it. (Deny read) Another process can read this file but not write to it. (Deny none) Another process can write to this file but not read it. the file is opened twice—once to create the file and again to establish the correct sharing mode. For Binary files. (Exclusive) If the file does not exist and lock is specified. the file is opened in compatibility mode (i.e. Files opened in Random mode are divided up into a sequence of records.. access is attempted three times in the following order: 1. Write 3. the following defaults are used: File mode Input Output Append Binary Default value for accessmode Read Write Read Write When the file is initially opened. For files opened for sequential I/O.Dat" For Output Access Write Lock Write As #2 Close MicroStation BASIC Guide 7-115 7 Standard BASIC Reference The lock parameter determines what access rights are granted to other processes that attempt to open the same file. Open "Test1. reclen is ignored. Read Write 2. each of the length specified by the reclen parameter.A to Z Reference If accessmode is not specified. If lock is not specified. reclen specifies the size of the internal buffer when performing I/O. Example Sub Main() 'This example opens several files in various configurations. The following table describes the values for lock: . If this parameter is missing. Larger buffers mean faster file access. only the current process can access the file).

e.A to Z Reference Open "Test1.Dat" Close Open "Test1. By default.e. StrComp and the Like operator.Dat" Close Open "Test1. This statement must appear outside of any functions or subroutines. When Option Compare is set to Binary. Option Compare affects all string comparisons in any statements that follow it. ‘A’ is equal to ‘a’)..Dat" Close Open "Test1.Dat" Close Kill "Test1. Additionally. string comparisons are case-insensitive (i. The following table shows the types of string comparisons affected by this setting: > < <> 7-116 MicroStation BASIC Guide . The default value for Option Compare is Binary. Example Option Base 1 Sub Main() Dim a(10) End Sub Contains 10 elements (not 11).. When it is set to Text. the setting affects the default behavior of Instr. The Option Compare statement controls how strings are compared. Option Compare Option Compare [Binary | Text] Descr.Dat" Close Open "Test1. string comparisons are case-sensitive (i. the lower bound used for all array declarations is 0. ‘A’ does not equal ‘a’).Dat" End Sub For Input Access Read Shared As #1 For Append Access Write Lock Read Write as #3 For Binary Access Read Write Shared As #4 For Random Access Read Write Lock Read As #5 For Input Access Read Write Shared As #6 Option Base Option Base {0 | 1} Descr. This statement sets the lower bound for array declarations.

FALSE. the result is the bitwise Or of the arguments. Standard BASIC Reference . Example Sub Main() 'Uses the Or operator in a logical comparison. it cannot appear within a Sub or Function block. otherwise. If either operand is a floating-point number. True if either expression1 or expression2 is TRUE. both operands are first converted to Longs. In other words. then a bitwise Or is performed.A to Z Reference <= StrComp >= Like Option Compare must appear outside the scope of all subroutines and functions. 'Calls subroutine above. MicroStation BASIC Guide 7-117 7 'Calls subroutine above. Instr Example 'This example shows the use of Option Compare. If both operands are numeric. Option Compare Binary Sub CompareBinary A$ = "This String Contains B$ = "this string contains If A = B Then MbeMessageBox "The two Else MbeMessageBox "The two End if End Sub Option Compare Text Sub CompareText A$ = "This String Contains B$ = "this string contains If A = B Then MbeMessageBox "The two Else MbeMessageBox "The two End if End Sub Sub Main() CompareBinary CompareText End Sub UPPERCASE" uppercase" strings were compared case-insensitive" strings were compared case-sensitive" UPPERCASE" uppercase" strings were compared case-insensitive" strings were compared case-sensitive" Or expression1 Or expression2 Descr.

Due%) 7-118 MicroStation BASIC Guide ."Standard") MbeMessageBox Msg End Sub Pmt Pmt#(Rate#."0") + " = " Msg = Msg + Format$(Z. Fv#. Pv#.141592653589793238462643383279. NPer#."Standard") + crlf Msg = Msg + "Area: " + Format$(Area. Dia# = 5 Circ# = PI * Dia Area# = PI * ((Dia / 2) ^ 2) Msg$ = "Diameter: 5" + crlf Msg = Msg + "Circumference: " + Format$(Circ."True/False") + crlf Next y Next x MbeMessageBox Msg End Sub PI PI Descr. Msg$ = Null For X% = True To False For Y% = True To False Z = X Or Y Msg = Msg + Format$(Abs(X)."0") + " Or " Msg = Msg + Format$(Abs(Y). 3.A to Z Reference A$ = "First line" B$ = "Second line" If (A = "First line") Or (B = "Another line") Then MbeMessageBox "The comparison is True" Else MbeMessageBox "The comparison is False" End If 'Constructs a truth table for the Or statement. PI can also be determined using the following formula: 4 * Atn(1) Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example illustrates the use of the PI constant.

00. In the case of a loan.00 ‘loan over 36 months at an annual rate of 10%.0. Pmt requires the following parameters: Parameter Rate Description A double-precision number representing the interest rate per period. X = Pmt((. Payments are due at ‘the beginning of the period. Per#.A to Z Reference Descr. Parameter that indicates when payments are due for each payment period."Currency") End Sub PPmt PPmt#(Rate#. A double-precision number representing the future value of your annuity. Fv#. In the case of a loan. An annuity is a series of fixed payments made to an insurance company or other investment company over a period of time. NPer Pv Fv Due Rate and NPer must be expressed in the same units. whereas negative numbers represent cash paid out. Examples of annuities are mortgages and monthly savings plans. Positive numbers represent cash received. If Rate is expressed in months. the present value would be the amount of the loan. the future value would be 0.1/12). Example Sub Main() 'This example calculates the payment necessary to repay a $1. periodic payments and a constant interest rate. A 0 specifies payment at the end of each period.1000. The Pmt function returns the payment for an annuity based on fixed.000.36. Pv#.1) Msg$ = "The payment to amortize $1. be sure to normalize annual rates by dividing them by 12. If the periods are given in months. A double-precision number representing the present value of your annuity. A double-precision number representing the total number of payments in the annuity.000 over 36 months @ 10% is: " MbeMessageBox Msg + Format$(X. NPer#. then NPer must also be expressed in months. whereas a 1 specifies payment at the start of each period. Due%) MicroStation BASIC Guide 7-119 7 Standard BASIC Reference .

An annuity is a series of fixed payments made to an insurance company or other investment company over a period of time. the present value would be the amount of the loan. whereas positive values represent payments received. a double-precision number representing the future value of your annuity.0. a double-precision number representing the number of payment periods.00.0) Bal = Bal + Prn Msg = Msg + Format$(Pay. Negative values represent payments paid out.1000.0. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example calculates the principal paid during each year on a ‘loan of $1. PPmt requires the following parameters: Parameter Rate Per NPer Pv Description a double-precision number representing the interest rate per period.000.10."Currency") 7-120 MicroStation BASIC Guide . then payments are due at the end of each period.000" + crlf + "at 10% annually for" Msg = Msg + " 10 years: " + crlf + crlf Bal = 1000. indicates when payments are due. If Rate is expressed in months.00 with an annual rate of 10%. Pay = Pmt(. The result is displayed ‘as a table containing the following information: payment.1."Currency") + " " + Format$(Prn. In the case of a loan. Fv Due Rate and NPer must be in the same units to calculate correctly. principal 'balance.A to Z Reference Descr. if 1.1000. a double-precision number representing the present value of annuity. Examples of annuities are mortgages and monthly savings plans. a double-precision number representing the total number of payments in the annuity. the future value would be 0. If 0.1) Msg$ = "Amortization table for 1.Per.1. The PPmt function calculates the principal payment for a given period of an annuity based on fixed.00 For Per = 1 to 10 Prn = PPmt(. NPer must also be expressed in months. In the case of a loan. then payments are due at the start of each period. periodic payments and a constant interest rate.10. principal ‘payment. Per can be no less than 1 and no greater than NPer.

Open i% = 10 s$ = "This is a test" Print "The value of i=". Print i%. | . The Tab and Spc functions provide additional control over the column position. Strings are written in their literal form. Each expression in expressionlist is separated with a comma ‘. whereas Spc outputs the specified number of spaces. Print zones are defined every 14 spaces.s$ 'Print the value of i% in print zone 1 and s$ in print zone 3.’ or semicolon ‘. Viewport.s$ MicroStation BASIC Guide 7-121 7 Standard BASIC Reference .s$ 'Print the value of i% and s$ separated by 10 spaces.’.i%. Example Sub Main() 'The next example opens a viewport and prints some data. A comma means that the next expression is output in the next print zone. If the last expression in the list is not followed by a comma or a semicolon. The next Print statement will output information immediately following the expression. Integers and Longs are written with an initial space reserved for the sign (space = positive)."the value of s=". with no enclosing quotes. The actual output device depends on the platform on which BASIC is running. The Print statement prints data to an output device.. Tab moves the file position to the specified column.Spc(10). If the last expression in the list ends with a comma."Currency") + crlf Next Per MbeMessageBox Msg End Sub Print Print [[{Spc(n) | Tab(n)}][expressionlist][{. A semicolon means that the next expression is output immediately after the current expression. a carriage return is printed to the file.A to Z Reference Msg = Msg + " " + Format$(Bal. Print i%. no carriage return is printed. the file pointer is positioned at the start of the next print zone on the current line.}]] Descr. Additionally. If the last expression ends with a semicolon. there is a space following each number.

The Tab and Spc functions provide additional control over the file position. The Write statement always outputs information ending with an end-of-line. no end of line is printed. Writes data to a sequential disk file. A semicolon means that the next expression is output immediately after the current expression. filenumber is a number used to refer to the open file—the number passed to the Open statement. then an end-of-line is printed to the file. Strings are written in their literal form. The next Print statement will output information immediately following the expression.Dat" For Output As #1 7-122 MicroStation BASIC Guide . Print i%. A comma means that the next expression is output in the next print zone.|. If the last expression in the list ends with a comma. Print can only be used with files that are opened in Output or Append mode. the file pointer is positioned on a new line. Open "Test.. If the last expression in the list is not followed by a comma or semicolon.’.s$ 'Print the value of i% and s$. If the last expression ends with a semicolon. whereas Spc outputs the specified number of spaces.}]] Descr. there is a space following each number. Integers and Longs are written with an initial space reserved for the sign (space = positive).Tab(30).s$. Each expression in expressionlist is separated with a comma ‘. Tab moves the file position to the specified column. Example Sub Main() 'The next example opens a file and prints some data. Print 67 End Sub Print# Print filenumber%. with no enclosing quotes. [[{Spc(n) | Tab(n)}][expressionlist][{. if a Print statement is followed by a Write . the file pointer is positioned at the start of the next print zone on the current line.A to Z Reference 'Print the value of i in column 1 and s$ in column 30. Print zones are defined every 14 spaces. Print i%. Additionally.’ or semicolon ‘.. Thus.

.s$ 'Print the value of i in column 1 and s$ in column 30.s$ 'Print the value of i% in print zone 1 and s$ in print zone 3..i%.s$. Print #1.Spc(10). Up to 60 array dimensions are allowed.i%.. the following are allowed: Private foo As Integer Private foo% subscripts allows the declaration of arrays.s$ 'Print the value of i% and s$.s$ 'Print the value of i% and s$ separated by 10 spaces."The value of i=".i%.. Print #1.[lower To] upper].i%. If a type-declaration character is used when specifying name (such as %. The lower and upper parameters are integers specifying the lower and upper bounds of the array.. Print #1. Print #1. Declares a list of private variables and their corresponding types and sizes. &. then the lower bound as specified by Option Base is used (or 0 if no Option Base statement has been encountered).i%. $ or !). the optional [As type] expression is not allowed. Dynamic arrays are declared by not specifying any bounds: Private a() MicroStation BASIC Guide 7-123 7 Standard BASIC Reference .67 Close #1 End Sub Private Private name [(subscripts)] [As type] [. If lower is not specified. This parameter uses the following syntax: [lower To] upper [. The total size of an array (not counting space for strings) is limited to 64K.."the value of s=". Descr.Tab(30). Print #1. For example.A to Z Reference i% = 10 s$ = "This is a test" Print #1. name [(subscripts)] [As type]].. Private variables are global to every subroutine and function within the currently executing macro.

Single. If a variable is seen that has not been explicitly declared with either Dim. If a type-declaration character is used when specifying name (such as %. then it will be implicitly declared local to the routine in which it is used. the following are allowed: Public foo As Integer Public foo% subscripts allows the declaration of arrays. See also Public. Dynamic arrays are declared by not specifying any bounds: Public a() type specifies the type of the data item being declared. This parameter uses the following syntax: [lower To] upper [. &. the optional [As type] expression is not allowed. $ or !). Descr.A to Z Reference type specifies the data type of the item being declared. application-defined object. Double.[lower To] upper].. object. lower and upper are integers specifying the lower and upper bounds of the array. Long. Integer. It can be any of the following data types: String. Declares a list of public variables and their corresponding types and sizes.. If lower is not specified. For example. Up to 60 array dimensions are allowed. name [(subscripts)] [As type]]. or any user-defined data type. Long. The total size of an array (not counting space for strings) is limited to 64K. object. or any user-defined data type... application-defined data type. Double. Public or Private. Public variables are global to all Subs and Functions in all loaded macros. application-defined object. 7-124 MicroStation BASIC Guide . then the lower bound as specified by Option Base is used (or 0 if no Option Base statement has been encountered). Single. application-defined data type. Integer. It can be any of the following data types: String. Public Public name [(subscripts)] [As type] [.

Example 'This example uses a subroutine to calculate the area of 10 circles 'and displays the result in a dialog box. then writing that many characters to the file. Public R#. variable-length strings are written by first writing a 2-byte length. The variables R and Ar are ‘declared as Public variables so that they can be used in both Main ‘and Area.Ar# Sub Area() Ar = (R ^ 2) * Pi End Sub Sub Main() Msg$ = Null For X = 1 To 10 R = X Area Msg = Msg + Str$(R) + " : " + Str$(Ar) + crlf Next x MbeMessageBox Msg End Sub Put Put [#] filenumber% . variable-length strings are written by first determining the specified string variable's length. Writes data from the specified variable to a Random or Binary file. 4 bytes are written to the file. 8 bytes are written to the file (IEEE format). In Binary files. 4 bytes are written to the file (IEEE format). For compatibility. Public or Private. In Random files. Double Single MicroStation BASIC Guide 7-125 7 variable is the name of any variable of any of the following types: Standard BASIC Reference . then writing that many bytes to the file. variable Descr. [recordnumber%].A to Z Reference If a variable is seen that has not been explicitly declared with either Dim. the keyword Global is also supported—it has the same meaning as Public. Variable type Integer Long String File storage description 2 bytes are written to the file. then it will be implicitly declared local to the routine in which it is used.

variable-length strings within user-defined types are written by first writing a 2-byte length followed by the string's content. With Binary files. this number represents the first byte to be written starting with the beginning of the file (the first byte is 1). the data elements are written contiguously. then writes 10 'records into the file with the values 10.recvar If recordlength is specified. as in the following example: Put #1. Arrays Objects The optional recordnumber parameter specifies which record is to be written to the file. If recordnumber is not specified. the record length must be greater than or equal to the combined size of each element within the data type. the commas must still appear. With Random files. this number represents the record number starting with the beginning of the file (the first record is 1). it overrides any previous change in file position specified with the Seek statement. If recordnumber is not specified. and the 'records are read with the Get statement.Dat" For Random Access Write As #1 For X% = 1 To 10 Y% = X * 10 7-126 MicroStation BASIC Guide . The data elements are never separated with padding. a run-time error will occur if the length of the data being written exceeds the record length (specified as the reclen parameter with the Open statement). For Binary files. the next record is written to the file (if no records have been written yet. The result is displayed 'in a dialog box. When writing user-defined types.. the entire record is written along with padding (whatever data happens to be in the I/O buffer at that time). This value ranges from 1 to 2147483647. For Random files.A to Z Reference Variable type User-defined types File storage description Each member of a user-defined data type is written individually. Object variables cannot be written to a file using the Put statement. In Binary files. Open "Test2. then the first record in the file is written). Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example opens a file for random write. This storage is different than variable-length strings outside of user-defined types..50.. If the length of the data being written is less than the record length. Then the file 'is closed and reopened in random mode for read. Arrays cannot be written to a file using the Put statement.

whereas a 1 specifies payment at the start of each period. If Rate is expressed in months. then NPer must also be expressed in months. A double-precision number representing the future value of the annuity after the last payment has been made. Example Sub Main() 'This example demonstrates the present value (the amount you'd have MicroStation BASIC Guide 7-127 7 Standard BASIC Reference Descr. . When used with monthly payments. NPer Pmt Fv Due Rate and NPer must be expressed in the same units. Pmt#.Y Next X Close Pstr$ = "" Open "Test2.X.Dat" For Random Access Read As #1 For Y = 1 To 5 Get #1. A double-precision number representing the total number of payments in the annuity. A 0 specifies payment at the end of each period.y. Due%) Pv requires the following parameters: Parameter Rate Description A double-precision number representing the interest rate per period.A to Z Reference Put #1. whereas negative numbers represent cash paid out. The Pv function calculates the present value of an annuity based on future periodic. NPer#. Number that determines when the payments are due for each payment period. A double-precision number representing the amount of each payment per period. the future value would be 0. be sure to normalize annual percentage rates by dividing them by 12.X Pstr = Pstr + "Record " + Str$(Y) + ": " + Str$(X) + crlf Next Y MbeMessageBox Pstr Close End Sub Pv Pv#(Rate#. In the case of a loan. fixed payments and a constant interest rate. Fv#. Positive numbers represent cash received.

PVal = Pv(. Initializes the random number generator with a new seed. If seed is not specified. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example sets the randomize seed to a random number between '100 and 1000.1.000 over 20 years at an annual interest rate of 10%. Returns a random number greater than or equal to min and less than or equal to max.A to Z Reference ‘to pay now) for a $100. The expressions that appear in place of min and max will be rounded to the nearest whole number.-5000. A runtime error is generated if min is greater than max.000 annuity that pays an annual income ‘of $5. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example uses the random number generator to generate ten 'lottery numbers: Msg$ = Null Randomize For X = 1 To 10 Y = Random(0.100) Msg = Msg + Str$(Y) + crlf 7-128 MicroStation BASIC Guide . then generates ten random numbers for the lottery. Randomize Msg$ = Null For X = 1 To 10 Y = Random(0. max&) Descr."Currency") End Sub Random Random&(min&.20. then the current value of the system clock is used.100) Msg = Msg + Str$(Y) + crlf Next x MbeMessageBox "Ten Numbers for the Lottery: " + crlf + Msg End Sub Randomize Randomize [seed&] Descr.100000.1) MbeMessageBox "The present value is: " & Format$(PVal.

A to Z Reference Next x MbeMessageBox "Ten Numbers for the Lottery: " + crlf + Msg End Sub Rate Rate#(NPer#. This function returns the rate of interest for each period of an annuity.10000. FV#.1) MicroStation BASIC Guide 7-129 7 Guess Standard BASIC Reference a double-precision number representing the total number of payments in the annuity. a double-precision number representing the present value of your annuity. the present value would be the amount of the loan. Example Sub Main() 'This example calculates the rate of interest necessary to save $10. Rate fails and the user must pick a better guess.00001 percent. . PV#. It starts with the value of Guess. In a loan situation. If a result cannot be found after 20 tries. FV Due Positive numbers represents cash received. An annuity is a series of fixed payments made to an insurance company or other investment company over a period of time. R# = Rate(10. a number you guess as the value the Rate function will return. The most common guess is . Examples of annuities are mortgages and monthly savings plans. Due%.. a double-precision number representing that future value of the annuity after the last payment has been made.000 'by paying $550 each year for 10 years. Rate requires the following parameters: Parameter NPer Pmt PV Description a double-precision number representing the amount of each payment per period.-550. Pmt#. the future value would be zero.000. The value of Rate is found by iteration. and cycles through the calculation adjusting Guess until the result is accurate within 0. while negative values represent cash paid out. The guess rate is 10%.1 (10 percent). In the case of a loan.1. determines when the payments are due for each payment period. Guess#) Descr. A 0 specifies payment at the end of each period while 1 indicates payment at the start of each period.

specifying a new upper and lower bound for each dimension of the array. the new elements are initialized to zero (or empty string). Dim FL$() 7-130 MicroStation BASIC Guide . then 0 is used (or the value set using the option base statement. Arrays can be declared using any fundamental data type. If the preserve is specified.. If the array variable already exists. The type parameter can be used to specify the array element type. then the extra elements will be deleted. Descr. userdefined data types. then the number of dimensions of the array being dimensions must either be 0 or the same as the new number of dimensions. When this keyword is specified. If the number of elements in an array dimension increased.. Redimensioning an array erases all elements of that array unless the preserve keyword is specified.. then it must be previously declared with the Dim statement with no dimensions. If the number of elements in an array dimension is decreased."Percent") End Sub ReDim Redim [Preserve] variablename (subscriptRange) [As type]. or the name of a new array variable. If lower is not specified. The subscriptRange parameter specifies the new upper and lower bounds for each dimension of the array using the following syntax: [lower% To] upper% [. as shown in the following example: Dim a$() 'dynamic array of strings (no dimensions yet) Dynamic arrays can be redimensioned any number of times. and objects.A to Z Reference MbeMessageBox "The Rate required is: " + Format$(R. Example Sub Main() 'This example uses the FileList statement to redim and fill an array 'with file name strings. The variablename parameter specifies the name of an existing array (previously declared using the Dim statement).[lower% To] upper%].. existing data in the array is preserved where possible.. A new array is then redimmed to hold the 'number of elements found by FileList and the FileList array is 'copied into it and partially displayed. This statement redimensions an array.

and closed with the Reset Statement 'then deleted with the Kill statement. Causes the compiler to skip all characters on that line. Example Sub Main() REM This line is a line of comments which serve to illustrate the REM workings of the code and insert comments to make it more REM readable and maintainable in the future.Dat") Then MbeMessageBox "The file was not deleted" Else MbeMessageBox "The file was deleted" End If End Sub Resume Resume {[0] | Next | label} Descr.A to Z Reference FileList FL. MicroStation BASIC Guide 7-131 7 Standard BASIC Reference . The form Resume 0 (or simply Resume by itself) causes execution to continue with the statement that caused the error. Ends an error handler and continues execution. End Sub Reset Reset Descr. Example Sub Main() 'A file is opened for output. Open "Test. Closes all open files."*.Dat" If FileExists("Test. writing out all I/O buffers.*" count = Ubound(FL) ReDim NL$(Lbound(FL) To Ubound(FL)) For X = Lbound(FL) to count NL(X) = FL(X) Next x MbeMessageBox "The last element of the new array is: " + NL(count) End Sub REM REM text Descr.Dat" for output access write as # 1 Reset Kill "Test.

This means that. after executing this statement.) 'The lastRemDir statement will cause a run-time error which is not 'trapped. 'If it is successful then it displays a message "Directory created" 'Otherwise it executes the error trap and changes the message. Msg$ = Null On Error Goto DirError For X = 1 To 2 Msg = "Directory Created" MkDir "TestDir" MbeMessageBox Msg Next x RmDir "TestDir" On Error Resume Next RmDir "TestDir" MbeMessageBox "No Error Trap: RmDir Failed" RemoveError: On Error Goto 0 RmDir "TestDir" Exit Sub DirError: If Err = 70 Then Msg$ = "Directory exists! Error: " + Str$(Err) RmDir "TestDir" Resume Next Else Msg$ = "Unspecified Error (Remove Directory)! " + Str$(Err) Resume RemoveError End If End Sub 7-132 MicroStation BASIC Guide . After 'performing this twice.A to Z Reference The form Resume Next causes execution to continue with the statement following the statement that caused the error. the error trap is reset to "Resume Next" which 'ignores the error (if any) and tries to remove the directory. Example Sub Main() 'This example tries to create a new subdirectory in the current path. new errors can be generated and trapped as normal. If there 'is an error the next line resets the error trap with "On Error Goto 0" 'and the RmDir is executed again (to create an error for this example. The Resume statement resets the error state. The form Resume label causes execution to continue at the specified label.

Lname$ = "WILLIAMS" X = Len(Lname) Rest$ = Right$(Lname. Example Sub Main() 'A subroutine is called and then execution is returned to the main 'routine by the Return statement. If NumChars is 0.1) Lname = Fl + LCase$(Rest) MbeMessageBox "The Converted name is: " + Lname End Sub RmDir RmDir dir$ Descr. then the entire string is returned. A runtime error results if a Return statement is encountered without a corresponding Gosub statement. then an empty string is returned. Transfers execution control to the statement following the most recent Gosub. Removes the specified directory. Example Sub Main() 'This routine creates a directory and then deletes it with RmDir On Error Goto ErrMake MicroStation BASIC Guide 7-133 7 Standard BASIC Reference .1) FL$ = Left$(Lname.X . NumChars$) Descr. If NumChars is greater than or equal to the length of the string. Example Sub Main() 'This example shows the Right$ function used in a routine to change 'upper case names to lower case with an upper case first letter. Returns the specified rightmost characters from a string. If True Then Gosub SubTrue MbeMessageBox "The main routine continues here" Exit Sub SubTrue: MbeMessageBox "This message is generated in the Subroutine" Return End Sub Right$ Right$(str$.A to Z Reference Return Return Descr.

If source$ is shorter in length than dest$. If number is omitted. then the string is right aligned within dest$ and the remaining characters are padded with spaces. copying only the leftmost number of characters that will fit in dest$. then source$ is truncated. The RSet statement copies the source string source$ into the destination string dest$. Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example Replaces a 40 character string of asterisks (*) with 7-134 MicroStation BASIC Guide . If source$ is longer in length than dest$. Otherwise. the next random number is returned. Returns a single precision random number between 0 and 1. the number parameter has the following meaning: number < 0 number = 0 number > 0 Always returns the same number Returns the last number generated Returns the next random number Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This routine generates a list of random numbers and displays them For x = -1 To 8 y! = Rnd(1) * 100 Msg$ = Msg + Str$(X) + " : " + Str$(y) + crlf Next MbeMessageBox msg + "Last form: " +Str$(Rnd) End Sub RSet RSet dest$ = source$ Descr.A to Z Reference MkDir("TEST01") On Error Goto ErrRemove RmDir("Test01") ErrMake: MbeMessageBox "The directory could not be created" Exit Sub ErrRemove: MbeMessageBox "The directory could not be removed" Exit Sub End Sub Rnd Rnd![(number!)] Descr.

TmpStr$ TmpStr = String$(40.A to Z Reference 'a RSet and LSet string and then displays the results. Dim Msg$. and second and displays them as the current time. A$ = "This is a left justified string " B$ = RTrim$(A) MbeMessageBox A + "<=" + crlf + B + "<=" End Sub Second Second%(serial#) Descr. . 'minute. Returns the second of the day encoded in the specified serial parameter. The value returned is between 0 and 59 inclusive. XT# = TimeValue(Time$()) XH# = Hour(XT) XM# = Minute(XT) XS# = Second(XT) MbeMessageBox "Current Time is: " + CStr(XH)+":"+CStr(XM)+":"+CStr(XS) End Sub Seek (function) Seek&(filenumber%) MicroStation BASIC Guide 7-135 7 Standard BASIC Reference Descr. "*") Msg = "Here are two strings that have been right" + crlf Msg = Msg + "and left justified in a 40 character string" Msg = Msg + crlf + crlf RSet TmpStr = "Right->" Msg = Msg & TmpStr & crlf LSet TmpStr = "<-Left" Msg = Msg & TmpStr & crlf MbeMessageBox Msg End Sub RTrim$ RTrim$(str$) Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example displays a left justified string and it's RTrim result. Example Sub Main() 'This example takes the current time and extracts the hour. Returns the string with the trailing spaces removed.

The filenumber parameter is a number that is used by the OS to refer to the open file—the number passed to the open statement.Y Next X Y = Seek(1) MbeMessageBox "The current file position is: " + Str$(Y) Close End Sub Seek (statement) Seek [#] filenumber%.X. Sets the position of the file pointer within a given file so that the next read or write operation will occur at the specified position. It is a number between 1 and 7-136 MicroStation BASIC Guide . filenumber is a number that is used by the OS to refer to the open file—the number passed to the open statement.A to Z Reference Descr. The file position ‘is displayed using the Seek Function. position& Descr. Example Sub Main() 'This example opens a file for random write then writes ten 'records into the file using the PUT statement. and the file is closed. Returns the position of the file pointer in a file relative to the beginning of the file. The value returned depends on the mode in which the file was opened: File Mode Input Output Append Random Binary Returns byte position for the next read byte position for the next write byte position for the next write number of the next record to be written or read byte position for the next read or write The value returned is always between 1 and 2147483647 where the first byte (or first record) in the file is 1. The position parameter specifies the location within the file to position the file pointer. Open "Test2.Dat" for random access write as #1 For X% = 1 to 10 Y% = X * 10 Put #1. filenumber should always be between 1 and 2147483647 where the first byte (or first record) in the file is 1.

. position is the byte position within the file.. where the first byte (or record number) in the file is 1.Rec$ MbeMessageBox "The Ninth Record = " + Str$(X) Close End Sub Select. A file can be extended by seeking beyond the end-of-file and writing data there. For Random files. Open "Test2.9 Get #1. Output.. This statement is used to execute a block of BASIC statements depending on the value of a given expression. For files opened in either Binary.Case Select Case testexpression [Case expressionlist [statement_block]] [Case expressionlist [statement_block]] .X. Input or Append modes. position is the record number. Example Sub Main() 'This example opens a file for random write then writes ten 'records into the file using the PUT statement...A to Z Reference 2147483647.Dat" For Random Access Read As #1 Seek #1. [Case Else [statement_block]] End Select Descr. The file is 'then re-opened for read and the ninth record is read using 'the Seek and Get Functions. The Select Case statement uses the following arguments: testexpression Any numeric or string expression MicroStation BASIC Guide 7-137 7 Standard BASIC Reference .Rec$ Next X Close Open "Test2.Dat" For Random Access Write As #1 For X = 1 To 10 Rec$ = “Record #” + Str$(X) Put #1.

. case statement to output the 'current operating system. may be more readable.A to Z Reference statement_block expressionlist Any group of BASIC statements Any of the following: expression [..OS Select Case OpSystem% Case 2 S$ = "Microsoft Windows" Case 3 to 8 S$ = "Unix" Case 10 S$ = "Apple Macintosh" Case 12 S$ = "DOS" Case Else S$ = "Other" End Select MbeMessageBox "This version of BASIC runs on: "+ S$ End Sub 7-138 MicroStation BASIC Guide .expression]. The resultant type of expression must be the same as that of testexpression. OpSystem% = Basic.12. The use of the Select statement. Multiple expression ranges can be used within a single Case clause. expression to expression is relational_operator expression If the testexpression matches any of the expressions contained in expressionlist.Then expression. Is > 40 Only the statement_block associated with the first matching expression will be executed. then the accompanying block of BASIC statements is executed. A Select.... however..End Select expression can also be represented with the If. Example Sub Main() 'This example uses the select . For example: Case 1 To 10..15.

the reserved keyword Nothing is used to make an object variable reference no object. such as destroying the physical object. With application-defined objects. such as destroying the physical object. This syntax is only valid for application-defined objects. At a later time. When an object created using the New keyword goes out of scope (i. The application should respond by creating a new physical object (within the appropriate context) and returning a reference to that object which is immediately assigned to the variable being declared. the object variable is being assigned to a new instance of an existing object type. the MicroStation BASIC Guide 7-139 7 Standard BASIC Reference . the application or extension that defines that object type is notified that a new object is being created and assigned.A to Z Reference Set Set object_var = object_expression Set object_var = New object_type Set object_var = Nothing Descr. The application can choose any appropriate action. but rather copies a reference of an existing object to an object variable. In the third syntax. the application or extension that defines that object type is notified that a reference to an object is being made and destroyed. the Sub or Function in which the variable is declared ends). The Set statement assigns a value to an object variable.e. Set performs additional processing. the following statement informs the application or extension that a reference to object A is lost and a reference to object B is added: Set A = B In this way. When the Set is performed. The object_expression is an expression that evaluates to an object of the same type as the object_var. the application can detect when an object is no longer being referenced and take appropriate action. For example. The first syntax assigns the result of an expression to an object variable. At runtime. This statement does not duplicate the object being assigned.. the application is notified. In the second syntax.

name End Sub SetAttr SetAttr filename$. none Read-only files Hidden files System files Volume label Sub-directories Files that have changed since last backup Files with no attributes The attributes can be combined using the + operator or the bitwise OR operator.doc”) set page = Document.Dat" For Output Access Write As # 1 Close MbeMessageBox "Current Attribute: " + Str$(GetAttr("Test2.ebReadOnly OR ebSystem MbeMessageBox "Attribute set to: " + Str$(GetAttr("Test2. Read-only. attribute% Descr. Example Sub Main() 'This example creates a file and sets it's attributes to ‘Read-Only and System.. Example Sub Main() dim Document as object dim Page as object set Document = GetObject(“c:\resume.ActivePage MbeMessageBox page.Dat")) End Sub 7-140 MicroStation BASIC Guide .Dat".Dat")) SetAttr "Test2.. Open "Test2. The SetAttr command changes the attributes of the specified file to the given attribute.A to Z Reference object variable can be compared to Nothing to test if the object variable has been instantiated. archive. A runtime error results if the file cannot be found. subdir. attribute can contain any combination of the following values: Constant ebNormal ebReadOnly ebHidden ebSystem ebVolume ebDirectory ebArchive ebNone Value 0 1 2 4 8 16 32 64 Includes.

Returns 1 if number is greater than 0. Example Sub Main() 'Displays the Sine of PI/4 radians (45 degrees) C# = Sin(PI / 4) MbeMessageBox "The sine of 45 Degrees is: " + Str$(C) End Sub Sleep Sleep milliseconds& Descr. Returns -1 if number is less than 0. Standard BASIC Reference . A% = -100 B% = 100 C% = A * B Select Case Sgn(C) Case -1 MbeMessageBox "The Product is Negative " + Str$(Sgn(C)) Case 0 MbeMessageBox "The Product is Zero" + Str$(Sgn(C)) Case 1 MbeMessageBox "The Product is Positive" + Str$(Sgn(C)) End Select End Sub Sin Sin#(angle#) angle is given in radians. Example Sub Main() 'This example displays a message for two seconds. MicroStation BASIC Guide 7-141 7 Descr. This statement causes a macro to pause for a specified number of milliseconds. Returns 0 if number is equal to 0.A to Z Reference Sgn Sgn%(number) Descr. Returns the sine of a given angle. Example Sub Main() 'This example tests the product of two numbers and displays 'a message based on the sign of the result. or equal to zero. Returns a value indicating if a number is less than. The number parameter is a numeric expression of any type. greater than.

The formula used to find the SLN of an asset is as follows: (Cost .Salvage Value) / Useful Life Sln requires the following parameters: Parameter Cost Salvage Life Description This is a double-precision number representing the initial cost of the asset.00. Life#) Descr. assuming constant benefit from the asset. 7-142 MicroStation BASIC Guide . Returns a string containing the specified number of spaces.00. Example Sub Main() 'This example calculates the straight line depreciation of an asset 'which cost $10. Dep# = Sln(10000. The SLN of an asset is found by taking an estimate of its useful life in years. The Sln function returns the Straight-Line Depreciation of an asset. This number represents the length of the assets useful life.00 as scrap 'after 10 years of service life. This is a double-precision number representing the estimated value of the asset at the end of its useful life. assigning values to each year. and adding up all the numbers.000."Currency") End Sub Space$ Space$(NumSpaces%) Descr. The unit of time used to express the useful life of the asset is the same unit of time used to express the period for which the depreciation is returned.00 and has a salvage value of $500.A to Z Reference MbeWriteMessage "Waiting 2 seconds" Sleep(2000) MbeWriteMessage End Sub Sln Sln#(Cost#. Salvage#. NumSpaces must be between 0 and 32767.10) MbeMessageBox "The Annual depreciation is: " + Format$(Dep.500.

Example Sub Main() 'This example calculates the square root of the numbers from 1 to 10 'and displays them. The Spc function prints out the specified number of spaces. the file pointer will never advance more than one line.A to Z Reference Example Sub Main() 'This example returns a string of 10 spaces and displays it. number must be greater than or equal to 0. Spc can only be used with the Print and Print# statements. crlf$ = Chr$(13) + Chr$(10) Msg$ = Null For X = 1 To 10 SX# = Sqr(X) MicroStation BASIC Guide 7-143 7 Print "20 Spaces:-->". then the number of spaces is adjusted as follows: numspaces% = numspaces% Mod width% If the resultant number of spaces is greater than width print_position. Ln$ = Space$(10) MbeMessageBox "Value of LN: =>" + LN + "<=" End Sub Spc Spc(numspaces%) Descr. If a line width has been specified (using the Width statement). Example 'Displays 20 spaces between the arrows Sqr Sqr#(number#) Descr. "<--" Standard BASIC Reference . numspaces specifies the number of spaces to be printed. Furthermore. Returns the square root of a given value. with a large value for column% and a small line width.print_position) These calculations have the effect of never allowing the spaces to overflow the line length. It can be any value between 0 and 32767. the number of spaces is recalculated as follows: numspaces% = numspaces% . Spc(20).(width% .

if the result is very small or very large. If number is positive. Example Sub Main() 'The Str$ function is used to display the value of a numeric variable. The result is returned in floating point ‘E’ notation." + Format$(SX.22 MbeMessageBox Str$(X) End Sub 7-144 MicroStation BASIC Guide . X# = 100. Example Sub Main() 'The stop statement can be used for debugging. Here it is used 'to stop execution when Z is randomly set to zero For X = 1 To 10 Z = Random(0. then the returned string will contain a leading minus sign.A to Z Reference Msg = Msg + Format$(X. If a debugger is not present. Doubles are printed using 15-16 significant digits.10) If Z = 0 Then Stop Y = X / Z Next x End Sub Str$ Str$(number%) Str$(number&) Str$(number!) Str$(number#) Descr. then the returned string will contain a leading space. this command will have the same affect as end."Fixed") + " . Suspends execution of the current macro. Singles are printed using only 7 significant digits. returning control to a debugger if one is present. If number is negative."Fixed") + crlf Next x MbeMessageBox Msg End Sub Stop Stop Descr. Returns a string representation of the given number.

A to Z Reference StrComp StrComp%(string1$."True/False") BDi = StrComp(B. then Binary is used (i.e. 'It illustrates that the function compares two strings to the 'length of the shorter string in determining equivalency."True/False") MbeMessageBox Msg End Sub + crlf + crlf + crlf + crlf MicroStation BASIC Guide 7-145 7 Standard BASIC Reference . Msg$ = Null A$ = "This string is UPPER and lower case" B$ = "This string is upper and lower case" C$ = "This string" D$ = "This string is upper and lower case characters" ABc = StrComp(A. string comparison is case sensitive)."True/False") ACi = StrComp(A.1) Msg= Msg + "B and D (sensitive) : " + Format$(BDi."True/False") ABi = StrComp(A. compare%]) Descr.1) Msg= Msg + "A and B (insensitive): " + Format$(ABi. string2$ [.C. then the current Option Compare setting is used.B.0) Msg= Msg + "A and C (sensitive) : " + Format$(ABc.1) Msg= Msg + "A and C (insensitive): " + Format$(ACi. The comparison can be either case sensitive or case insensitive depending on the value of the optional compare parameter: 0 1 case sensitive comparison case insensitive comparison If compare is not specified.. Example Const crlf$ = Chr$(13) + Chr$(10) Sub Main() 'This example compares two strings and displays the results.B. If no Option Compare statement has been encountered.D. Returns an Integer value indicating the result of comparing the two string arguments: 0 1 -1 string1$ = string2$ string1$ > string2$ string1$ < string2$ The StrComp function compares two strings and returns an integer indicating the result of the comparison.

CharCode%) String$(number%.(j) If a subroutine is not to receive a parameter by reference.. To avoid this.)] [statements] End Sub Descr. meaning that any modifications to a passed parameter changes that variable in the caller."=") MbeMessageBox A + crlf + B End Sub Sub.. as in the following example function calls: UserSub 10. If str$ is specified. If CharCode is specified. and then displays the character string ‘underlined with the generated string. Declares a subroutine. A$ = "This string will appear underlined" B$ = String$(Len(A). then the first character of this string is used as the filler character. then the character with this ANSI value will be used as the filler character. simply enclose variable names in parenthesis. Returns a string of length number consisting of a repetition of the specified filler character. str$) Descr.A to Z Reference String$ String$(number%..End Sub Sub name[(parameter [As type].. Parameters are passed to a subroutine by reference. Example Sub Main() 'This example uses the string function to create a line of "=" signs ‘the length of another string. then the optional ByVal keyword can be used: Sub Test ByVal FileName As String [statements] End Sub A subroutine terminates when one of the following statements is encountered: End Sub Exit Sub 7-146 MicroStation BASIC Guide .12.

Life#. Example Sub Main() 'This example uses a subroutine to calculate the area of a circle R! = 10 PrintArea R End Sub Sub PrintArea(R as single) Area! = (R ^ 2) * PI MbeMessageBox "Area of circle with radius"+Str$(R) + " = " + Str$(Area) End Sub SYD SYD#(Cost#.00 is depreciated over 10 years.000.A to Z Reference The name of the subroutine must follow BASIC naming conventions. The formula used to find the SYD of an asset is as follows: (Cost . This function returns the Sum of Years' Digits depreciation of an asset over a specific period of time.00 and the Sum of the years digit ‘depreciation is shown for each year. Example Sub Main() 'An asset which cost $1. It cannot include type declaration characters. ‘The salvage value is $100. then Period must also be expressed in terms of months to receive accurate results. It cannot exceed the life of the asset. This number represents the period that the depreciation is to be calculated for. Period#) Descr. Salvage#. Subroutines can be recursive. If Life is expressed in terms of months. This number represents the length of the assets useful life. Standard BASIC Reference . Life and Period must be expressed in the same units. assigning values to each year. and adding up all the numbers. For X = 1 To 10 MicroStation BASIC Guide 7-147 7 This is a double-precision number representing the initial cost of the asset. The SYD of an asset is found by taking an estimate of its useful life in years.Salvage_Value) * Remaining_Useful_Life / SYD SYD requires the following parameters: Parameter Cost Salvage Life Period Description This is a double-precision number representing the estimated value of the asset at the end of its useful life.

Returns the tangent of an angle. regardless of the length of the data already printed on that line. Print “Column1”. If a line width is specified (using the Width statement). Tab(10). column specifies the desired column position to advance to. “Column3” Print Tab(3). then the column position is adjusted as follows before applying the above two rules: column = column Mod width% Tab is useful for making sure that output begins at a given column position. then the number of spaces is calculated as: column . “1”. then column-1 spaces are printed on the next line. Tab(20).X) Msg$=Msg + "Year"+Str$(X)+" Dep: " + Format$(Dep.10. Tab can only be used with the Print and Print# statements. Tab(14). “Column2”. Example Sub Main() ‘This example prints three column headers and three numbers ‘aligned below the column headers. “3” End Sub Tan Tan#(angle#) Descr.100. angle is given in radians. It can be any value between 0 and 32767 inclusive. 7-148 MicroStation BASIC Guide .A to Z Reference Dep# = SYD(1000. The Tab function prints out the number of spaces necessary to reach a given column position.print_position Rule 2: If the current print position is greater than column.“Currency”)+ Chr$(13) Next x MbeMessageBox Msg End Sub Tab Tab(column%) Descr. “2”. Tab(24). Rule 1: If the current print position is less than or equal to column.

The format of the time string is HH:MM:SS. Time$ returns the system time as an 8 character string. Example This example illustrates use as a function. Sub Main() 'Returns the system time and displays it in a dialog box Ti$ = Time$ Msg$ = "Time was: " + Ti + crlf Time$ = "10:30:54" Msg = Msg + "Time set to: " + Time$ + crlf Time$ = Ti Msg = Msg + "Time restored to: " + Time$ MbeMessageBox Msg End Sub This example illustrates use as a statement. As a function. Time$ sets the system time to the time contained in the specified string. As a statement.A to Z Reference Example Sub Main() 'This example computes tangent of PI/4 radians (45 degrees) C# = Tan(PI / 4) MbeMessageBox "The Tangent of 45 Degrees is: " + Str$(C) End Sub Time$ Time$[()] Time$ = newtime$ Descr. Example Sub Main() 'Displays the elapsed time between execution start and the MicroStation BASIC Guide 7-149 7 Standard BASIC Reference . Returns the number of seconds that have elapsed since midnight. Sub Main() 'Returns the system time and displays it in a dialog box Ti$ = Time$ Msg$ = "Time was: " + Ti + crlf Time$ = "10:30:54" Msg = Msg + "Time set to: " + Time$ + crlf Time$ = Ti Msg = Msg + "Time restored to: " + Time$ MbeMessageBox Msg End Sub Example Timer Timer& Descr. A 24 hour clock is used.

A MbeMessageBox "The elapsed Time was: " + Str$(B) + " seconds" End Sub TimeSerial TimeSerial#(hour%. For example. If a particular time item is missing. A Date of zero is equal to Dec 30.30) T2# = TimeSerial(10. Returns a double-precision number representing the time contained in the specified string argument.A to Z Reference ‘time you clicked the Ok button on the first message A& = Timer MbeMessageBox "Click the Ok button Please" B& = Timer . This function interprets the passed time_string$ parameter looking for a valid time specification. Example Sub Main() 'This example calculates the TimeValue of the current time and 'Displays it in a dialog box. Returns a double-precision number representing the given time with a date of zero. minute%. then the missing time items are set to zero.T2) MbeMessageBox "The Difference is: " + Format$(Tdif. The time_string$ parameter can contain valid time items separated by time separators such as colon ‘:’ or period ‘. Time strings can contain an optional date specification. the string "10 pm" would be interpreted as "22:00:00". but this is not used in the formation of the returned value. "hh:mm:ss") End Sub TimeValue TimeValue#(time_string$) Descr. T1$ = “10:15” T2# = TimeValue(T1$) MbeMessageBox "The Timevalue of " + T1 + " is: " + Str$(T1) End Sub 7-150 MicroStation BASIC Guide . second%) Descr.27) Tdif# = Abs (T1 .’. 1899 Example Sub Main() T1# = TimeSerial(10.22.35.

Within a structure definition appear field descriptions in the format: variable As type MicroStation BASIC Guide 7-151 7 Standard BASIC Reference Descr.A to Z Reference Trim$ Trim$(str$) Descr. and (3) if A is 'equal to -1 (True). (2) if the True constant = -1. The username field specifies the name of the structure that is used later with the Dim statement. Returns the a copy of the passed string expression (str$) with leading and trailing spaces removed. a = True if ((A =True) and (True = -1) and (A = -1)) then MbeMessageBox "A is True" Else MbeMessageBox "A is False" End If End Sub Type Type username variable As type variable As type variable As type : End Type Descr. -1. The Type statement creates a structure definition which can then be used with the Dim statement to declare variables of that type. used in conditionals and boolean expressions . Example const crlf$ = chr$(13) + chr$(10) Sub Main() 'This example uses the Trim$ function to extract the non-blank part 'of a string and display it: Tx$ = " This is Text " Te$ = Trim$(Tx) MbeMessageBox "Orig =>" + Tx + "<=" + crlf + "Trimmed =>" + Te + "<=" End Sub True Example Sub Main() 'This example sets variable a to True and then tests to see if '(1) A is True.

Type can only appear outside of subroutine and function declarations. 9 To 20) UBa = UBound(A) UBb = UBound(B.Cir = Circle. Only fixed arrays can appear within structure definitions.*" count = Ubound(FL) 7-152 MicroStation BASIC Guide .2) MbeMessageBox "Upper Bnd A: " + Str$(UBa) + " Upper Bnd B: " + Str$(UBb) 'This example uses Lbound and Ubound to dimension a dynamic array to 'hold a copy of an array redimmed by the FileList statement.Dia * Circle. 2 2 * Pi Pi the Circle is: " + Str$(Circle. Returns the upper bound of the specified dimension of the specified array variable.Msg End Sub circle and assign values to them.Rad = 5 Circle. The first dimension (1) is assumed if dimension is not specified. Example 'This example displays the use of the Type statement to create a structure 'representing the parts of a Type Circ Msg As String Rad As Integer Dia As Integer Are As Double Cir As Double End Type Sub Main() Dim Circle As Circ Circle. Dim FL$() FileList FL.Rad * Circle. and type is the data type for that variable.A to Z Reference where variable is the name of a field of the structure.Rad ^ Circle.Dia = Circle. Example Sub Main() 'This example dimensions two arrays and displays their upper bounds Dim A(5 To 12) Dim B(2 To 100. Any fundamental data type or previously declared user-defined data type can be used within the structure definition (structures within structures are allowed).Are = Circle."*.Are) UBound UBound%(ArrayVariable() [. dimension%]) Descr.Msg = "The Area of MbeMessageBox Circle.

A to Z Reference Redim NL$(Lbound(FL) To Ubound(FL)) For X = 1 To count NL(X) = FL(X) Next x MbeMessageBox "The last element of the new array is: " + NL(count) End Sub UCase$ UCase$(str$) Descr. start and end parameters are ignored—the entire file is unlocked. the record. Example Sub Main() 'This example uses the UCase$ function to change a string from lower 'to upper case. allowing other processes access to that section of the file. A1$ = "This string was lower case" A2$ = UCase$(A1) MbeMessageBox A2 End Sub UnLock Unlock [#] filenumber% [.{record& | [start&] To end&}] Descr. The Unlock statement unlocks a section of the specified file. MicroStation BASIC Guide 7-153 7 Standard BASIC Reference . Returns the upper case equivalent of the specified string. For sequential files. The filenumber parameter is a number that is used to refer to the open file—the number passed to the open statement. The section of the file is specified using one of the following: Syntax <none> record to end Description unlock the entire file (no record specification is given) unlock the specified record number (for Random files) or byte (for Binary files) unlock from the beginning of the file to the specified record (for Random files) or byte (for Binary files) start to end unlock the specified range of records (for Random files) or bytes (for Binary files) The unlock range must be the same as that used by the Lock statement.

A$ = "This is record number: " B$ = "0" Rec$ = "" Msg$ = "" Open "Test2.Dat" for random access write shared as #1 For x% = 1 To 10 Rec = A + Str$(x) Lock #1.x 'lock it for our use Put #1.1. The number$ parameter can contain any of the following: • Leading minus sign (for non hex or octal numbers only) • Hexadecimal number in the format: &H<hex digits> • Octal number in the format: &O<octal digits> 7-154 MicroStation BASIC Guide .DAT and fills it with 10 string variable 'records.x Msg = Msg + Rec + crlf Next x MbeMessageBox "The Records are: " + crlf + Msg close End Sub Val Val#(number$) Descr. 'rewritten and unlocked.Rec 'nobody's changed it UnLock #1.x Put #1.Rec Unlock #1. These are displayed in a dialog box.A to Z Reference Example const crlf$ = chr$(13) + chr$(10) Sub Main() 'This example creates Test2.x Msg = Msg + Rec + crlf Next x Close MbeMessageBox "The Records are: " + crlf + Msg Msg = "" Open "Test2. modified.x. Converts a given string expression to a number.Dat" For Random Access Read Write Shared As # 1 For x = 1 to 10 Rec = Mid$(Rec. The file is then 'reopened for read/write and each record is Locked.23) + Str$(11-x) Lock #1.. The new records are then displayed in a 'dialog box.

3 ' "&HFFFF" -1 ' "&O77" 63 ' "12. This value is forced to the data type of the assigned variable.345E-02" . If number$ does not contain a number. Example Sub Main() 'This example inputs a number string from an MbeInputBox and converts ‘it to a number variable. monday is 2.12345 Weekday Weekday%(serial#) Descr. which can contain a decimal point and optional exponent Spaces. The Val function continues to read characters from the string up to the first non-numeric character. Returns the day of the week specified by the given date/time serial value. Sunday is 1. Dim A$(7) A(1) = "SUNDAY" A(2) = "MONDAY" A(3) = "TUESDAY" A(4) = "WEDNESDAY" A(5) = "THURSDAY" A(6) = "FRIDAY" A(7) = "SATURDAY" Bd$ = MbeInputBox$("Please Enter Your Birthday") Dt = DateValue(Bd) Dw = WeekDay(Dt) MicroStation BASIC Guide 7-155 7 Standard BASIC Reference . Example Sub Main() 'This example gets a date in an input box and displays 'the day of the week and it's name for the date entered. then 0 is returned.3" 12. tabs and linefeeds are ignored. and so on. Val always returns a double-precision floating point value. A$ = MbeInputBox$("Input a Number String") B# = Val(A) MbeMessageBox "The converted values is: " + Str$(B) End Sub 'The following table shows valid strings and their numeric equivalent: ' "1 2 3" 123 ' "12.A to Z Reference • Floating point number.

which was a " + A(Dw) End Sub While.A to Z Reference MbeMessageBox "You were born on " + Str$(Dw) + ". filenumber is a number that is used to refer to the open file—the number passed to the Open statement. The Width statement specifies the line width for sequential files opened in either Output or Append modes. there is no limit to line length. Repeats a statement or group of statements while a condition is TRUE. When a file is initially opened. If newwidth is zero. newwidth can be any integer from 0 to 255 inclusive. 7-156 MicroStation BASIC Guide . then the data is written on the next line. This command forces all subsequent output to the specified file to use the specified value as the maximum line length.Wend While condition [statements] Wend Descr. Example Sub Main() 'This example executes a While loop until the random number 'generator returns a value of 1 X% = 0 Count% = 0 While X <> 1 And Count < 500 X = Rnd(1) Count = Count + 1 Wend MbeMessageBox "The loop executed " + Str$(count) + " times. Width affects output in the following manner: if the column position is greater than 1 and the length of the text to be written to the file causes the column position to exceed the current line width." End Sub Width# Width #filenumber%.. no maximum line length is used. newwidth% Descr. Width also affects output of the Print command when used with Tab and Spc functions..

If first is greater than the number of words in text$. then only that word is returned. then all words between first and last will be returned. end-of-lines and punctuation. Stuart is my surname. Words are separated by spaces." C$ = Word$(A. The first parameter specifies the first word in the sequence to return.A to Z Reference Example Sub Main() 'See Print statement 'This statement sets the maximum line width for file number 1 to 80 'columns Width #1.80 End Sub Word$ Word$(text$. first%[. including all spaces. Words are separated by any non-alphanumeric characters such as spaces. Returns the number of words in the specified text. tabs and end-of-lines. Returns a single word or sequence of words between first and last.5. This function extracts words from a text source. last%]) Descr. then an empty string is returned. If last is greater than the number of words in text$.6) MbeMessageBox "The extracted name is: " + C End Sub WordCount WordCount%(text$) Descr. If last is specified. then all words from first to the end of text are returned. Example Sub Main() 'This example counts the number of words in a particular string A$ = "My last name is Williams. If last is not specified. Example Sub Main() 'This example extracts two words from the string. A$ = "My last name is Williams." MicroStation BASIC Guide 7-157 7 Standard BASIC Reference . tabs and end-of-lines that occur between those words. Stuart is my surname. tabs.

Y Next X Close Pstr$ = "" Open "Test2.A%. Write can only be used with files opened in Output or Append modes. Example const crlf$ = chr$(13) + chr$(10) Sub Main() 'This example opens a file for sequential write then writes ten 'records into the file with the values 10. Strings are output enclosed within quotation marks. expressionlist] Descr. Write outputs data items separated with commas.D! = WordCount(A) MbeMessageBox "The String has " + Str$(D) + " words" End Sub Write # Write [#]filenumber% [. Then the file 'is closed and re-opened for read and the records read with the 'Input statement.X.100. After writing each expression in the list. Write outputs an end-of-line. filenumber is a number that is used to refer to the open file—the number passed to the Open statement. The results are displayed in a dialog box.B% Pstr = Pstr + "Record " + Str$(A) + ": " + Str$(B) + crlf Next Y MbeMessageBox Pstr Close End Sub Xor expression1 Xor expression2 7-158 MicroStation BASIC Guide .. Open "Test2. The file referenced by filenumber must be opened in either Output or Append mode. This statement writes a list of expressions to a given sequential file.Dat" for input access read as #1 For Y = 1 To 5 Input #1.Dat" For Output Access Write As #1 For X% = 1 To 10 Y% = X * 10 Write #1.

Returns the year of the date encoded in the specified serial parameter. If both operands are numeric. Msg$ = Null For X = True To False For Y = True To False Z = X Xor Y Msg = Msg + Format$(X."True/False") + " " + _ Format$(Y. For numeric operands."True/False") + crlf Next y Next x MbeMessageBox Msg End Sub Year Year%(serial#) Descr. If both operands are relational."True/False") + " " + Format$(Z. both operands are first converted to Longs. then Xor returns the logical exclusive Or of expression1 and expression2. bitwise Xor works as follows: Bit in expression1 1 0 1 0 Bit in expression2 1 1 0 0 Bit in result 0 1 1 0 Example Const crlf = Chr$(13) + Chr$(10) Sub Main() 'This example builds a logic table for the XOR function & displays it. If either of the operands is a floating point number.A to Z Reference Descr. Xor returns True only if both operands are not equal. The value returned is (100 <= serial <= 9999) inclusive. Example Sub Main() 'This example returns the current Year in a dialog box. then a bitwise Xor is performed. In other words. Tdate$ = Date$ TDay! = Year(DateValue(Tdate)) MbeMessageBox "The current Year is: " + Str$(TDay) End Sub MicroStation BASIC Guide 7-159 7 Standard BASIC Reference . the result is the bitwise Xor of the arguments.

A to Z Reference 7-160 MicroStation BASIC Guide .

• State Object (see page 8-2) • Element Object (see page 8-15) • Element Set Objects (see page 8-62) • Settings Object (see page 8-66) • Design File Information Objects (see page 8-87) • Current Transformation Object (see page 8-93) • View Objects (see page 8-99) • Reference File Objects (see page 8-108) • Session Object (see page 8-116) • C Expression Statements (see page 8-120) • CAD Input Operations (see page 8-123) • Dialog Box Statements (see page 8-145) • MbeSqlda Object (see page 8-149) • MbeTable Object (see page 8-152) • MbeDatabase Object (see page 8-160) • MbeDatabaseLink Object (see page 8-168) • MbeDgnLevels Object (see page 8-172) • MbeLevelGroup Object (see page 8-177) • MbeNamedLevel Object (see page 8-181) • Tag BASIC Extensions (see page 8-183) • MbeTagSet Object (see page 8-185) • MbeTagDef Object (see page 8-190) • MbeTag Object (see page 8-196) • MbeMacro Object (see page 8-202) • Topology Objects (page 8-202) (GeoGraphics only) • GbeTLayerPoint Object (page 8-205) (GeoGraphics only) • GbeTLayerLine Object (page 8-207) (GeoGraphics only) MicroStation BASIC Guide 8-1 .8 MicroStation Extensions to BASIC "extensio.pdf" The keywords documented here are MicroStation-specific extensions to the standard BASIC language.

MbeState.getInputKeyin (page 8-4) MbeState.) submitted by the macro. Access the results of the last MicroStation measure command. Get the command string entered by the user. MbeState. Set the location tolerance that MicroStation uses. Get the key-in string entered by the user.locateFileNum (page 8-9) MbeState.setLocateFileMask.setLocateTypeMask.getLocateTypeMask (page 8-11) Used to Returns information about the type of input that the user entered.locateComponentFilePos (page 8-10) MbeState. reset. Set/determine which graphic element types are eligible for element location logic during command execution or fence processing by a macro.measureResult1. Get the file number of an element that has been located by the user.messages (page 8-6) MbeState. Get the result of input (data point. etc.errorMessages. Enable or disable error/status messages that MicroStation displays to the user.State Object • GbeTLayerPolygon Object (page 8-209) (GeoGraphics only) • GbeTLayerMixed Object (page 8-212) (GeoGraphics only) • Category Object (page 8-214) (GeoGraphics only) • Feature Object (page 8-218) (GeoGraphics only) • Map Object (page 8-222) (GeoGraphics only) • Project Object (page 8-226) (GeoGraphics only) State Object Properties and Methods MbeState.measureResult2 (page 8-7) MbeState.getInputCommand (page 8-3) MbeState.noElementDisplay (page 8-6) MbeState. MbeState.getLocateFileMask (page 8-10) MbeState. Get the file position of the complex header of the element that has been located by the user.locateTolerance (page 8-8) MbeState. 8-2 MicroStation BASIC Guide . Get the coordinates and view of a data point entered by the user. MbeState. Set/determine which files are eligible for element location logic during command execution or fence processing by a macro.parseAll (page 8-7) MbeState. Get the file position of the component of the complex element nearest the data point used to locate an element. Tell MicroStation to parse or not parse all user key-ins for commands. Temporarily disable the display of graphics elements in views.getInputDataPoint (page 8-4) MbeState.locateHeaderFilePos (page 8-10) MbeState.inputType (page 8-3) MbeState.cmdResult (page 8-5) MbeState.

. Once the input type is known.. MBE_CommandInput If MbeState. Limit elements eligible for user location and fence processing based on their class.getInputCommand (cmdString$) = MBE_Success Then ' Process Command here MicroStation BASIC Guide 8-3 8 MicroStation Extensions to BASIC Example MbeGetInput MBE_DataPointInput. Otherwise. the function returns MBE_Success. MbeState.getInputCommand is valid. MBE_ResetInput . and only when MbeState. and is valid only after a call to MbeGetInput.getInputCommand.getInputDataPoint.getInputCommand status = MbeState.getInputCommand only after calling MbeGetInput.inputType = MBE_CommandInput Then If MbeState. MbeGetInput MBE_DataPointInput.locatePropMask. Its value will be one of the predefined constants MBE_CommandInput. it returns MBE_WrongInputType (1101) and commandString is set to an empty string.getInputDataPoint or MbeState.locateClassMask (page 8-14) Used to Limit elements eligible for user location and fence processing based on their properties. The MbeState.getInputCommand(commandString as String) Descr.getInputCommand object function sets the commandString argument to the command string entered by the user. MbeState. the macro can use one of the MbeState methods that return the user input details: MbeState. The MbeState.State Object Properties and Methods MbeState.inputType Descr. MbeState. MbeState. MbeState.inputType MbeState.inputType is a read-only property. It is typically used in an If statement or Select statement to control program flow based on input type.getInputKeyin. MbeState.inputType equals MBE_CommandInput. If MbeState.getInputCommand. Returns If the call to MbeState.inputType property returns information about the type of input that the user entered.inputType = MBE_DataPointInput Then ' Process data point here Else ' Process reset here End If See also MbeGetInput. It is valid to call MbeState. MbeState. MBE_DataPointInput. MBE_ResetInput or MBE_KeyinInput.locatePropVal (page 8-13) MbeState. Example Dim cmdString$ as String .getInputKeyin. MbeState.

MbeGetInput MBE_DataPointInput.getInputKeyin(keyinString as String) Descr. However. 8-4 MicroStation BASIC Guide . Returns If the call to MbeState.getInputDataPoint object function sets the dataPoint argument to the coordinates entered by the user and the optional view argument to the view in which the data point was entered. It is valid to call MbeState. it returns MBE_WrongInputType (1101) and the dataPoint and view arguments are set to 0.inputType equals MBE_DataPointInput. the function returns MBE_Success.getInputKeyin is valid.State Object End If Else ' Process data point here End If See also MbeGetInput. MBE_CommandInput If MbeState. Otherwise it returns MBE_WrongInputType (1101) and keyinString is set to an empty string. The actual value of the screenPoint is of limited use. the function returns MBE_Success. Returns If the call to MbeState. view as _ Integer [. and only when MbeState. MbeState. The MbeState.getInputDataPoint(dataPoint as MbePoint [. on comparing screenPoint from two different data points entered in the same view shows if the user has moved the input pointer significantly. The optional screenPoint argument is set to the position of the data point in screen coordinates. screenPoint as MbePoint]]) Descr.getInputDataPoint status = MbeState.. Otherwise.inputType. MbeState..getInputKeyin status = MbeState.getInputDataPoint(dataPoint. and only when MbeState. MbeState. It is valid to call MbeState.getInputKeyin only after calling MbeGetInput. The MbeState. MbeState.getInputDataPoint only after calling MbeGetInput.inputType equals MBE_KeyinInput. view) = MBE_Success Then ' Process Data point here End If Else ' Process command here End If See also MbeGetInput. Example Dim dataPoint as MbePoint Dim view as Integer .inputType = MBE_DataPointInput Then If MbeState.getInputKeyin object function sets keyinString to the string entered by the user.inputType.getInputDataPoint is valid.

cmdResult MbeState. the MbeState.inputType = MBE_KeyinInput Then If MbeState. prompting “Accept/Reject” Command not recognized 2D file. 3D command Could not find reference file Named view could not be found Data point resulted in illegal element def. MbeSendKeyin.cmdResult Integer property can be checked to determine the result of the input. MbeSendCommand. MbeState.cmdResult and their meanings are: MBE_Success MBE_ElementNotFound MBE_AcceptQuery MBE_UnknownCommand MBE_3Donly MBE_RefFileNotFound MBE_ViewNotFound MBE_IllegalDefinition MBE_OffDesignPlane MBE_NeedChars MBE_CellLibNotFound MBE_NoCellLibrary MBE_NoOrigin MBE_NoFenceActive MBE_EmptyFence MBE_BadCellName MBE_CellExists MBE_CellNotFound MBE_NoActiveCell MBE_3DLib2DFile successful processing tried to locate element. MbeSendLastInput. MbeSendReset..cmdResult can be reliably checked only immediately following a call to one of the previously mentioned subroutines.cmdResult Common values of MbeState.inputType. Note that MbeState. MbeGetInput MBE_DataPointInput. Data point put element off design plane Text data point before entering string No cell library attached No cell origin defined when creating cell Operation requires a fence. .State Object Example Dim keyinString$ as String .getInputKeyin(keyinString$) = MBE_Success Then ' Process Keyin here End If Else ' Process data point here End If See also MbeGetInput.. MbeRelocate or MbeLocateElement. MBE_KeyinInput If MbeState. Upon return from a call to MbeSendDataPoint. but couldn’t element found. none active No elements found within fence Invalid cell name when creating cell Cell already in library on creating cell Cell not found Attempt to place cell with no active cell Attempt to create 3D cell in 2D library Could not find cell library MicroStation BASIC Guide 8-5 8 MicroStation Extensions to BASIC Descr. MbeState.

messages Descr.messages = 0 . To turn off element 8-6 MicroStation BASIC Guide .noElementDisplay read/write Integer property is used to temporarily disable the display of graphics elements to MicroStation views. a macro will want to display its own messages in place of the usual MicroStation messages. MbeSendReset.messages MbeState.. it is wise to save the settings of these two properties before setting them and to restore them to their previous values as part of the exit code for a macro.messages MbeState.State Object MBE_CellDeleted MBE_CellNestError MBE_FileReadOnly MBE_InvalidRefOp Cell successfully deleted Cell nesting error (nests itself) Tried to write to read-only design file Invalid reference file operation Example Dim point as MbePoint .errorMessages and MbeState. set MbeState. MbeState.messages is permanent until it is changed by the macro (or another macro).messages = saveMsgs MbeState..errorMessages to zero. The MbeState. MbeLocateElement. The effect of setting MbeState.errorMessages = 0 MbeState. Thus. Often. (process here) End If See also MbeSendDataPoint.messages read/write Integer properties are used to enable and disable the messages that display to the user.noElementDisplay Descr. To turn off all messages except error messages. Any nonzero value enables MicroStation’s messages..errorMessages = saveErrMsgs MbeState.. MbeSendCommand. MbeState.errorMessages MbeState. The MbeState.errorMessages.errorMessages and MbeState. To turn off error messages. MbeSendInputDataPoint point If MbeState. MbeRelocate.errorMessages saveMsgs = MbeState. MbeSendKeyin.cmdResult = MBE_AcceptQuery Then ' element found by MicroStation . set MbeState.noElementDisplay MbeState.. Example saveErrMsgs = MbeState. and thus the MicroStation messages must be suppressed. MbeState.messages to zero..

Example MbeState. Thus it is wise to save the setting of the property before setting it and to restore it to its previous value as part of the exit code for a macro.measureResult1 MbeState.noElementDisplay = 0 MbeState. .noElementDisplay to zero. MbeState. To turn element display back on. The MbeState.noElementDisplay is permanent until it is changed by the macro. For example.noElementDisplay = 1 . The effect of setting MbeState..noElementDisplay to any nonzero value. set MbeState.measureResult2 Descr.parseAll MbeState. The MbeState. set MbeState.parseAll = 0 .parseAll = saveParseAll MbeState.parseAll is permanent until it is changed by another macro.parseAll Descr.measureResult2 read-only properties are of type Double and are used to access the results of the last MicroStation measure command. MbeState..measureResult2 MbeState.measureResult1 and MbeState.parseAll is nonzero. if MbeState. and it is recommended that it not be used..parseAll MbeState.State Object display. The effect of setting MbeState.. MicroStation parses all key-ins for commands even when it is prompting the user to enter text for the place text command. it should be used with caution and always set back to zero as part the exit code for a macro. They are used when a macro sequences one of the measure commands and MicroStation BASIC Guide 8-7 8 MicroStation Extensions to BASIC Because there are separate BASIC extension statements for sending MicroStation commands and key-ins. this property is rarely needed by a macro. Since turning off element display affect MicroStation operation quite dramatically.measureResult1. Example saveParseAll = MbeState. ' do whatever operations are needed without element display MbeState.parseAll read/write Integer property is used to direct MicroStation to try to parse user key-ins regardless of MicroStation state.

The MbeState.scalarFromUors MbeState. The location tolerance is the diameter. and can generally be prevented by setting MbeState. this means that two points may be “close enough” when looking at a zoomed out view.State Object needs access to the result. Example Dim area as Double Dim perimeter as Double . The following table shows the values placed in these two properties by MicroStation and the units of the values. if desired..locateTolerance Descr.locateTolerance MbeState. Since the location tolerance is based on screen coordinates. ' sequence the measure area command area = MbeState. Command Measure Angle Measure Area Element Measure Distance Measure Length Measure Radius Measure Volume measureResult1 measureResult2 Angle Degrees Area Square Master Units Distance Units of Resolution Length Master Units Primary Radius Master Units Volume Cubic Master Units not used Perimeter Master Units not used not used Secondary Radius Master Units Surface Area Square Master Units The MbeCurrentTransform.locateTolerance temporarily to zero and then setting it back to its original value when the operation is over. The problems surface in a zoomed out view. which assume the user meant to close a shape when the input point is “close enough” to the starting point. 8-8 MicroStation BASIC Guide .. of a circle surrounding the screen pointer location. in screen pixels.measureResult2 MbeCurrentTransform.locateTolerance read/write Integer object property is used to set the “location tolerance” that MicroStation uses. When a MicroStation command asks the user to locate an element.measureResult1 perimeter = MbeState. The location tolerance is also used to determine when two points are “close enough” to be considered the same for MicroStation. an element that has any part drawn inside the location tolerance circle is considered for location. Occasionally this causes problems for macros that sequence commands like PLACE SHAPE. but not “close enough” when looking at a magnified view.scalarFromUors object function can be used to transform the Measure Distance result to the macro units.

locateHeaderFilePos properties because it sets the current position in the element to the proper component element. Example Sub drawOutline (origin as MbePoint.locateHeaderFilePos. view) point. totalHeight as Double) Dim point as MbePoint Dim saveTolerance as Integer saveTolerance = MbeState.fromFile(MbeState. _ totalWidth as Double. Example Dim element as New MbeElement ..totalHeight Call MbeSendDataPoint(point. Thus it is wise to save the settings of the property before setting it and restore it to its previous value as part of the exit code for a macro. and file position of the component of the complex element that was nearest the data point used to locate the element.locateFileNum Descr. If the MbeStartLocate function is used.State Object The effect of setting MbeState. MicroStation BASIC Guide 8-9 8 MicroStation Extensions to BASIC . locateHeaderFilePos and locateComponentFilePos will be identical.x + totalWidth Call MbeSendDataPoint(point.locateFileNum and MbeState. the MbeElement. view) point.y = origin.x Call MbeSendDataPoint(point. locateHeaderFilePos and locateComponentFilePos can be used to retrieve the file that the located element is in.locateTolerance MbeState. view as Integer. _ MbeState.locateTolerance = 0 point = origin Call MbeSendCommand("PLACE SHAPE") Call MbeSendDataPoint(origin.locateTolerance is permanent until it is changed by the macro (or another macro). If the selected element is not complex.x = origin. view) point. the file position of the complex header. view) point.locateFileNum) See also MbeElement.locateFileNum MbeState.y .locateTolerance = saveTolerance End Sub MbeState.y = origin. the read-only properties locateFileNum. When an element has been located by the user (either as part of a command sequence or as a result of using the MbeStartLocate function in a Macro).y Call MbeSendDataPoint(point.fromLocate.. MbeState.fromLocate is a better way to retrieve the element located than using MbeElement. stat = element.x = origin. MbeStartLocate. view) MbeState.locateFileNum is of type Integer.fromFile with the MbeState.

locateHeaderFilePos MbeState. Example Dim element as New MbeElement ..locateFileNum) See also MbeElement..fromLocate is a better way to retrieve the element located than using MbeElement.MbeState.setLocateFileMask() stat = MbeState. the file position of the complex header. locateHeaderFilePos and locateComponentFilePos will be identical. the MbeElement. MbeState. the MbeElement. the read-only properties locateFileNum.locateFileNum and MbeState. When an element has been located by the user (either as part of a command sequence or as a result of using the MbeStartLocate function in a Macro).getLocateFileMask stat = MbeState. If the MbeStartLocate function is used. locateHeaderFilePos and locateComponentFilePos can be used to retrieve the file that the located element is in. _ MbeState.locateHeaderFilePos properties because it sets the current position in the element to the proper component element.locateHeaderFilePos. the read-only properties locateFileNum.locateComponentFilePos.fromFile with the MbeState. and file position of the component of the complex element that was nearest the data point used to locate the element..fromLocate.getLocateFileMask(fileArray() as Long) 8-10 MicroStation BASIC Guide . MbeStartLocate. locateHeaderFilePos and locateComponentFilePos will be identical. If the selected element is not complex.fromLocate.locateComponentFilePos Descr. locateHeaderFilePos and locateComponentFilePos can be used to retrieve the file that the located element is in. and file position of the component of the complex element that was nearest the data point used to locate the element.setLocateFileMask(fileArray() as Long) stat = MbeState. MbeStartLocate.setLocateFileMask. Example Dim element as New MbeElement .fromFile with the MbeState. stat=element.locateFileNum) See also MbeElement.State Object MbeState. MbeState.fromFile(MbeState.locateFileNum and MbeState. the file position of the complex header. If the selected element is not complex. MbeState. If the MbeStartLocate function is used.locateHeaderFilePos properties because it sets the current position in the element to the proper component element. stat=element.locateHeaderFilePos Descr.fromFile(MbeState.fromLocate is a better way to retrieve the element located than using MbeElement.locateComponentFilePos MbeState.. When an element has been located by the user (either as part of a command sequence or as a result of using the MbeStartLocate function in a Macro).

and the files searched for elements is left up to MicroStation.setLocateTypeMask.. Returns Both functions return MBE_Success if successful or MBE_WrongDimension (801) if fileArray is dimensioned incorrectly.getLocateTypeMask(typeArray() as Integer) MicroStation BASIC Guide 8-11 8 MicroStation Extensions to BASIC . The setLocateFileMask takes one optional argument that specifies. If you are using Option Base 0 (the default) the correct Dim statement is: Dim fileArray(7) as Long If you are using Option Base 1. every element of the fileArray retrieved by getLocateFileMask will be 0. MbeState. MbeState.State Object Descr.setLocateFileMask(fileArray) . If the fileArray argument is left off. Rotate Element) or use a fence. The low-order bit of the first array element is for the master file. When a macro sequences commands that either select an element (e. If it is included.g. one bit for each file.getLocateFileMask(fileArray) fileArray(1) = fileArray(1) Or 256 stat = MbeState.locateClassMask. The low-order bit of the second array element is for reference file 32.setLocateFileMask() ' clear locate mask See also MbeState. and so on. stat = MbeState.setLocateTypeMask(typeArray() as Integer) stat = MbeState. then the correct Dim statement is: Dim fileArray(8) as Long In either case you could be more specific: Dim fileArray(1 to 8) as Long The getLocateFileMask object function retrieves the file mask set by setLocateFileMask. any previous setting of the locate file mask is cleared. Example Dim fileArray(1 to 8) as Long fileArray(1) = 255 ' select from master file and first 7 reference files stat = MbeState. MbeState. in the form of an array of 8 Longs. and does not affect MicroStation operation after the macro exits. the macro can specify which MicroStation files are eligible by setting a file mask using the setLocateFileMask object function.getLocateTypeMask stat = MbeState.setLocateTypeMask() stat = MbeState.. MbeState.. the next-lowest bit in the first array element is for the first reference file.setLocateFileMask(fileArray) stat = MbeState. etc. fileArray must be an array of Longs with 8 elements.locatePropMask. If setLocateFileMask is not called or is called without its optional argument.locatePropVal. MbeState.setLocateTypeMask. MbeState.getLocateTypeMask. The file mask set using setLocateFileMask takes effect only for data points sent by the macro.

State Object Descr. MBE_Text ' select text 8-12 MicroStation BASIC Guide . the Macro can specify which MicroStation graphic element types are eligible by setting a type mask using the setLocateTypeMask object function. and does not affect MicroStation operation after the macro exits.g. and the types eligible for selection is left up to MicroStation. Both functions return MBE_Success if successful. one bit for each graphics element type.. Example Dim typeArray(1 to 8) as Integer setElemTypeBit typeArray. and so on. elemType as Integer) dim bitNum as Integer dim index as Integer bitNum = (elemType-1) Mod 16 index = LBound(typeArray) + (elemType-1) \ 16 If bitNum = 15 Then typeArray(index) = typeArray(index) Or -32768 Else typeArray(index) = typeArray(index) Or 2 ^ bitNum End If End Sub The getLocateTypeMask object function retrieves the type mask set by setLocateTypeMask.type on page 8-29. The setLocateTypeMask takes one optional argument that specifies. The low-order bit of the first array element is for element type 1. etc. The correct bit for a particular element can be set in BASIC using the following subroutine: Example Sub setElemTypeBit(typeArray() as Integer. If typeArray is left off. Rotate Element) or use a fence. typeArray must be an array of Integer with 8 elements. The low-order bit of the second array element is for element type 17. or MBE_WrongDimension if typeArray is dimensioned incorrectly. If you are using Option Base 0 (the default) the correct Dim statement is: Dim typeArray(7)as Integer If you are using Option Base 1. every element of the typeArray retrieved by getLocateTypeMask will be 0. The element type mask set using setLocateTypeMask takes effect only for data points sent by the macro. then the correct Dim statement is: Dim typeArray(8) as Integer In either case you could be more specific: Dim typeArray(1 to 8) as Integer The element type numbers are listed in the reference material for the MbeElement. in the form of an array of 8 Integers. If setLocateTypeMask is not called or is called without its optional argument. the next-lowest bit in the first array element is element type 2. When a Macro is sequencing commands that either select an element (e. any previous setting of the locate type mask is cleared.

properties object property.locatePropVal MbeState. To indicate that the value of a particular property should be used to determine locate eligibility. MbeState. to locate only unlocked elements (without caring about the state of other properties bits). MbeState.locateClassMask.setLocateFileMask. MicroStation BASIC Guide 8-13 8 MicroStation Extensions to BASIC Descr. the following BASIC statements are used: MbeState. MBE_TextNode setElemTypeBit typeArray. hole or solid status. MbeState. the corresponding bit in the MbeState.getLocateTypeMask.locatePropVal Integer properties are used together to limit the element eligible for user location and fence processing based on the element properties. MbeState. To select only elements with user attributes present.setLocateTypeMask(typeArray) . See also MbeState.getLocateFileMask. modified status.locatePropVal The element properties are a group of bits in the element header that indicate locked status. The bit name and meaning are summarized in the reference section for the MbeElement.locatePropMask = MBE_AttributeProperty MbeState.State Object setElemTypeBit typeArray.setLocateTypeMask(typeArray) stat = MbeState.locatePropVal is set to the desired value. MbeState.locatePropMask and MbeState. MBE_CellHeader stat = MbeState. and snappable.. The properties mask and value set using these object properties takes effect only for data points sent by the macro. attributes present.getLocateFileMask. the following BASIC statements are used: MbeState.locatePropMask.. MbeState.locateClassMask. MbeState.getLocateTypeMask.getLocateTypeMask(typeArray) setElemTypeBit typeArray.setLocateTypeMask. and the corresponding bit in MbeState. MbeState. . stat = MbeState. MbeState. MBE_Shape ' add shape elements stat = MbeState.locatePropMask MbeState. planar. The MbeState. MbeState. For example.setLocateFileMask.locatePropVal = MBE_AttributeProperty Combinations of property bits can be set by Oring different properties bits into locatePropMask and locatePropVal. new status. view independent.setLocateTypeMask() ' clear locate type mask ' select text nodes ' select cells See also MbeState. and does not affect MicroStation operation after the macro exits.locatePropVal = 0 ' "locked" property relevant ' want it to be zero.setLocateTypeMask.locatePropMask = MBE_LockedProperty MbeState.locatePropMask is set.

setLocateTypeMask.State Object MbeState.locateClassMask Or 2 ^ (classNum-1) MbeState. and does not affect MicroStation operation after the macro exits. MicroStation allows selection of elements in the primary class. 8-14 MicroStation BASIC Guide . If the MbeState.locatePropVal.locateClassMask = MbeState. then the selection of eligible classes is left to MicroStation.locateClassMask Or 2 ^(MBE_DimClass-1) See also MbeState. Regardless of whether the “primary” class bit is set or not. MbeState. The MbeState. The class mask set using this object property takes effect only for data points sent by the macro. the corresponding bit in the MbeState.locateClassMask MbeState. MbeState. MbeState.locateClassMask property is never assigned by a macro.locateClassMask Descr.locateClassMask = MbeState.locateClassMask is set.setLocateFileMask.locateClassMask Integer property is used to limit the element eligible for user location and fence processing based on the element class.locatePropMask. MbeState.class object property. The bit in the mask for a class is set using the BASIC statement: Example MbeState.getLocateTypeMask.getLocateFileMask. MbeState. Each graphics element has a class value associated with it. The element classes are summarized in the reference section for the MbeElement. To indicate that a particular class of elements is eligible for location and fence operations.

charHeight. Set complex element position to the first element. or tag element at the current position. Control the scope of changes made to the MbeElement’s properties. Get the size of the entire MbeElement as it exists in the file. text node.area (page 8-46) MbeElement. Extract database attributes to MbeDatabaseLink array Return the file number from which the MbeElement originated.extractDBLinkages (page 8-20) MbeElement. Test whether element has database attributes.filePos (page 8-33) MbeElement. Return the file position of the element at the current position.attachActiveEntity (page 8-18) MbeElement.foundDBLinkages (page 8-19) MbeElement.componentFilePos (page 8-33) MbeElement.cellName (page 8-47) MbeElement. Read an element from a master or reference file. Display the MbeElement in one or more views.class (page 8-36) MbeElement. MbeElement. Get the character (height/width) of the text. Attach active entity to the element. Append database linkage to the element.charWidth (page 8-50) MbeElement.Element Object Element Object Properties and Methods MbeElement. MicroStation BASIC Guide 8-15 8 MicroStation Extensions to BASIC Set the class of an element in the MbeElement or retrieve the class from the element at the current position.display (page 8-45) MbeElement.appendDBLinkage (page 8-21) MbeElement.changeAll (page 8-34) MbeElement.font (page 8-49) MbeElement. .fontName (page 8-49) MbeElement.color (page 8-35) MbeElement.addToFile (page 8-45) MbeElement. Read the last element located by a user (or a macro calling MbeStartLocate). Get the area of the element at the current position.fileSize (page 8-30) MbeElement. Get or set the font (by name) of one or all component text.fileNum (page 8-33) MbeElement.fromFile (page 8-31) MbeElement. Set the color of an element in the MbeElement or retrieve the color from the element at the current position.deleteDBLinkage (page 8-21) MbeElement.firstElement (page 8-22) MbeElement.fromLocate (page 8-32) Used to Add the MbeElement to the end of the master file. text node or tag elements in the MbeElement. Delete linkage specified in MbeDatabaseLink object. Get the name of the cell in the cell header at the current position. Get or set the font (by number) of one or all component text. Return the file position from which the MbeElement originated. text node or tag elements in the MbeElement.

Determine if the element at the current position is a component of a complex element. Get the character width and height of the text node element at the current position. Determine if the element at the current position is a complex header. Get the rotation matrix for the element at the current position. Set the level of an element in the MbeElement or retrieve the level from the element at the current position. Load displayable attribute text node.group (page 8-57) MbeElement. Get the justification of the text. Set complex element position to the next element at the previous nest level.getRotation (page 8-49) MbeElement.getCellBox (page 8-48) MbeElement.move (page 8-42) MbeElement. Get the size of the element at the current position as it exists in memory. Get the centroid of the element at the current position.getString (page 8-52) MbeElement. Get the start and end points of the graphics element at the current position.getCellLevels (page 8-48) MbeElement.getCentroid (page 8-47) MbeElement. 8-16 MicroStation BASIC Guide . Set element position to the next component under the current complex header.Element Object Properties and Methods MbeElement.getEndPoints (page 8-41) MbeElement.isComponent (page 8-29) MbeElement.isHeader (page 8-28) MbeElement.loadDAttributes (page 8-19) MbeElement. Determine if the element at the current position is a graphics element.justification (page 8-51) MbeElement.isGraphics (page 8-29) MbeElement.headerElement (page 8-26) MbeElement.internalSize (page 8-30) MbeElement. Get an array of points that comprise the graphics element at the current position. Resets the current position to the header of the element at the current position.lineSpacing (page 8-51) MbeElement.getTopOrigin (page 8-55) MbeElement.getOrigin (page 8-38) MbeElement.level (page 8-34) MbeElement. Get the center of the top circle of the cone element at the current position.nextComponent (page 8-24) MbeElement. Get the origin of the graphics element at the current position.nextElement (page 8-22) Used to Get the eight points that comprise the range box associated with the cell at the current position. Get the range of the element at the current position. Set or retrieve the graphic group of the MbeElement.getPoints (page 8-39) MbeElement. text node or tag element at the current position.getRange (page 8-41) MbeElement. Set the text string for the text element at the current position. Offset the coordinates of one or all elements in the MbeElement. Determine the levels occupied by the cell at the current position.

startAngle (page 8-54) MbeElement.weight (page 8-36) MbeElement. Rotate one or all elements in the MbeElement. Decide whether the element has any tag attached. MbeElement.primaryAxis (page 8-53) MbeElement. Get the volume of the element at the current position.reportDBLinkages (page 8-19) MbeElement. Set or retrieve the properties bit flags of the component element at the current position.tagId (page 8-57) MbeElement. Get or set the secondary axis of the arc or ellipse element at the current position.numTags (page 8-58) MbeElement.setPoints (page 8-40) MbeElement. Set the points that make up the linear element at the current position.style (page 8-35) Used to Get the perimeter of the element at the current position. Get or set the sweep angle of the arc element at the current position.bottomRadius (page 8-55) MbeElement. Review database attributes of the element.type (page 8-29) MbeElement. Publish the MbeElement for manipulation by C expression functions (rarely used).properties (page 8-37) MbeElement. Get the (top/bottom) radius of the cone element at the current position.reviewDBAttributes (page 8-18) MbeElement.volume (page 8-47) MbeElement. Get the association ID of the element. Get the type of the element at the current position.setString (page 8-53) MbeElement.topRadius.isTagged (page 8-57) MbeElement.secondaryAxis (page 8-54) MbeElement. MbeElement.scale (page 8-43) MbeElement.perimeter (page 8-46) MbeElement.thisComponent (page 8-27) MbeElement. Scale one or all elements in the MbeElement.publish (page 8-56) MbeElement.Element Object Properties and Methods MbeElement. Get the array of tags attached to the element.sweepAngle (page 8-55) MbeElement.extractTags (page 8-58) MicroStation BASIC Guide 8-17 8 MicroStation Extensions to BASIC . Set the text string for the text element at the current position. Set the line style of an element in the MbeElement or retrieve the line style from the element at the current position. Rewrite the MbeElement at the file position from which it was read. Get a handle to the current component or set the current component. Get or set the start angle of the arc element at the current position. Get or set the primary axis of the arc or ellipse element at the current position. Get the number of tags attached to the element.rotate (page 8-42) MbeElement. Set the weight of an element in the MbeElement or retrieve the weight from the element at the current position.rewrite (page 8-44) MbeElement. Process database linkage and populate report rows.

Otherwise.attachActiveEntity . MbeDatabase.. extract a user attribute data linkage from an element.deleteLinkage (page 8-61) Used to Get MbeTag object from attribute element (type 37).defineActiveEntity. If screen forms are activated. get number of user attribute data linkages on element. 8-18 MicroStation BASIC Guide . DEFINE AE or ACTIVE ENTITY command. the entity's active screen form will be used.getNumLinkages (page 8-59) MbeElement. delete a user attribute data linkage from an element.showActiveEntity.Element Object Properties and Methods MbeElement. MbeDatabase. Attach a tag to the element. the SQL SELECT statement specified by the MicroStation command ACTIVE REVIEW will control attributes displayed for each linkage.reviewDBAttributes Descr. the database server will copy the active entity and add a new record to the database. MbeElement.reviewDBAttributes See also MbeElement. Example Dim element as New MbeElement element. The MbeElement. No existing linkages will be disturbed.attachTag (page 8-59) MbeElement. The active entity must have been established with MicroStation FIND. Example Dim element as New MbeElement element.getMbeTag (page 8-58) MbeElement.appendLinkage (page 8-60) MbeElement. The database server will execute the REVIEW SINGLE MicroStation command for the element linkages..reviewDBAttributes MbeElementMbeElement. add a new user attribute data linkage to an element. The database linkage that is created will be appended to existing attributes present on the element object. MbeElement. If the linkage mode is NEW. The MbeElement.extractLinkage (page 8-59) MbeElement.reviewDBAttributes.reviewDBAttributes command interactively reviews attribute linkages present on the element. CREATE ENTITY.attachActiveEntity command links the graphic element with the active entity.attachActiveEntity MbeElement. rewrite the element See also MbeElement. The MicroStation environment variable MS_LINKTYPE controls the linkage format.attachActiveEntity.attachActiveEntity Descr.

reportDBLinkages will accumulate additional rows in the report tables according to the attribute linkages present on the elements. line spacing and justification are taken from the text node. The MbeElement. The MicroStation command ACTIVE REPORT defines the report table contents.loadDAttributes MbeElement. Example Dim element as New MbeElement If element.foundDBLinkages function tests to determine whether an element contains attribute data linkages that belong to the database server.foundDBLinkages. The MbeElement object must be of type text node with a displayable attribute database linkage. The MbeElement. The MbeElement.reportDBLinkages See also MbeDatabase.reportClose.foundDBLinkages = MBE_Success Then element. Example Dim element as New MbeElement element.reportOpen. The text string properties such as font. MbeElement. The screen form associated with the displayable attribute code of the text node's database linkage determines the text string format. text size.Element Object MbeElement. Subsequent calls to MbeElement.reportDBLinkages MbeElement. MbeElement.foundDBLinkages stat = MbeElement.loadDAttributes End If End If See also MbeElement. Elements can MicroStation BASIC Guide 8-19 8 MicroStation Extensions to BASIC Descr. MbeDatabase.loadDAttributes command loads a displayable attribute text node with attribute information from the database. .loadDAttributes Existing text elements attached to the text node are replaced with the text strings reflecting the current database attribute contents.reportDBLinkages Descr.type = MBE_TextNode Then If element.reportDBLinkages command processes database linkages on the MbeElement object.foundDBLinkages() Descr. The database server will add one row to the corresponding report table for each occurrence of an attribute linkage.

Example Dim inElem as New MbeElement Dim lnk() as MbeDatabaseLink Dim numLinks as Integer Dim stat as Integer If inElem..foundDBLinkages returns MBE_Success if the element has one or more linkages that belong to the database server and MBE_NoLinkage if no recognized linkages are present.extractDBLinkages(link() as MbeDatabaseLink) Descr. 8-20 MicroStation BASIC Guide .extractDBLinkages stat = MbeElement. Example Dim inElem as New MbeElement Dim lnk() as MbeDatabaseLink Dim numLinks as Integer Dim stat as Integer If inElem. Returns MbeElement. link specifies a variable length array of MbeDatabaseLink objects which will be redimensioned to point to the array of the linkages found. Otherwise. The MbeElement. Only the linkage types identified by MS_LINKTYPE will be recognized by this function. MbeElement.foundDBLinkages = MBE_Success Then .extractDBLinkages returns MBE_Success if any existing linkages were successfully extracted..extractDBLinkages function extracts an element's database linkages. MbeElement. MbeElement.Element Object contain many types of attribute data linkages that belong to either application programs or the database interface.foundDBLinkages = MBE_Success Then If inElem. MbeElement. Returns MbeElement.deleteDBLinkage.extractDBLinkages.foundDBLinkages is a convenient way to determine whether the MbeElement contains at least one linkage that belongs to the database server.process linkages End If See also MbeElement.tableName = fromTable Then Call rewriteLinkage(inElem. lnk(iLink)) End If Next iLink End If End If See also MbeElement.extractDBLinkages(lnk) = MBE_Success Then For iLink = LBound(lnk) To UBound(lnk) If lnk(iLink).foundDBLinkages.appendDBLinkage. an error status is returned.

name lnk.deleteDBLinkage stat = MbeElement.deleteDBLinkage function removes the database attribute linkage(s) matching to the properties set in the link parameter.largestMslink If inElem.linkType.linkType.tableName.appendDBLinkage. Example Sub RemoveAllOracleLinkages (inElem as MbeElement) Dim link as New MbeDatabaseLink link. MbeDatabaseLink. Returns MbeElement.deleteDBLinkage(link as MbeDatabaseLink) Descr.deleteDBLinkage returns MBE_Success if the attribute linkage(s) was successfully removed.linkType = MBE_ORACLE_Linkage If inElem. MbeDatabaseLink.tableName = tb.entityNumber largestMslink = tb. MbeElement. MbeDatabaseLink.appendDBLinkage returns MBE_Success if the linkage is successfully appended.mslink. Otherwise. MbeDatabaseLink.appendDBLinkage function appends database attribute information present in the MbeDatabaseLink object link to the end of any existing attributes on the element. MbeDatabaseLink.entityNumber = tb. Returns MbeElement. MbeElement. The environment variable MS_LINKTYPE sets the types of linkages that the server processes.deleteDBLinkage. No other types of user data linkages but database will be disturbed. MicroStation BASIC Guide 8-21 8 MicroStation Extensions to BASIC See also MbeElement.deleteDBLinkage (link) = MBE_Success Then stat = inElem.rewrite() End If MbeElement. The MbeElement. MbeDatabaseLink. entityNumber and mslink properties of the MbeDatabaseLink object must be set before passing it as a parameter for appendDBLinkages. If no properties are set by link. MbeDatabaseLink. MbeDatabaseLink.appendDBLinkage(lnk) = MBE_Success Then stat = inElem. Example Dim lnk as New MbeDatabaseLink Dim inElem as MbeElement lnk. tableName.appendDBLinkage(link as MbeDatabaseLink) Descr.extractDBLinkages. The linkType.Element Object MbeElement. all database attributes will be stripped off.rewrite () End If End Sub See also MbeElement.extractDBLinkages.mslink. MbeDatabaseLink.tableName.appendDBLinkage stat = MbeElement.entityNumber. . an error status is returned. The MbeElement.

MbeElement..nextElement stat = MbeElement. The MbeElement. returns MBE_NoMoreElems (leaving the current position set to the header). there is only one element.. sets the current position to that next element and returns MBE_Success. If the element at the current position is a complex component.nextElement.firstElement Descr. Example Dim element as New MbeElement Dim filePos as Long . the MbeElement. consider the following nested cell: 1 2 3 4 5 6 7 8 9 10 Cell Header (0) Line (1) Cell Header (1) Line String (2) Text Node (2) Text (3) Text (3) Ellipse (2) Shape (2) Arc(1) 8-22 MicroStation BASIC Guide .firstElement MbeElement.. For illustration purposes. 2.Element Object MbeElement. so MbeElement. MbeElement. If there is an element following that header at the same level as the header.. If MbeElement is a simple graphics element.nextElement Descr.firstElement Call ProcessPass2(element) . If there is no element following that header at the same nesting level. If the MbeElement is not complex. sets the current position to its header.nextComponent.fromFile(filePos) ' two-pass processing required Call ProcessPass1(element) element. ' figure out what element to operate on ' read the element filePos = element. Whenever it is accessed.thisComponent.firstElement statement sets the current position within a complex MbeElement to the very first element. See also MbeElement.firstElement has no effect.nextElement read-only property does the following: 1. returns MBE_NoMoreElems (1217) and does not affect the current position. MbeElement.

The example illustrates this technique. The following table shows the effect of accessing MbeElement.nextComponent End If Loop While gotNext = MBE_Success End Sub '------------------------------------------------------------' Entry point '------------------------------------------------------------Sub main MicroStation BASIC Guide 8-23 8 MicroStation Extensions to BASIC The MbeElement.isHeader <> 0 Then ' if any components in complex.nextElement with current position set at each element of this complex element: Current pos 1 (Cell Header) 2 (Line) 3 (Cell Header) 4 (Line String) 5 (Text Node) 6 (Text) 7 (Text) 8 (Ellipse) 9 (Shape) 10 (Arc) nextElement returns MBE_NoMoreElems MBE_NoMoreElems MBE_NoMoreElems MBE_Success MBE_Success MBE_Success MBE_Success MBE_Success MBE_Success MBE_NoMoreElems new current pos 1 (CellHeader) 1 (CellHeader) 1 (CellHeader) 10 (Arc) 10 (Arc) 8 (Ellipse) 8 (Ellipse) 10 (Arc) 10 (Arc) 1 (Cell Header) Example '----------------------------------------------------------------' Recursive subroutine to process a simple or complex element '----------------------------------------------------------------Sub ProcessElement(inElem as MbeElement) Dim gotNext as integer Do ' call func.Element Object Where the numbers in parentheses indicate nesting level. process them recursively If inElem.nextElement Else gotNext = inElem. to process individual element at current position Call ProcessIndividualElem(inELem) If inElem.nextComponent to traverse a complex MbeElement using a recursive subroutine. .nextComponent = MBE_Success Then Call ProcessElement(inElem) End If gotNext = inElem.nextElement object method is designed to be used in conjunction with MbeElement.

the current position is updated and MbeElement.thisComponent. If there is no component element. If the element at the current position is a complex header. If there is at least one component.nextComponent read-only property does the following: 1. returns MBE_NoMoreElems (1217) and does not affect the current position. the MbeElement. MbeElement. If the MbeElement is not complex.. Otherwise. the current position is updated to the first component and MbeElement.nextComponent attempts to set the current position to the next component sharing the same complex header. if there is one.nextComponent returns MBE_Success. If the element at the current position is not a complex header (it must therefore be a complex component).Element Object Dim element as New MbeElement Dim filePos as Long . 3. If there are no more such components. 2. ' figure out what element to process filePos = element.nextComponent.fromFile(filePos) Call ProcessElement(element) End Sub ' read element from file ' process element recursively See also MbeElement.nextComponent does not change the current position and returns MBE_NoMoreElems. MbeElement. For illustration purposes. Whenever it is accessed.. MbeElement.nextComponent Descr.nextComponent returns MBE_Success.nextComponent stat = MbeElement. which thus continues to point to the only element within the MbeElement. it returns MBE_NoMoreElems and the current position is not changed. MbeElement. sets the current position to its first component element. consider the following nested cell: 1 2 3 4 5 6 7 8 9 10 Cell Header (0) Line (1) Cell Header (1) Line String (2) Text Node (2) Text (3) Text (3) Ellipse (2) Shape (2) Arc(1) 8-24 MicroStation BASIC Guide .

nextElement to traverse a complex MbeElement using a recursive subroutine.nextElement Else gotNext = inElem.nextComponent End If Loop While gotNext = MBE_Success End Sub '------------------------------------------------------------' Entry point '------------------------------------------------------------- MicroStation BASIC Guide 8-25 8 MicroStation Extensions to BASIC . The following table shows the effect of accessing MbeElement.nextComponent with current position set at each element of this complex element: Current pos 1 (Cell Header) 2 (Line) 3 (Cell Header) 4 (Line String) 5 (Text Node) 6 (Text) 7 (Text) 8 (Ellipse) 9 (Shape) 10 (Arc) nextComponent returns MBE_Success MBE_Success MBE_Success MBE_Success MBE_Success MBE_Success MBE_NoMoreElems MBE_Success MBE_NoMoreElems MBE_NoMoreElems new current pos 2 (Line) 3 (CellHeader) 4 (Line String) 5 (Text Node) 6 (Text) 7 (Text) 7 (Text) 9 (Shape) 9 (Shape) 10 (Arc) The MbeElement.nextComponent = MBE_Success Then Call ProcessElement(inElem) End If gotNext = inElem.nextComponent object method is designed to be used in conjunction with MbeElement. The example illustrates this technique. process them recursively If inElem.isHeader <> 0 Then ' if any components in complex.Element Object Where the numbers in parentheses indicate the nesting level. Example '----------------------------------------------------------------' Recursive subroutine to process a simple or complex element '----------------------------------------------------------------Sub ProcessElement(inElem as MbeElement) Dim gotNext as integer Do ' call function to process individual element at ' current position Call ProcessIndividualElem (inELem) If inElem.

fromFile(filePos) Call ProcessElement(element) End Sub ' read element from file ' process element recursively See also MbeElement. 2. sets the current position to the header of the element at the current position and returns MBE_SUCCESS. is the “root” of the MbeElement). MbeElement. Whenever it is accessed. MbeElement. returns MBE_NotComplex (1218) and does not affect the current position..Element Object Sub main Dim element as New MbeElement Dim filePos as Long . The following table shows the effect of accessing MbeElement. or is not a complex component (i.headerElement Descr. For illustration purposes.e.headerElement stat = MbeElement.. ' figure out what element to process filePos = element.headerElement read-only property does the following: 1. consider the following nested cell: 1 2 3 4 5 6 7 8 9 10 Cell Header (0) Line (1) Cell Header (1) Line String (2) Text Node (2) Text (3) Text (3) Ellipse (2) Shape (2) Arc(1) Where the numbers in parentheses indicate the nesting level.nextElement. Otherwise..nextElement with current position set at each element of this complex element: Current pos 1 (Cell Header) 2 (Line) 3 (Cell Header) 4 (Line String) headerElement returns MBE_NotComplex MBE_Success MBE_Success MBE_Success new current pos 1 (Cell Header) 1 (Cell Header) 1 (Cell Header) 3 (Cell Header) 8-26 MicroStation BASIC Guide . the MbeElement. If the MbeElement is not complex.nextComponent.

thisComponent read/write Integer property is used to mark a position within a complex MbeElement and return later to that position. This “handle” has meaning only when MbeElement. For example... if a macro wanted to change the first text in a cell only if the next text had a certain characteristic.thisComponent is accessed.thisComponent . Example '----------------------------------------------------------------' Recursive subroutine to find first text '----------------------------------------------------------------Function FindFirstText(inElem as MbeElement) as Integer Dim gotNext as integer Dim firstTextPos As Integer Do ' call function that shows info for element at current position If inElem. it could save the position of the first text it encountered and return to it if the next text matched the desired characteristics.thisComponent is assigned .headerElement = MBE_Success Then . When MbeElement.. it returns a non-zero Integer “handle” that is used to identify the position within the complex.Element Object headerElement Current pos 5 (Text Node) 6 (Text) 7 (Text) 8 (Ellipse) 9 (Shape) 10 (Arc) returns MBE_Success MBE_Success MBE_Success MBE_Success MBE_Success MBE_Success new current pos 3 (Cell Header) 5 (Text Node) 5 (Text Node) 3 (Cell Header) 3 (Cell Header) 1 (Cell Header) Example Dim element as MbeElement .nextElement.isHeader <> 0 Then ' process complex elements recursively If inElem. End If See also MbeElement.thisComponent Descr.the actual value cannot be used in any other context. The MbeElement. MbeElement.thisComponent.nextComponent. MbeElement.nextComponent = MBE_Success Then MicroStation BASIC Guide 8-27 8 MicroStation Extensions to BASIC MbeElement.type = MBE_Text Then FindFirstText = inElem. ' now current position is at header .thisComponent Exit Function End If If inElem. MbeElement. If element..

Element Object
firstTextPos = FindFirstText (inElem) If firstTextPos <> 0 Then FindFirstText = firstTextPos Exit Function End If End If gotNext = inElem.nextElement Else gotNext = inElem.nextComponent End If Loop While gotNext = MBE_Success ' if we get here, did not find text FindFirstText = 0 End Function '------------------------------------------------------------' Steps through every element in file, processes first text ' element in every cell. '------------------------------------------------------------Sub main Dim element as New MbeElement Dim filePos as Long Dim firstTextPos as Integer ' read the first element filePos = element.fromFile (0) Do While filePos >= 0 If element.type = MBE_Cell Then firstTextPos = FindFirstText(element) If firstTextPos <> 0 Then element.thisComponent = firstTextPos ' here is where we process the text element we found Call ProcessFirstText(element) End If End If filePos = element.fromFile(filePos + element.fileSize) Loop End Sub

See also MbeElement.firstElement, MbeElement.nextElement, MbeElement.nextComponent.

MbeElement.isHeader
MbeElement.isHeader

Descr. The MbeElement.isHeader read-only property returns TRUE if the element at the current position of MbeElement is a complex header and FALSE otherwise. Complex header elements include MBE_CellHeader, MBE_TextNode, MBE_ComplexString,

8-28

MicroStation BASIC Guide

Element Object
MBE_ComplexShape, MBE_Surface, MBE_Solid, MBE_BSplineSurface, MBE_BSplineCurve and MBE_RasterHeader.

Example Dim element as MbeElement
... If element.isHeader <> 0 Then ... ' process complex element End If

MbeElement.isComponent
MbeElement.isComponent

Descr. The MbeElement.isComponent read-only property returns TRUE if the element at the current position of MbeElement is complex element component, FALSE otherwise. Example Dim element as MbeElement
... If element.isComponent <> 0 Then ... ' process component element End If

MbeElement.isGraphics
MbeElement.isGraphics

Descr. The MbeElement.isGraphics read-only property returns 1 if the element at the current position of MbeElement is a graphics element and 0 if it is a non-graphics (control) element. Example Dim element as MbeElement
... If element.isGraphics <> 0 Then ... ' process graphics element End If

MbeElement.type

The MbeElement.type read-only property returns the Integer type of the element at the current position. The graphics element types are:
MBE_CellLibraryHdr MBE_CellHeader MBE_Line MBE_LineString MBE_Shape

1 2 3 4 6

MBE_BSplinePole MBE_PointString MBE_Cone MBE_BSplineSurface MBE_BSplineBoundary

21 22 23 24 25

MicroStation BASIC Guide

8-29

8

MbeElement.type

MicroStation Extensions to BASIC

Element Object
MBE_TextNode MBE_Curve MBE_ComplexString MBE_ComplexShape MBE_Ellipse MBE_Arc MBE_Text MBE_Surface MBE_Solid

7 11 12 14 15 16 17 18 19

MBE_BSplineKnot MBE_BSplineCurve MBE_BSplineWeight MBE_Dimension MBE_SharedCellDefinition MBE_SharedCell MBE_MultiLine MBE_Tag MBE_RasterHeader MBE_RasterComponent

26 27 28 33 34 35 36 37 87 88

Example Dim element as New MbeElement
... ' get an element by some method If element.type = MBE_Text Then ... ' process complex element End If

MbeElement.fileSize
MbeElement.fileSize

Descr. The MbeElement.fileSize read-only Long property returns the size, in bytes, that the entire (possibly complex) MbeElement occupies in the design file. This value can be used to step through the design file reading elements sequentially. Example Dim element as MbeElement
Dim filePos as Long ' step through every element in the file filePos = element.fromFile (0) Do While filePos >= 0 ProcessElement(element) filePos = element.fromFile(filePos + element.fileSize) Loop

See also MbeElement.internalSize.

MbeElement.internalSize
MbeElement.internalSize

Descr. The MbeElement.internalSize read-only Long property returns the size, in bytes, that the individual component element at the current position occupies in memory. On some platforms, an element is a different size on the disk from its internal size because

8-30

MicroStation BASIC Guide

Element Object
some data items in an element must be aligned on byte boundaries appropriate to their data size. Example Dim internalSize as Long
internalSize = element.internalSize

See also MbeElement.fileSize.

MbeElement.fromFile
filePos = MbeElement.fromFile(filePos as Long[, fileNum as Integer[, _ mastFileUnits as Integer [, expandShared as Integer]]])

Descr. The MbeElement.fromFile object function attempts to read an MbeElement from either the master file or one of its reference files. The argument, filePos, is required to specify the file position of the MbeElement to be read from the file. If the second (optional) argument, fileNum, is provided, it specifies whether to read the element from the master (fileNum = 0) or one of the reference files (fileNum = the reference file slot to read the element from). If fileNum is not provided, the MbeElement is read from the master file. The third (optional) argument, mastFileUnits, is used only if the MbeElement is read from a reference file. It specifies whether to transform MbeElement read from the reference file to the coordinate system of the master file. Not providing the argument is the same as passing TRUE and thus transforming the MbeElement to master file coordinates, which is the recommended option. The fourth (optional) argument, expandShared, specifies whether or not to expand shared cells, with TRUE indicating that they are to be expanded. Note that any changes that are made to the components of a shared cell cannot be written back to the design file. The default behavior if the argument is omitted is not to expand shared cells.

If any optional argument is omitted, the arguments following it in the argument list must be omitted as well.

If successful, MbeElement.fromFile returns a Long that is the file position from which the element is read. The return value may differ from the filePos specified in the case that the element in the design file at filePos is a deleted element. Deleted elements cannot be retrieved from the design file using MbeElement.fromFile. Instead, the first non-deleted element following filePos is read. If filePos specifies a file position that does not correspond to the beginning of an element, MbeElement.fromFile returns -1. If filePos points to a complex header, MbeElement.fromFile always reads the entire complex element. If filePos points to a complex component, MbeElement.fromFile will read it, but the usefulness of this is limited since you cannot modify a complex component and use MbeElement.rewrite to make a permanent change to the design. There are a number of ways to determine a file position to use as input to
MbeElement.fromFile. To process an entire design file, MbeElement.fromFile can read starting at 0 and use the return value from one call to MbeElement.fromFile and

MicroStation BASIC Guide

8-31

8

MicroStation Extensions to BASIC

Element Object
MbeElement.fileSize to calculate the filePos for the next call. The MbeElementSet object can be used to operate on sets of elements, and MbeDgnInfo.endOfFile can be

saved before placing an element to retrieve the new element after sequencing a command. Note that even though you can consider MbeElement.fromFile to be reading elements from the design file, in reality it retrieves the element from MicroStation’s element cache if the element is available in the cache. This yields a substantial performance benefit versus actual disk access. Example Sub main
Dim element as New MbeElement Dim filePos as Long ' read the first element filePos = element.fromFile(0) ' step through every element in the file Do While filePos >= 0 ProcessElement(element) filePos = element.fromFile(filePos + element.fileSize) Loop End Sub

See also MbeElement.fileSize, MbeElement.fromLocate.

MbeElement.fromLocate
filePos=MbeElement.fromLocate([mastFileUnits as Integer _ [,expandShared as Integer]])

Descr. The MbeElement.fromLocate object function attempts to read the last element that the user interactively located, either during the course of a MicroStation command or as a result of the macro calling MbeStartLocate. The first (optional) argument, mastFileUnits, is used only if the element last located was in a reference file. It specifies whether to transform an MbeElement read from the reference file to the coordinate system of the master file. Not providing the argument is the same as passing TRUE and thus transforming the MbeElement to master file coordinates, which is the recommended option. The second (optional) argument, expandShared, specifies whether or not to expand shared cells, with TRUE indicating that they are to be expanded. Note that any changes can be made to the components of a shared cell cannot be written back to the design file. The default behavior if the argument is omitted is not to expand shared cells. If successful, MbeElement.fromLocate returns a Long that is the file position from which the previously located element is read. If the user has not previously located an element while the current master file has been active, MbeElement.fromLocate returns -1.

8-32

MicroStation BASIC Guide

Element Object
If the element located is a complex, MbeElement.fromLocate retrieves the entire complex element and the current position in the MbeElement points to the actual component element that the user locate point selected.
Dim element as New MbeElement MbeStartLocate ... ' sequence user through selecting an element ' retrieve the element that the user located filePos = element.fromLocate() If filePos >= 0 Then ... ' process the element End If

See also MbeStartLocate, MbeElement.fromFile.

MbeElement.filePos
MbeElement.filePos

Example Dim element as New MbeElement
Dim nextElemFilePos as Long stat = element.fromLocate() nextElemFilePos = element.filePos + element.fileSize

See also MbeElement.fileNum, MbeElement.componentFilePos.

MbeElement.componentFilePos
MbeElement.componentFilePos

Descr. The MbeElement.componentFilePos read-only Long property returns the file position from which the component at the current position in the MbeElement originated.
Dim componentOffset as Long componentOffset = element.componentFilePos - element.filePos

See also MbeElement.fileNum, MbeElement.filePos.

MbeElement.fileNum
MbeElement.fileNum

Descr. The MbeElement.fileNum read-only Integer property returns the file number from which the MbeElement originated. Example Dim element as New MbeElement
Dim nextElemFilePos as Long stat = element.fromLocate()

MicroStation BASIC Guide

8-33

8

MicroStation Extensions to BASIC

Descr. The MbeElement.filePos read-only Long property returns the file position from which the MbeElement originated.

Element Object
nextElemFilePos = element.filePos + element.fileSize element.fromFile(nextElemFilePos, element.fileNum)

See also MbeElement.filePos, MbeElement.componentFilePos.

MbeElement.changeAll
MbeElement.changeAll

Descr. The MbeElement.changeAll read/write Integer property controls whether changes to certain MbeElement properties affect only the element at the current position, or all valid component elements of the MbeElement. The properties for which the state of MbeElement.changeAll matters are those that are common to all graphics elements, including: level, color, style, weight, class and group; and the fontNum and fontName properties which are applied to all text and text node elements in a complex if MbeElement.changeAll is TRUE. The behavior of the MbeElement.move, MbeElement.rotate, and MbeElement.scale object functions are also affected by changeAll. The changeAll property is set to FALSE for a new MbeElement, but the state of changeAll is unaffected by reading a new element into an MbeElement. Example Sub MatchLevel(elem1 as MbeElement, elem2 as MbeElement, _
allComponents as integer) ' set changeAll property to change all component elements if desired elem1.changeAll = allComponents elem1.level = elem2.level End Sub

See also MbeElement.level, MbeElement.color, MbeElement.style, MbeElement.weight, MbeElement.class, MbeElement.group, MbeElement.font, MbeElement.fontName, MbeElement.move, MbeElement.rotate, MbeElement.scale.

MbeElement.level
MbeElement.level

Descr. The MbeElement.level read/write Integer property sets or retrieves the level of the MbeElement. When MbeElement.level is retrieved, it returns the level of the component element at the current position. When MbeElement.level is assigned, it sets the level of the component element at the current position if MbeElement.changeAll is FALSE, and the level of all components of the MbeElement if MbeElement.changeAll is TRUE. Any attempt to assign level to a value outside the range 1 to 63 results in an MBE_InvalidLevel (1202) runtime error. Any attempt to assign a level to a non-graphics (control) element or an element of type MBE_CellHeader results in an MBE_WrongElemType (1207) runtime error. Example Sub MatchLevel(elem1 as MbeElement, elem2 as MbeElement, _
allComponents as Integer) ' set changeAll property to change all component elements if desired elem1.changeAll = allComponents

8-34

MicroStation BASIC Guide

Element Object
elem1.level = elem2.level End Sub

See also MbeElement.changeAll.

MbeElement.color
MbeElement.color

Descr. The MbeElement.color read/write Integer property sets or retrieves the color of the MbeElement. When MbeElement.color is retrieved, it returns the color of the component element at the current position. When MbeElement.color is assigned, it sets the color of the component element at the current position if MbeElement.changeAll is FALSE, and the color of all components of the MbeElement if MbeElement.changeAll is TRUE. Any attempt to assign color to a value outside the range 0 to 255 results in an MBE_InvalidColor (1203) runtime error. Any attempt to assign a color to a non-graphics (control) element results in an MBE_WrongElemType (1207) runtime error. Example Sub MatchColor(elem1 as MbeElement, elem2 as MbeElement, _
allComponents as Integer) ' set changeAll property to change all component elements if desired elem1.changeAll = allComponents elem1.color = elem2.color End Sub

See also MbeElement.changeAll.

MbeElement.style
MbeElement.style

Descr. The MbeElement.style read/write String property sets or retrieves the style of the MbeElement. When MbeElement.style is retrieved, it returns the style of the component element at the current position. When MbeElement.style is assigned, it sets the style of the component element at the current position if MbeElement.changeAll is FALSE, and the style of all components of the MbeElement if MbeElement.changeAll is TRUE. The style property is a String so a macro can use custom line styles. If a macro wants to set a line style by number, in can send the numeric string (i.e., “1” to set style 1). If an attempt is made to assign style that cannot be found, a runtime error MBE_InvalidStyle (1205) is generated. Any attempt to assign a style to a non-graphics (control) element results in an MBE_WrongElemType (1207) runtime error. Example Sub MatchStyle(elem1 as MbeElement, elem2 as MbeElement, _
allComponents as Integer) ' set changeAll property to change all component elements if desired elem1.changeAll = allComponents

MicroStation BASIC Guide

8-35

8

MicroStation Extensions to BASIC

Element Object
elem1.style = elem2.style End Sub

See also MbeElement.changeAll.

MbeElement.weight
MbeElement.weight

Descr. The MbeElement.weight read/write Integer property sets or retrieves the line weight of the MbeElement. When MbeElement.weight is retrieved, it returns the line weight of the component element at the current position. When MbeElement.weight is assigned, it sets the line weight of the component element at the current position if MbeElement.changeAll is FALSE, and the weight of all components of the MbeElement if MbeElement.changeAll is TRUE. Any attempt to assign weight to a value outside the range 0 to 31 results in an MBE_InvalidWeight (1204) runtime error. Any attempt to assign a weight to a non-graphics (control) element results in an MBE_WrongElemType (1207) runtime error. Example Sub MatchWeight(elem1 as MbeElement, elem2 as MbeElement, _
allComponents as Integer) ' set changeAll property to change all component elements if desired elem1.changeAll = allComponents elem1.weight = elem2.weight End Sub

See also MbeElement.changeAll.

MbeElement.class
MbeElement.class

Descr. The MbeElement.class read/write Integer property sets or retrieves the class of the MbeElement. When MbeElement.class is retrieved, it returns the class of the component element at the current position. When MbeElement.class is assigned, it sets the class of the component element at the current position if MbeElement.changeAll is FALSE, and the class of all components of the MbeElement if MbeElement.changeAll is TRUE. Any attempt to assign class to a value outside the range 0 to 15 results in an MBE_InvalidClass (1206) runtime error. Any attempt to assign a class to a non-graphics (control) element results in an MBE_WrongElemType (1207) runtime error. Constants have been defined for the element classes that MicroStation recognizes:
MBE_PrimaryClass MBE_PatternClass MBE_ConstructionClass MBE_DimensionClass MBE_PrimaryRuleClass

0 1 2 3 4

8-36

MicroStation BASIC Guide

Element Object
MBE_PatternedLineClass MBE_ConstRuleClass

5 6

Example Sub MatchClass(elem1 as MbeElement, elem2 as MbeElement, _
allComponents as Integer) ' set changeAll property to change all component elements if desired elem1.changeAll = allComponents elem1.class = elem2.class End Sub

See also MbeElement.changeAll.

MbeElement.properties
MbeElement.properties

The element properties are a group of bits in the element header that indicate locked status, new status, modified status, attributes present, view independent, hole or solid status, planar, and snappable. Generally, macros want to examine properties bits, and will rarely need to set them. To test for a particular property, retrieve the properties and AND with the desired property bit. To set a particular property, retrieve the properties, OR with the desired property, and assign the result. To clear a particular property, AND with NOT the property bit and assign the result. These constants have been defined for the element properties bits:
Property
MBE_LockedProp MBE_NewProp MBE_ModifiedProp MBE_AttributesProp MBE_ViewIndProp MBE_PlanarProp MBE_NoSnapProp MBE_HoleProp

Mask Value
1 4 8 16 32 64 128 2

Example Function isLocked(elem as MbeElement)
If (elem.properties And MBE_LockedProp) <> 0 Then

MicroStation BASIC Guide

8-37

8

MicroStation Extensions to BASIC

Descr. The MbeElement.properties read/write Integer property sets or retrieves the properties of the MbeElement. When MbeElement.properties is retrieved, it returns the properties of the component element at the current position. When MbeElement.properties is assigned, it sets the properties of the component element at the current position. Any attempt to assign properties to a non-graphics (control) element results in an MBE_WrongElemType (1207) runtime error.

Element Object
isLocked = TRUE Else isLocked = FALSE End If End Function

MbeElement.getOrigin
stat = MbeElement.getOrigin(origin as MbePoint)

Descr. The MbeElement.getOrigin object function retrieves an MbePoint that is the “origin” of the graphics element at the current position in the MbeElement. The function is valid for most, but not all graphics element types. The origin returned for each element type is as follows:
Element Type
MBE_CellHeader MBE_Line MBE_LineString MBE_Shape MBE_TextNode MBE_Curve MBE_ComplexString MBE_ComplexShape MBE_Ellipse MBE_Arc MBE_Text MBE_BSplinePole MBE_PointString MBE_Cone MBE_BSplineSurface MBE_BSplineCurve MBE_SharedCell MBE_MultiLine MBE_Tag

Origin Definition
Cell origin Centroid Centroid Centroid User origin Centroid Centroid Centroid Center Center User origin First pole First point Bottom center Centroid Centroid Origin Centroid User origin

If the element at the current position is valid for getOrigin, the function returns MBE_Success. Otherwise it returns MBE_WrongElemType (1207).

8-38

MicroStation BASIC Guide

points(iPoint). MBE_PointString and MBE_MultiLine.getPoints object function retrieves an array of type MbePoint that contains the points that comprise the graphics element at the current position.cmdResult = MBE_AcceptQuery Then MbeSendDataPoint(origin) ' accept (point doesn’t matter) End If ' get out of SCALE command MbeSendCommand "NULL" End If See also MbeElement. If the element at the current position is valid for getPoints.filePos. if the macro needs to calculate the number of points it can do so using UBound(points) .LBound(points) + 1 For iPoint = LBound(points) To UBound(points) print “x :". MBE_LineString.fromLocate() ' find the origin If element. MBE_BSplinePole. ' sequence user through selecting an element ' retrieve the element that the user located filePos = element.getPoints stat = MbeElement.filePos.UBound(points) . Example Sub ShowPoints(element as MbeElement) Dim points() as MbePoint Dim iPoint as Integer If element.z MicroStation BASIC Guide 8-39 8 MicroStation Extensions to BASIC . _ element.fileNum. so the macro must pass it a variable-length array.x. MbeElement. origin) ' should have found it. element.y. Otherwise it returns MBE_WrongElemType (1207).getPoints(points() as MbePoint) Descr." y:".points(iPoint).. the function returns MBE_Success. The function redimensions the points array argument..getPoints.Element Object Example ' scale selected element about its origin Dim element as New MbeElement Dim origin as MbePoint MbeStartLocate . The function is valid for element types MBE_Line.getPoints(points) = MBE_Success Then print “Number of Points : “. The array is redimensioned by the function to points (0 to numpoints-1). MBE_Shape. but double check If MbeState.points(iPoint). MBE_Curve.getOrigin(origin) = MBE_Success Then ' start the SCALE command MbeSendCommand “SCALE” ' locate the element at its origin Call MbeLocateElement(element.Lbound(points) + 1. The MbeElement. print " z:".

setPoints(points() as MbePoint [.rewrite function is used. 8-40 MicroStation BASIC Guide .getOrigin. MBE_Shape. If numPoints is supplied. while an MBE_LineString is changed to an MBE_Line if the number of points is equal to 2. MBE_TooManyPoints (1213) is returned. MBE_LineString. Note that the changes are made to the MbeElement in memory only. then that specifies the number of points to use from the points array. and. or MBE_WrongDimension (801) is returned.getPoints(points) = MBE_Success Then If Ubound(points) . it must contain at least numPoints MbePoints. Example Dim points() as MbePoints Dim element as New MbeElement . An MBE_Line is changed to an MBE_LineString if the number of points is greater than 2. ' get element somehow If element. otherwise the UBound and LBound of points are used to compute the number of points.x = points(1). the MbeElement. the function returns MBE_OffDesignPlane (1211). The MbeElement.. If the number of points is less than 2.numPoints as Integer]) Descr. the function returns MBE_WrongElemType (1207). The function can change the number of points in a linear graphics element.Lbound(points) > 3 Then points(2). If an element that is invalid for the function is specified.getOrigin. If any of the points specified are off the design plane. MbeElement. To make the changes permanent.setPoints object function sets the points that make up the linear element as the current position within the MbeElement. MBE_Curve and MBE_MultiLine.Element Object Next iPoint End If End Sub See also MbeElement..setPoints stat = MbeElement. if numPoints is specified.x If element. The function is valid for element types MBE_Line.setPoints (points) <> MBE_Success Then print “could not set points” End If End If End If See also MbeElement. and if the number of points is greater than 101. MBE_NotEnoughPoints (1212) is returned. points must be a single-dimensioned array.

MBE_LineString. The function is valid for element types MBE_Line. the start and end points are the same.getEndPoints stat = MbeElement. startPoint retrieves the starting point as an MbePoint. y and z directions in the design file. startPoint as MbePoint. MBE_Ellipse.getEndPoints(startPoint. If the element at the current position is valid for getEndPoints. The range retrieved indicates the upper and lower boundaries of the element in the x.getEndPoints(startPoint [..getRange object function retrieves an MbeRange that contains the range of the element at the current position within the MbeElement. MbeElement..getRange(range) MicroStation BASIC Guide 8-41 8 MicroStation Extensions to BASIC . Get an element stat = element. The MbeElement. The element range is generally of limited use to a macro. ' get element from somewhere If element.getEndPoints object function retrieves the start and end points of the graphics element at the current position in the MbeElement.getRange(range as MbeRange) Descr. while the second (optional) argument retrieves the end point as an MbePoint.. MBE_ComplexString. MBE_Curve. element as New MbeElement . MBE_ComplexShape and MBE_MultiLine. Example Dim element as MbeElement. MBE_BSplinePole.getRange stat = MbeElement.getOrigin. The MbeRange type is defined as follows: Type MbeRange xLow as Long yLow as Long zLow as Long xHigh as Long yHigh as Long zHigh as Long End Type Example Dim range as MbeRange. ' process end points End If See also MbeElement.getPoints. The getRange function returns an integer that is set to MBE_Success unless the element passed is corrupt.. Otherwise it returns MBE_WrongElemType (1207).. MbeElement. endPoint]) Descr. MBE_Shape. The MbeElement. MBE_Arc. the function returns MBE_Success. The values are returned in design file units (not in master units). endPoint as MbePoint . endPoint) = MBE_Success Then .. MBE_PointString.Element Object MbeElement. For closed elements.

move(distance as MbePoint) Descr. This is rarely the desired result. To make the changes permanent.getRotation method. Get an element distance. in which case the entire complex element is rotated. The rotate function works on any graphics element type except those that are inherently components of a complex element (i.rotate.scale. MBE_BSplineKnot). unless MbeElement.changeAll is TRUE. in which case the entire complex element is moved.move stat = MbeElement.z = 0 stat = element.move (distance) See also MbeElement. The move function works on any graphics element type except those that are inherently components of a complex element (i. distance as MbePoint .. MbeElement. only the first argument is given. which specifies the rotation about the Z axis. If attempts are made to move such elements. The fourth optional argument specifies a point to rotate the element about. The MbeElement.move object function offsets the element at the current position within the MbeElement by the distance specified. rather than just the component.rotate(rMatrix(0 to 2. ✍ Changes are made to the element descriptor in memory only..rewrite. (refer to the second example).rotate object function rotates the element at the current position within the MbeElement by the rotating angles specified in radians. MbeElement.. rather than just the component.Element Object MbeElement.e. respectively. Most of the time origin is needed. The second legal declaration of MbeElement. _ [origin as MbePoint]) Descr. MbeElement. MbeElement.rotate illustrates the ability to accept a rotation matrix in the form of a 3-dimensional array of Doubles. MBE_WrongElemType (1207) is returned. 8-42 MicroStation BASIC Guide .2 distance. The MbeElement.2 distance. _ rotateX as Double [. origin as MbePoint]]]) stat = MbeElement.. otherwise the element is rotated about the coordinate system origin. in its simplest form. 0 to 2) as Double. Considering the first declaration of MbeElement.rotate(rotateZ as Double [.y = -1. This is the form already returned by the MbeElement. unless MbeElement.addToFile.changeAll is TRUE.x = 4.rotate stat = MbeElement.rewrite is used. The second and third optional arguments specify the rotations around the Y and X axes. Example Dim element as New MbeElement.e.rotate. MbeElement. rotateY as Double [. otherwise MBE_Success.

Most of the time the origin argument is needed.2) = 1.. origin) = MBE_Success Then stat = element.changeAll is TRUE. MbeElement.scale MicroStation Extensions to BASIC rMatrix(1. only the first argument is given.0 rMatrix(2.0) = 1. unless MbeElement. stat = MbeElement. 0.Element Object MBE_BSplineKnot). _ scaleZ as Double [.rewrite() End If End If Example Dim cellElem As MbeElement. which are assumed to be 1.0 . because otherwise the element is scaled about the MicroStation BASIC Guide 8-43 8 MbeElement.0) = 0. respectively.scale object function scales the element at the current position within the MbeElement by the scale factors specified. MBE_WrongElemType (1207) is returned.0 ..move.1) = 0. scaleY as Double [. Example Dim element as New MbeElement.rewrite() End If End If See also MbeElement..getOrigin(origin) = MBE_Success Then If cellElem.0 rMatrix(0. To make the changes permanent. Note that the changes are made to the element descriptor in memory only. which specifies the scale factor in the X direction. In its simplest form.2) = 0.scale (scaleX as Double [. origin as MbePoint .rotate(rMatrix. otherwise the function returns MBE_Success. origin As MbePoint Dim rMatrix(0 To 2. origin as MbePoint]]]) Descr. MbeElement.1) = -1.0 if not specified.rotate(PI/4. the MbeElement.0 rMatrix(2. MbeElement.0 rMatrix(1.addToFile.0.getOrigin(origin) = MBE_Success Then If element. The fourth optional argument specifies a point to scale the element about. in which case the entire complex element is scaled.0) = 0.0 rMatrix(0. The MbeElement. The second and third optional arguments specify the scale factors in the Y and X axes. rather than just the component.0 rMatrix(1..rewrite. 0. rMatrix(0.rewrite object function is used. 0 To 2) As Double ’ Set up a matrix to do a 90 degree rotation. If an attempt is made to rotate such an element. Get an element If element.0 rMatrix(2. Get a cell element If cellElem.2) = 0. origin) = MBE_Success Then stat = element.1) = 0.scale.0.

0. it controls whether the existing element is erased before replacing it in the file.addToFile. element in reference file element is not an entire complex write to file stopped by MDL application element corrupted Example Dim element as New MbeElement.rewrite object function rewrites the MbeElement at the file position from which it was read.rotate.4. MbeElement.scale(1. file is read only. origin as MbePoint .rewrite([filePos [.rotate(PI/4.0. which is rarely the desired result. eraseOld as Integer [. See Appendix A for more information on OLE Automation. 1.. _ drawNew as Integer]]]) Descr. If filePos is provided. origin as MbePoint .0.getOrigin(origin) = MBE_Success Then If element. MbeElement.4. In Visual Basic.Element Object coordinate system origin. Dim element as New MbeElement. Both arguments are assumed to be TRUE if they are not provided. 0. drawNew controls whether the changed element is displayed after it is written to the design file. the MbeElement.rewrite stat = MbeElement.e. MBE_BSplineKnot). The scale function works on any graphics element type except those that are inherently components of a complex element (i.changeAll. The possible errors that can arise when trying to rewrite an element are: MBE_DiskFull (61) MBE_AccessDenied (70) MBE_CantRewrite (1208) MBE_ComplexComponent (1215) MBE_WriteInhibit (1216) MBE_BadElement (1219) disk is full. MbeElement. If the optional eraseOld argument is specified. the method name scaleElem must be used instead of scale.. origin) = MBE_Success Then stat = element.. Note that the changes are made to the element descriptor in memory only. The MbeElement.rewrite.rewrite() End If End If See also MbeElement. To make the changes permanent. Get an element If element. 0.getOrigin(origin) = MBE_Success Then If element. it returns the file position at which the element was rewritten. MbeElement. Similarly.. origin) = MBE_Success Then 8-44 MicroStation BASIC Guide . MbeElement. MBE_WrongElemType (1207) is returned. Get an element If element.move.. "Appendix A". otherwise MBE_Success is returned. 1. If an attempt is made to scale such an element.rewrite object function is used.

If filePos is provided. origin) = MBE_Success Then stat = element.Element Object stat = element. The MbeElement. The MbeElement. it returns the file position at which the element was written. MBE_NormalDraw is assumed. Possible values are MBE_NormalDraw. it specifies the drawing mode to use. file is read only.addToFile object function adds the MbeElement to the end of the master file. 0. If drawMode is provided. element is not an entire complex.rewrite. If the argument is omitted.display [drawMode as Integer[.rotate(PI/4. if the next MicroStation BASIC Guide 8-45 8 MicroStation Extensions to BASIC . element corrupted. The possible errors that can arise when trying to add an element to the file are: MBE_DiskFull (61) MBE_AccessDenied (70) MBE_ComplexComponent (1215) MBE_WriteInhibit (1216) MBE_BadElement (1219) disk is full.addToFile([filePos as Long [. MbeElement. MbeElement.addToFile stat = MbeElement. Not specifying drawNew is the same as passing TRUE.0. write to file stopped by MDL application. the element is displayed to view 1.0. 0. If drawNew is specified. ✍ Do not try to rewrite a deleted element. it controls whether the changed element is displayed after it is written to the .getOrigin(origin) = MBE_Success Then If element.display statement displays the MbeElement in one or more views.. viewMask as Integer]] Descr. origin as MbePoint . Example Dim element as New MbeElement.rewrite() End If End If See also MbeElement. Get an element ' rotate the element and put the modified copy at the end of the file If element. viewMask controls which views the MbeElement is displayed in.dgn file. drawNew as Integer]]) Descr.display MbeElement.addToFile() End If End If See also MbeElement.addToFile. Mbe_Erase or Mbe_Hilite.. If the low order bit is a 1.

MBE_ComplexShape and MBE_CellHeader that represent grouped hole orphan cells. the function returns 0. The element must be closed. closed MBE_BSplineCurve. Get an element ' hilite the element in views 1..Element Object bit is a 1. Example Dim element as New MbeElement. The MbeElement. 2. If the element at the current position is not closed and therefore does not have a valid perimeter..perimeter read-only property returns the perimeter of the element at the current position within the MbeElement as a Double. The units depend on the current coordinate system that the macro has established using the MbeCurrentTransform object (by default. The MbeElement. MBE_ComplexShape and MBE_CellHeader that represent grouped hole orphan cells...area read-only property returns the area of the element at the current position within the MbeElement as a Double. ' can use area in calculations End If MbeElement.0 Then . area as Double .. ' can use perimeter in calculations End If 8-46 MicroStation BASIC Guide . perimeter as Double . The property is valid for element types MBE_Shape. The property is valid for element types MBE_Shape.display MBE_Hilite.perimeter MbeElement. the MbeElement is displayed in all views. If viewMask is omitted. If the element at the current position is not closed and therefore does not have a valid area. MBE_Ellipse.area If area <> 0.. Example Dim element as New MbeElement .. closed MBE_BSplineCurve.area Descr.area MbeElement. it is master units).perimeter Descr. the element is displayed to view 2. and so on.. Get an element ' find the perimeter of the element perimeter = element. Example Dim element as New MbeElement. it is square master units). MBE_Ellipse. Get an element ' find the area of the element area = element.0 Then . The units depend on the current coordinate system that the macro has established using the MbeCurrentTransform object (by default.. MBE_Curve. the function returns 0.perimeter If perimeter <> 0. MBE_Curve. The element must be closed. and 3 element.. 7 MbeElement.

MBE_CellHeader. MBE_SharedCell and MicroStation BASIC Guide 8-47 8 MicroStation Extensions to BASIC MbeElement.volume read-only property returns the volume of the element at the current position within the MbeElement as a Double. The property is valid for MBE_Solid.. Example Dim element as New MbeElement. The centroid can be calculated for most elements.getCentroid(centroid as MbePoint) Descr. If the element at the current position does not have a valid volume.e. The property is valid for MBE_CellLibraryHeader.getCentroid object function returns the centroid of the element at the current position within the MbeElement as a Double. If the element at the current position does not have a valid centroid.volume Descr. ' can use centroid in calculations End If MbeElement. The MbeElement.. Example Dim element as New MbeElement.volume MbeElement...cellName read-only String property returns the name of the cell in the cell header at the current position within the MbeElement. The units depend on the current coordinate system that the macro has established using the MbeCurrentTransform object (by default. MBE_Surface. Get an element ' find the volume of the element volume = element. the function returns 0. the function returns MBE_WrongElemType (1207). the centroid is returned in master units).volume If volume <> 0. MBE_BSplineKnot).cellName MbeElement.. The MbeElement..getCentroid (centroid) = MBE_Success Then . and closed MBE_BSplineSurface elements.0 Then . ' can use volume in calculations End If stat = MbeElement.. it is cubic master units). Get an element ' find the centroid of the element If element. The MbeElement.Element Object MbeElement.. exceptions being those that are inherently components of a complex element (i.getCentroid .. area as Double . centroid as MbePoint . The units depend on the current coordinate system that the macro has established using the MbeCurrentTransform object (by default.cellName Descr. The element must be a volumeenclosing element.

. If the element at the current position is not one of these types. The function is valid for MBE_CellHeader. cellName as String . the function returns MBE_Success. process level mask End If MbeElement.type = MBE_CellHeader Or element. Example Dim element as New MbeElement. Otherwise it returns MBE_WrongElemType (1207).getCellLevels stat = MbeElement.getCellBox object function retrieves the eight points that comprise the range box associated with the cell. The MbeElement. etc. the next bit to level 2. Get an element If element.. When a cell is selected using MicroStation’s element selection tool.dgn file coordinate system. process range box End If 8-48 MicroStation BASIC Guide . If the element at the current position is one of these types.. The low bit of levelMask(0) corresponds to level 1. The function redimensions the levelMask array argument to levelMask (0 to 3). MBE_Success is returned. so the macro must pass a variable-length array. The MbeElement.getCellBox (rangeBox) = MBE_Success Then . otherwise MBE_WrongElemType (1207). If the element at the current position is one of these types.getCellBox(rangeBox. MBE_SharedCell and MBE_SharedCellDefinition elements. so the macro must pass a variable-length array. The function redimensions the rangeBox array argument to rangeBox (0 to 7).. The cell range box differs from the range of the element in that it is oriented in the coordinate system of the cell and thus is not necessarily orthogonal to the . element handles are placed at the eight points returned by this function (the first four in a 2D file).cellName End If MbeElement. Example Dim element as New MbeElement Dim levelMask() as Integer If element.Element Object MBE_SharedCellDefinition elements.getCellLevels(levelMask() as Integer) Descr.getCellBox stat = MbeElement. rangeBox() as MbePoint If element. MBE_CellHeader.getCellLevels(levelMask) = MBE_Success Then . MBE_SharedCell and MBE_SharedCellDefinition elements. as MbePoint) Descr.. The function is valid for MBE_CellLibraryHeader.getCellLevels object function retrieves an array of type Integer that contains the levels that are occupied by the cell.. Example Dim element as New MbeElement.type = MBE_SharedCell Then cellName = element. an MBE_WrongElemType (1207) runtime error is generated.

. MBE_Arc.Element Object MbeElement.getRotation object function retrieves the rotation matrix for the element at the current position within the MbeElement.font = 4 Then element.fontName MbeElement.type Case MBE_Text.the dimensions can be (0 to 2) or (1 to 3). MBE_Tag ' change all font 4’s into font 1’s If element. When MbeElement. MBE_Ellipse. Get an element element. returning MBE_Success if it is able to return the rotation matrix. rotation(1 to 3. The function is valid for MBE_CellHeader. On retrieval or assignment with MbeElement. Example Dim element as New MbeElement. If rotMatrix is not correctly dimensioned. MBE_Text. If the element at the current position is not one of these types. The MbeElement.font is assigned.font read/write Integer property sets or retrieves the font of MBE_Text. and the font of all MBE_Text.changeAll = FALSE.getRotation stat = MbeElement. MBE_TextNode.changeAll = FALSE Select Case element. MBE_TextNode and MBE_Tag elements within the MbeElement if MbeElement.getRotation(rotMatrix(0 to 2)(0 to 2) as Double) Descr.changeAll.1 to 3) as Double If element.. process rotation End If MbeElement.font MbeElement. MbeElement. MBE_Tag and MBE_Cone elements. the function returns Mbe_WrongDimension (801).font Descr.changeAll is TRUE. it returns the font of the component element at the current position. an MBE_WrongElemType (1207) runtime error is generated if the element at the current position is not a valid type. The rotMatrix argument must be a 3 x 3 twodimensional array .fontName MicroStation BASIC Guide 8-49 8 MicroStation Extensions to BASIC .. MBE_SharedCell.font = 1 Case Else font = -1 End Select See also MbeElement. When MbeElement. MBE_TextNode. MbeElement. Dim element as New MbeElement . MBE_SharedCellDefinition.fontName. MBE_TextNode or MBE_Tag elements. depending on the macro programmer’s preference. the function returns MBE_WrongElemType (1207). MBE_TextNode or MBE_Tag element at the current position if MbeElement. The MbeElement.getRotation(rotation) = MBE_Success Then .font is retrieved.changeAll is FALSE.. it sets the font of the MBE_Text.

MBE_TextNode or MBE_Tag element at the current position within the MbeElement.charWidth Descr. MbeElement.fontName read/write String property sets or retrieves the font of MBE_Text. The MbeElement. and the font of all MBE_Text. MbeElement.. Example Dim element as New MbeElement. MBE_Tag If element. Get an element element.type Case MBE_Text.changeAll=FALSE.charHeight MbeElement. On retrieval or assignment with MbeElement.charWidth Case Else font = -1 End Select 8-50 MicroStation BASIC Guide .fontName is retrieved. Get an element Select Case element. MBE_TextNode. charWidth as Double. When MbeElement. If the font specified on assignment isn’t found in symbology resource files..fontName is assigned.changeAll = FALSE Select Case element.font..fontName = “WORKING” End If Case Else font = -1 End Select See also MbeElement.charHeight and MbeElement. it sets the font of the MBE_Text. The MbeElement. MBE_TextNode. MBE_FontNotFound (1209) runtime error is generated.type Case MBE_Text.changeAll is FALSE. an MBE_WrongElemType (1207) runtime error is generated. Dim element as New MbeElement .charHeight.changeAll is TRUE.Element Object Descr. MBE_TextNode or MBE_Tag elements.charWidth read-only Double properties retrieve the character height and width of the MBE_Text.charWidth MbeElement. it returns the font of the component element at the current position. MBE_Tag ' get the character height and width charHeight = element.changeAll.fontName = “ENGINEERING” Then element.. MBE_TextNode and MBE_Tag elements within the MbeElement if MbeElement. When MbeElement. charHeight as Double . If the element at the current position is not one of these types. MBE_TextNode or MBE_Tag element at the current position if MbeElement. MBE_WrongElemType (1207) runtime error is generated if the element at the current position is not a valid type.charHeight charWidth = element. MbeElement.

MBE_Tag MicroStation BASIC Guide 8-51 8 MicroStation Extensions to BASIC Descr. MBE_TextNode or MBE_Tag element at the current position within the MbeElement.justification read-only Integer property retrieves the justification of an MBE_Text. The MbeElement.. lineSpacing as Double .justification The possible value for justification are: MBE_LeftTop MBE_LeftCenter MBE_LeftBottom MBE_LeftMarginTop MBE_LeftMarginCenter MBE_LeftMarginBottom MBE_CenterTop MBE_CenterCenter MBE_CenterBottom MBE_RightMarginTop MBE_RightMarginCenter MBE_RightMarginBottom MBE_RightTop MBE_RightCenter MBE_RightBottom 0 1 2 3 (Text nodes only) 4 (Text nodes only) 5 (Text nodes only) 6 7 8 9 (Text nodes only) 11 (Text nodes only) 12 13 14 10 (Text nodes only) Example Dim element as New MbeElement. .lineSpacing Descr.type = MBE_TextNode Then lineSpacing = element. If the element at the current position is not one of these three types. If the element at the current position is not one of an MBE_TextNode. Example Dim element as New MbeElement. MBE_TextNode. an MBE_WrongElemType (1207) runtime error is generated. an MBE_WrongElemType (1207) runtime error is generated.Element Object MbeElement.. Get an element If element. justification as Integer .justification MbeElement. The MbeElement..lineSpacing End If MbeElement.lineSpacing MbeElement.type Case MBE_Text. Get an element Select Case element..lineSpacing read-only Double property retrieves the line spacing of the MBE_TextNode element at the current position within the MbeElement.

if text has right characteristics If (numEDFields > 3) Then If EDFields(2).justification Case Else justification = -1 End Select MbeElement. the function returns MBE_WrongElemType (1207).getString stat=MbeElement. _ enterDataFields() as MbeEDField ]]) Descr.start = 8 And EDFields(2).getString redimensions the array passed in to (0 to numEDFields-1).type = MBE_Text Then If element. respectively. The MbeEDField predefined data type is as follows: Type MbeEDField start as Integer length as Integer justification as Integer End Type Valid values for justification are -1. elemText as String Dim numEDFields as Integer. 8. so the macro must pass a variable-length array for this argument. Optionally.getString(elemText as String [.setString. 3) = “BJB” If element. 1. If enterDataFields is included.EDFields) _ <> MBE_Success Then MbeWriteError(“Unable to change string”) End If End If End If End If End If See also MbeElement. Example Dim element as New MbeElement. These values relate to left.numEDFields. EDFields() as MbeEDField .EDFields)=MBE_Success Then ' fill in second EDField..numEDFields as Integer[. The MbeElement. 0. center and right justification.getString function retrieves the text string for the MBE_Text element at the current position within the MbeElement. 8-52 MicroStation BASIC Guide .getString(elemText.. Get element somehow If element.setString(elemText. the number of “Enter Data” fields and the starting position and length of those Enter Data fields can be returned by numEDFields and enterDataFields.numEDFields.length = 3 Then Mid$(elemText. If the element at the current position is not MBE_Text. MbeElement.Element Object ' get the justification justification = element.

Example Dim element as New MbeElement. The primary axis of an ellipse or arc is the axis aligned with the X axis of MicroStation BASIC Guide 8-53 8 MbeElement.getString for the definition of the MbeEDField predefined data type.start = 8 And EDFields(2).length = 3 Then Mid$(elemText. the number of “Enter Data” fields and the starting position and length of those Enter Data fields can be set using the optional numEDFields and enterDataFields arguments. MbeElement. If either condition is not met. Get element somehow If element.getString. the function returns Mbe_WrongDimension (801) If the element at the current position is not MBE_Text.setString stat = MbeElement. if text has right characteristics If (numEDFields > 3) Then If EDFields(2). numEDFields. enterDataFields must be a onedimensional array with at least numEDFields entries. numEDFields. MbeElement. See MbeElement.setString (elemText as String [. 3) = “BJB” If element.primaryAxis MicroStation Extensions to BASIC . The MbeElement. The MbeElement. elemText as String Dim numEDFields as Integer.numEDFields as Integer.getString(elemText. If numEDFields and enterDataFields are both included.primaryAxis read/write Double property retrieves or sets the primary axis of the MBE_Arc or MBE_Ellipse element at the current position within the MbeElement. Optionally...Element Object MbeElement.setString object function sets the text string for the MBE_Text element at the current position within the MbeElement. _ enterDataFields() as MbeEDField ]) Descr.setString sets the enter data fields within the MBE_Text element. the function returns MBE_WrongElemType (1207). 8.primaryAxis Descr.type = MBE_Text Then If element.setString(elemText. EDFields() as MbeEDField . EDFields) = MBE_Success Then ' fill in second EDField. EDFields) _ <> MBE_Success Then MbeWriteError (“Unable to change string”) End If End If End If End If End If See also MbeElement.

sweepAngle.sweepAngle. MbeElement.primaryAxis = newAxis element. newAxis as Double . an MBE_WrongElemType (1207) runtime error is generated.secondaryAxis) / 2.secondaryAxis) / 2. MbeElement.primaryAxis + element.startAngle.type = MBE_Ellipse Then If element. If the element at the current position is not an MBE_Arc.0 element.primaryAxis <> element.. MbeElement.secondaryAxis Then newAxis = (element. If the element at the current position is not one of these two types. Get an element ' make the arc into a circular arc. The MbeElement.type = MBE_Arc Or element. If the element at the current position is not one of these two types.primaryAxis. an MBE_WrongElemType (1207) runtime error is generated.secondaryAxis Then newAxis = (element.startAngle. The secondary axis of an ellipse or arc is the axis aligned with the Y axis of the ellipse or arc coordinate system.startAngle MbeElement.secondaryAxis read/write Double property retrieves or sets the secondary axis of the MBE_Arc or MBE_Ellipse element at the current position within the MbeElement. ellipse into a circle If element. an MBE_WrongElemType (1207) runtime error is generated. where A is the primary axis and B is the secondary axis. ellipse into a circle If element. 8-54 MicroStation BASIC Guide .primaryAxis <> element. MbeElement. Example Dim element as New MbeElement.. MbeElement.secondaryAxis = newAxis End If End If See also MbeElement.type = MBE_Ellipse Then If element. newAxis as Double .primaryAxis + element. Example Dim element as New MbeElement.secondaryAxis MbeElement.0 element.secondaryAxis Descr.startAngle read/write Double property retrieves or sets the starting angle in radians of an MBE_Arc element at the current position within the MbeElement.type = MBE_Arc Or element.Element Object the ellipse or arc coordinate system. Get an element ' make the arc into a circular arc.secondaryAxis = newAxis End If End If See also MbeElement.startAngle The MbeElement. The start angle of an arc is the starting angle for theta while drawing the arc according to the formula X = A cos (theta).secondaryAxis. Y = B sin (theta).primaryAxis = newAxis element. MbeElement...

Get an element If element.topRadius bottomRadius = element. If the element at the current position is not an MBE_Cone.bottomRadius read-only Double properties retrieve the top and bottom radii of the MBE_Cone element at the current position within the MbeElement..getTopOrigin.getTopOrigin stat = MbeElement. Example Dim element as New MbeElement. an MBE_WrongElemType (1207) runtime error is generated. MbeElement. an MBE_WrongElemType (1207) runtime error is generated.getOrigin. MbeElement. MbeElement.. The MbeElement.secondaryAxis. bottomRadius as Double .getTopOrigin(origin as MbePoint) Descr.sweepAngle....primaryAxis. If the MicroStation BASIC Guide 8-55 8 MicroStation Extensions to BASIC . MbeElement..startAngle.getTopOrigin object function retrieves an MbePoint that is the center of the top circle of the MBE_Cone at the current position in the MbeElement.bottomRadius MbeElement.type=MBE_Arc Then arcAngle=element. topRadius as Double. MbeElement.bottomRadius End If See also MbeElement.topRadius.primaryAxis.topRadius MbeElement. The MbeElement.bottomRadius Descr.startAngle End If See also MbeElement. where A is the primary axis and B is the secondary axis. Y = B sin (theta). Get an element If element. MbeElement.sweepAngle MbeElement.topRadius and MbeElement.type=MBE_Arc Then arcAngle=element.Element Object Example Dim element as New MbeElement. Get an element If element. MbeElement. MbeElement. If the element at the current position is not an MBE_Arc.type = MBE_Cone Then topRadius = element. The MbeElement. arcAngle as Double . The sweep angle of an arc is the angle through which theta traverses while drawing the arc starting at its start angle according to the formula X = A cos (theta).sweepAngle Descr. Example Dim element as New MbeElement.secondaryAxis. MbeElement. arcAngle as Double .startAngle End If See also MbeElement.sweepAngle read/write Double property sets the sweep angle in radians for an MBE_Arc element at the current position within the MbeElement.

type = MBE_TextNode Then nodeNum = MbeCExpressionLong _ ("elem. filePos as Long ' read the first element filePos = element. but is provided for instances where MbeElement methods do not provide an interface to some aspect of the MbeElement.publish "elem" ' Find text node number 8 in the master file Do While filePos >= 0 print "element type ". Accessible members of a C structure that represent an MbeElement are: long int int MSElementDescr MSElementDescr filePos fileNum globalChanges *currentPosition *elemDP file position file number “changeAll” property current position element descriptor Using MbeElement. The base center of MBE_Cone is retrieved by MbeElement. nodeNumber as Long.Element Object element at the current position is not an MBE_Cone. Example Dim element as New MbeElement.fromFile (0) element. When the MbeElement. element.type If element.getOrigin.getTopOrigin (topOrigin) End If See also MbeElement.publish object method publishes the underlying structure for an MbeElement so that it can be accessed using MbeCExpression routines. BASIC MbeElement objects are implemented using MDL element descriptors.publish and MbeCExpression requires extreme caution.getOrigin. Effective use of MbeElement. That name can then be used by MbeCExpression functions to access structure members. MBE_WrongElemType (1207) runtime error is generated.text_node_2d.publish publishName as String Descr.publish requires a good working knowledge of C and MDL (MicroStation Development Language). Example Dim element as New MbeElement. This facility is rarely needed by macro programmers. MbeElement.publish statement is executed. topOrigin as MbePoint. None of the safeguards that are in place when you access the MbeElement through the BASIC object interface are in place when you use this technique. The MbeElement. the name supplied becomes the variable name for a C structure defining an MbeElement. botOrigin as MbePoint If element. so an understanding of element descriptor concept is also needed.type = MBE_Cone Then stat = element.publish MbeElement.nodenumber") If nodeNum = 8 Then End Do 8-56 MicroStation BASIC Guide .getOrigin (botOrigin) stat = element.currentPosition->el.

The MbeElement.. MbeDgnInfo.numTags. MbeElement.group = el2.found text node number 8 . MbeElement.attachTag.group MbeElement. MbeElement.fileSize) Loop If filePos >= 0 Then ' Do interrupted .fromFile(filePos + element. allComps as Integer) ' set changeAll property to change all component elements if desired el1. MbeElement. process it here End If See also MbeCExpressionLong.isTagged = 1 then call printTaggedInfo(inElem) end if End sub See also MbeElement.group Example Sub MatchGroup(el1 as MbeElement..group read/write Integer property sets or retrieves the graphic group of the MbeElement. MbeElement. It returns either 1 (tagged) or 0 (not tagged).tagId is a read only property of type Long that returns the unique association ID for the element.Element Object End If filePos = element.tagId=0 then call AssociateElement(inElem) end if End sub See also MbeElement. Any attempt to assign a graphic group to a nongraphics (control) element results in an ERR_WRONGELEMENTTYPE (1207) runtime error. MbeCExpressionDouble. el2 as MbeElement.group is retrieved.tagId Descr.tagId. MbeElement.changeall = allComps el1. When MbeElement. it sets the graphic group of component element at the current position if MbeElement.isTagged. MbeElement.isTagged Descr.nextGraphicGroup.changeAll is FALSE.group End Sub See also MbeElement. and the level of all components of the MbeElement if MbeElement.graphicGroup.numTags. it returns the graphic group of the component element at the current position. Example Sub ShowTagInfo(inElem as MbeElement) if inElem. MbeDgnInfo. Example if inElem. MbeCExpressionString.attachTag. When MbeElement.changeAll is TRUE.changeAll. . MicroStation BASIC Guide 8-57 8 MicroStation Extensions to BASIC Descr. It returns 0 if the element is not tagged.group is assigned.isTagged is a read only integer property which decides whether the element has any tags attached. MbeElement. MbeElement.

extractTags returns MBE_Success if either the tags are extracted successfully or the element has no tags attached. MbeElement.. MbeElement. MbeElement. Example Sub printTaggedInfo(inElem as MbeElement) dim tagArray() as MbeTag if inElem.extractTags(tagArray) = MBE_Success then for idx = 0 to total -1 call printTag(tagArray(idx)) next idx end if end if End Sub See also MbeElement.getMbeTag stat = MbeElement.getMbeTag. MbeElement. It returns 0 if it is not tagged.isTagged = 1 then for idx = 0 to idx = inElem. Example Sub printTagInfo(inElem as MbeElement) dim tag as new MbeTag 8-58 MicroStation BASIC Guide .extractTags stat = MbeElement. Otherwise.isTagged = 1 then total = inElem. Example Sub ProcessTags(inElem as MbeElement) if inElem.getMbeTag creates an MbeTag object from an attribute element (type 37). next idx end if End sub See also MbeElement.numTags Descr. It returns MBE_WrongElemType if the element is not an attribute element (type 37). MbeElement..numTags is a read only integer property which returns the number of tags attached to the element.isTagged. MbeElement. MbeElement.extractTags creates an array of MbeTag objects for each tag attached to the element.numTags if inElem.Element Object MbeElement. an error code is returned.getMbeTag(tag as MbeTag) Descr.numTags 1 .attachTag.getMbeTag returns MBE_Success if the MbeTag object extracted successfully from the element. MbeElement. tag specifies the MbeTag object to be created from the element.extractTags(tagArray() as MbeTag) Descr.attachTag. tagArray specifies a variable length array of MbeTag objects which will be redimensioned according the number tag attachments. MbeElement.

. doNotWrite as integer) Descr.name = "elemnum" tag. _ linkageId As Long [.value = Str$ (count) stat = inElem.getNumLinkages(demoLinkageId) MbeElement. MbeElement. MbeElement.extractLinkage(linkageData As <almost any type>.value.attachTag.getMbeTag(tag)=MBE_Success then ‘print tag properties end if End Sub See also MbeElement. MbeTag.setName.attachTag attaches the tag specified by an MbeTag object to the element.setName = "set0001" 'tag element count tag. MbeElement. MbeElement.getNumLinkages returns the number of user attribute data linkages on the element matching the linkage signature of linkageId. ’ Do not use the Id shown below in this example as it is for demonstration ’ purposes only and might conflict with already existing linkages. Otherwise. tag specifies the MbeTag object containing the tag information to be attached.extractTags.attachTag(tag) End Sub See also MbeElement. Example ’ An application-specific linkage Id must be obtained from Bentley Systems.attachTag(tag as MbeTag) stat = MbeElement. MbeTag.attachTag returns MBE_Success if the tag is attached successfully to the element. element As New MbeElement . it returns an error code.attachTag stat = MbeElement. MbeElement. MbeTag.extractLinkage status&=MbeElement. inElem as MbeElement) Dim tag as new MbeTag tag.getMbeTag.. If doNotWrite is not passed or its value is FALSE then the attribute element (type 37) is also written to the design file. nthLink As Integer]) MicroStation BASIC Guide 8-59 8 MicroStation Extensions to BASIC . Const demoLinkageId=43797 Dim numLinkages As Integer. Example Sub tagElement(count as Long.name.getNumLinkages numLinkages%=MbeElement. MbeElement. get an element numLinkages=element.attachTag(tag as MbeTag.getNumLinkages(linkageId as Long) Descr.Element Object if inElem.

extractLinkage obtains a copy of a user attribute data linkage from an element and makes it accessible in a BASIC variable. Example ’ An application-specific linkage Id must be obtained from Bentley Systems.extractLinkage(chair. Attention is needed when the BASIC variable is a String variable or a User Defined Type containing a String member.appendLinkage. Char arrays in user attribute data linkages must be a fixed size to be extracted properly at a later time. String variables are pre-sized by assigning a value to it. The example below may be considered an inverse to that in MbeElement. demoLinkageId) End sub MbeElement. Contents of the variable are filled in from a user attribute data linkage. The signature of the new linkage is provided by linkageId.appendLinkage(linkageData As <almost any type>. Although linkageData is filled in by MbeElement. When that data includes a char array. Consider a user attribute data linkage 8-60 MicroStation BASIC Guide . MbeElement. get an element ’extract the first demolinkage status=element. it is first used as a template on interpreting the format of the linkage data on the element.extractLinkage. MbeElement. linkageData can be any data type except Single and Object.. they are sized to fit data as needed. the first linkage matching linkageId is extracted. Contents of the variable are appended to the element as a user attribute data linkage. If nthLink is not provided. String variables have no predefined sizes.description=space$(32) . linkageData can be any BASIC data type except Single and Object. Regardless of platform. ’ Do not use the Id shown below in this example as it is for demonstration ’ purposes only and might conflict with already existing linkages. Regardless of platform. The signature for the new linkage is given by linkageId.appendLinkage appends a new user attribute data linkage to an element. element As New MbeElement. _ linkageId As Int) Descr. chair As FurnitureType ’String variables must be initialized to their expected size chair. nthLink specifies the linkage to extract in cases of multiple linkages on the element matching linkageId.dgn file format (packed little-endian)..dgn file format (packed little-endian) to native memory format.Element Object Descr. user attribute data copied from the element automatically is converted from . the corresponding String variable must be pre-sized to match the char data’s size. the BASIC variable’s contents will be converted to . Const demoLinkageId=43797 Type FurnitureType partId As Long description As String ’Must be padded to 32 characters End Type Sub Main Dim status As Long. The solution is padding the String variable to desired size before appending to the element. Attention is needed when extracting BASIC String variables (or String members of User Defined Types).appendLinkage status&=MbeElement.

32) . MbeElement. MbeElement. padSize As Integer) As String PadString=theString+space$(padSize-len(theString)) End Function Sub Main Dim status As Long. If nthLink is not provided. This only applies when more than one linkage matching linkageId exists on the element. MbeElement. the first linkage encountered (matching linkageId) is deleted. 2) See also MbeElement.deleteLinkage(demoLinkageId. PadString. To delete all linkages matching linkageId.deleteLinkage numDelete%=MbeElement. from an element. Example ’ An application-specific linkage Id must be obtained from Bentley Systems.deleteLinkage(linkageId [. get an element ’ delete the 2nd linkage on the element. ’ Do not use the Id shown below in this example as it is for demonstration ’ purposes only and might conflict with already existing linkages.. below can be used to pad the String variable to the desired size. element as New MbeElement . numDeleted=element. MbeElement. MicroStation BASIC Guide 8-61 8 MicroStation Extensions to BASIC .partId=512 chair.deleteLinkage returns number of linkages deleted.extractLinkage.Element Object consisting of 32 chars needs to be appended to an element.getNumLinkages.... Const demoLinkageId=43797 Type FurnitureType partId As Long description As String ’Must be padded to 32 characters End Type Function PadString(theString As String. element As New MbeElement. Example ’ An application-specific linkage Id must be obtained from Bentley Systems.appendLinkage.deleteLinkage deletes one or more user attribute data linkages matching the linkage signature of linkageId.description=PadString("arm chair". nthLink]) Descr. ’ Do not use the Id shown below in this example as it is for demonstration ’ purposes only and might conflict with already existing linkages. chair As FurnitureType chair. specify -1 for nthLink. Const demoLinkageId=43797 Dim numDeleted as Integer. demoLinkageId) End sub MbeElement. get an element status=element.appendLinkage(chair. nthLink (optional) specifies which linkage to delete from the element.

fromSelectionSet object function populates the MbeElementSet object from the user selection set.fromSelectionSet or MbeElementSet. the user selection set is discarded after it is transferred to the object. Populate the MbeElementSet object from the currently defined fence.fromFence (page 8-63) MbeElementSet. which is convenient if the macro wants to sequence a MicroStation command that works on a selection set. Free all memory associated with the MbeElementSet.messages = 0 ' get element set from either selection set or fence 8-62 MicroStation BASIC Guide .bas example shown below).fromSelectionSet is called for an MbeElementSet object that has previously been populated by a call to either MbeElementSet.Element Set Object Element Set Object Properties and Methods MbeElementSet.messages MbeState. if one exists.graphGroupLock = 0 ' turn off messages saveMsgs = MbeState. if there is one.getFirst (page 8-64) MbeElementSet. If MbeElementSet.fromSelectionSet function returns MBE_Success if there is a selection set. Example Sub main Dim Dim Dim Dim Dim Dim Dim Dim elemSet as New MbeElementSet elem as New MbeElement setMember as MbeSetMember point as MbePoint filePos as Long fileNum as Integer saveGGLk as Integer saveMsgs as Integer ' turn off graphic group lock saveGGLk = MbeSettings. giving individualized inputs for every element in the selection set (e. if one exists.getNext (page 8-64) MbeElementSet. the existing set members are discarded before getting the new members. If discard is set to a nonzero value. The MbeElementSet.fromFence..g.clear (page 8-65) Used To Populate the MbeElementSet object from the currently defined selection set.fromSelectionSet([discard]) Descr.fromSelectionSet (page 8-62) MbeElementSet.fromSelectionSet stat = MbeElementSet. The MbeElementSet.graphGroupLock MbeSettings. Get file information on the first selection set member (returned as type MbeSetMember). MbeElementSet. and MBE_NoSelectionSet (1301) if there is no user selection set active. Retrieve information on the next selection set member. the scaletxt.

If allowLocked is omitted or zero.getOrigin(point) = MBE_Success Then MbeSendCommand "SCALE" MbeLocateElement setMember. MbeElementSet.fromFence([allowLocked]) Descr.getFirst(setMember) ' process each graphic group member Do While status = MBE_Success filePos = elem. elements from reference files and elements in the master file with the locked bit set are included in the MbeElementSet. The MbeElementSet. MbeElementSet. as accept point may ' select another elem MbeSendCommand "NULL" End If End If End If status = elemSet.fromFence object function populates the MbeElementSet object from a fence.type = MBE_Text Then If elem.Element Set Object If elemSet.fileNum. only unlocked elements in the MicroStation BASIC Guide 8-63 8 MicroStation Extensions to BASIC .clear ' restore graphic group lock and messages MbeSettings.cmdResult = MBE_AcceptQuery Then MbeSendDataPoint point ' cancel scale.clear.fromFence stat = MbeElementSet. point If MbeState.getNext (setMember) Loop ' clear selection set elemSet. if there is one.messages = saveMsgs End Sub See also MbeElementSet.filePos.fromFence() <> MBE_Success Then MbeWriteStatus "No fence or selection set" Else MbeWriteStatus "Processing Fence" End If Else MbeWriteStatus "Processing Selection Set" End If ' set an undo mark so we can go back MbeSendCommand "MARK" status = elemSet.fromFile(setMember.fromFence. setMember.componentFilePos._ elem.filePos.fromSelectionSet (1) <> MBE_Success Then If elemSet. setMember.fileNum) If elem.graphGroupLock = saveGGLk MbeState. If allowLocked is set to a non-zero value.

getNext(setMember as MbeSetMember) Descr.getNext stat = MbeElementSet. which is a predefined type as follows: Type MbeElementSet filePos as Long fileNum as Integer End Type The MbeElementSet. MbeElementSet.getFirst(setMember as MbeSetMember) Descr. If MbeElementSet.Element Set Object master file are included.getFirst object function retrieves the next member from the MbeElementSet. the elements that overlap the fence boundary are clipped at the boundary and the appropriate clipped portion of the element becomes part of the element set.getFirst function returns MBE_Success if there is at least one member in the set.clear.fromSelectionSet. See also MbeElementSet.getFirst function returns MBE_Success if there is another member in the set. MbeElementSet.fromSelectionSet nor MbeElementSet. and MBE_NoMoreInset (1304) if the set is empty despite an attempt to get a set from a fence or selection set.getNext. The element set members are returned as type MbeSetMember. The MbeElementSet. For an example see MbeElementSet.fromSelectionSet. See also MbeElementSet. MbeElementSet.fromFence function returns MBE_Success if there is a fence active.getFirst object function retrieves the first member from the MbeElementSet.fromFence. and MBE_NoMoreInset (1304) if there are no more members.getFirst stat = MbeElementSet. The MbeElementSet. and MBE_MustGetFromUser (1303) if neither MbeElementSet. For an example see MbeElementSet. and MBE_NoFence (1302) if no fence is defined.fromFence.fromSelectionSet or MbeElementSet.fromFence was successfully called to populate the set. which is a predefined type as follows: Type MbeElementSet filePos as Long fileNum as Integer End Type The MbeElementSet. The MbeElementSet. The element set members are returned as type MbeSetMember. the existing set members are discarded before getting the new members. If fence clip lock is on. If 8-64 MicroStation BASIC Guide .fromFence is called for an MbeElementSet object that has previously been populated by a call to MbeElementSet.

See also MbeElementSet.fromSelectionSet. See also MbeElementSet.clear object method discards the MbeElementSet members and returns the memory used by the element set to the system.getFirst.getNext returns MBE_MustGetFromUser (1303).fromFence has been successfully called. For an example see MbeElementSet. the clear is automatically performed when the MbeElementSet object goes out of scope or when the macro exits.fromFence. whichever comes first. MbeElementSet.clear MbeElementSet. The MbeElementSet.Element Set Object neither MbeElementSet. For an example see MbeElementSet.clear Descr.fromSelectionSet nor MbeElementSet. MbeElementSet.fromSelectionSet.clear. It is good programming practice to call MbeElementSet. MicroStation BASIC Guide 8-65 8 MicroStation Extensions to BASIC . If a macro uses an MbeElementSet and fails to call MbeElementSet.clear as soon as the set processing is complete.

Set or retrieve the active font by number Set or retrieve the active font by name.terminatorScale (page 8-79) Used To Set or retrieve the active angle.axisOrigin (page 8-68) MbeSettings.lineTerminator (page 8-74) MbeSettings. Set or retrieve the increment angle for Axis Lock.fillMode (page 8-71) MbeSettings.level (page 8-73) MbeSettings. Set or retrieve the origin angle for Axis Lock. Set or retrieve the spacing between grid points. Set or retrieve the active cell name.nodeJustification (page 8-75) MbeSettings.patternScale (page 8-77) MbeSettings. Retrieve the active scale.setPatternDelta (page 8-76) MbeSettings.cell (page 8-69) MbeSettings. Set the active pattern component offsets.font (page 8-72) MbeSettings.patternAngle2 (page 8-75) MbeSettings.axisAngle (page 8-68) MbeSettings. Set or retrieve the number of grid points between grid reference crosses.areaMode (page 8-68) MbeSettings. Set or retrieve the active line terminator scale.Settings Object Settings Object Properties and Methods MbeSettings.fillColor (page 8-71) MbeSettings.gridReferences (page 8-72) MbeSettings. Set or retrieve the active pattern cell name.fontName (page 8-72) MbeSettings.class (page 8-69) MbeSettings. Set or retrieve the active text node justification.gridUnits (page 8-73) MbeSettings.patternAngle1 (page 8-75) MbeSettings.lineStyleName (page 8-74) MbeSettings. Set or retrieve the active line terminator (cell name). Set or retrieve the pattern angle 1 as a double in radians. Set or retrieve the active level. Set or retrieve the current graphic group number. Set or retrieve the active cap mode for making capped (open) surfaces or uncapped surfaces (treated as solids). Set or retrieve the active fill color.currentGraphicGroup (page 8-71) MbeSettings.getPatternDelta (page 8-77) MbeSettings. Retrieve the active pattern component offsets.patternCell (page 8-76) MbeSettings. Set or retrieve the active pattern scale factor.setScale (page 8-78) MbeSettings.colorName (page 8-70) MbeSettings. Set or retrieve the active color number. Set or retrieve the active tag increment.angle (page 8-67) MbeSettings. Set or retrieve the active color by name. Set or retrieve the active line style. 8-66 MicroStation BASIC Guide . Set the active scale. Set or retrieve the active class.getScale (page 8-78) MbeSettings.tagIncrement (page 8-78) MbeSettings. Set or retrieve the active fill mode. Set or retrieve the pattern angle 2 as a double in radians. Set or retrieve the active point cell name.point (page 8-77) MbeSettings.color (page 8-70) MbeSettings.lineStyle (page 8-74) MbeSettings. Set or retrieve the active line style name. Set or retrieve the active area mode (Solid or Hash).capMode (page 8-69) MbeSettings.

Set or retrieve the fence void lock state (controls how elements outside the fence are processed).boresiteLock (page 8-82) MbeSettings.gridLock (page 8-84) MbeSettings.angle Descr.angle read/write property sets or retrieves the active angle as a Double in radians. Set or retrieve the active text justification. Set or retrieve the active line weight.fenceVoid (page 8-85) MbeSettings. Set or retrieve the Axis Lock state (on or off).textHeight (page 8-79) MbeSettings.. MbeSettings.textWidth (page 8-79) MbeSettings.depthLock (page 8-83) MbeSettings. Set or retrieve the Snap Lock state.angle = PI/4 ' set active angle to 45 degrees .graphGroupLock (page 8-83) MbeSettings.fenceClip (page 8-84) MbeSettings. Set or retrieve the active text width.snapLock (page 8-86) MbeSettings.fenceOverlap (page 8-84) MbeSettings.settingErr (page 8-86) MbeSettings. MbeSettings. Example Dim oldAngle as Double oldAngle = MbeSettings.textNodeLock (page 8-86) MbeSettings.angle = oldAngle MicroStation BASIC Guide 8-67 8 MicroStation Extensions to BASIC .textLineLength (page 8-80) MbeSettings.constructionPlaneLock (page 8-83) MbeSettings. Set or retrieve the fence overlap lock state (controls how elements that overlap the fence are processed). Turn fence clipping on or off. Set or retrieve the Level Lock state (determines whether located elements should be limited to the active level).. Set or retrieve the active text line spacing. Set or retrieve the Grid Lock state (on or off).Settings Object Properties and Methods MbeSettings. Set or retrieve the Construction Plane Lock state (on or off). Set or retrieve the cell stretch lock state (on or off). The MbeSettings. Set or retrieve the Graphic Group Lock state (on or off).cellStretchLock (page 8-82) MbeSettings.selectionSetLock (page 8-85) Used To Set or retrieve the active text height. Set or retrieve the Depth Lock state (on or off).textLineSpacing (page 8-80) MbeSettings. Determine the status of the last attempt to set or retrieve one of the properties of the MbeSettings system object. Set or retrieve the selection set lock state (controls whether MicroStation commands will operate on elements in selection sets). Set or retrieve the Boresite Lock state (on or off).levelLock (page 8-85) MbeSettings. Set or retrieve the Association Lock state (on or off). Set or retrieve the Text Node Lock state.weight (page 8-81) MbeSettings.textJustification (page 8-80) MbeSettings.angle MbeSettings.angle MbeSettings.associationLock (page 8-81) MbeSettings. Set or retrieve the active text line length.axisLock (page 8-82) MbeSettings.

areaMode MbeSettings. it is not set and MbeSettings.axisOrigin' save existing settings oldAxisAngle = MbeSettings. MbeSettings. if MbeSettings.axisAngle Descr. Example Dim oldAreaMode as Integer oldAreaMode = MbeSettings.areaMode to a value other than 0 or 1.areaMode read/write Integer property sets or retrieves the active area mode as an Integer.axisAngle read/write property sets or retrieves the increment angle for axis lock. MbeSettings.settingErr is set to TRUE. degrees. The MbeSettings.axisOrigin Descr... The property is a Double measured in radians.axisAngle is PI/2 (90 degrees). MbeSettings.areaMode MbeSettings..axisAngle is PI/4 (45 degrees). Example Dim oldAxisOrigin as Double Dim oldAxisAngle as Double oldAxisOrigin = MbeSettings..settingErr.Settings Object MbeSettings. The MbeSettings.axisAngle MbeSettings. The MbeSettings. if MbeSettings. The property is a Double measured in radians. ' set axis origin to 45 degrees ' and axis angle to 90 degrees 8-68 MicroStation BASIC Guide . For example.. 45.axisAngle = PI/2 .areaMode is set to 0 for Solid and 1 for Hole..axisOrigin is PI/4 (45 degrees) and MbeSetting. the axis lock will lock at 45. 90.axisAngle = oldAxisAngle See also MbeSettings. If an attempt is made to set MbeSettings. the axis lock will lock at 0.axisAngle = PI/4 ' set axis angle to 45 degrees . 225. For example..axisAngle MbeSettings.axisAngle MbeSettings.areaMode = oldAreaMode ' restore old areaMode See also MbeSettings...axisOrigin = PI/4 MbeSettings. Example Dim oldAxisAngle as Double oldAxisAngle = MbeSettings.axisOrigin read/write property sets or retrieves the origin angle for axis lock..axisOrigin. 135. MbeSettings. MbeSettings..areaMode Descr.axisOrigin MbeSettings. degrees.areaMode = 0 ' set active areaMode to Solid .

Example Dim oldCell as String oldCell = MbeSettings. it is not set and MbeSettings.axisOrigin.settingErr = 0 Then .cell MbeSettings.cell = oldCell ' restore old cell End If See also MbeSettings. it is not set and MbeSettings.cell to a cell not found in any of the cell libraries in the search path.capMode = 1 . MbeSettings.cell MbeSettings.capMode MbeSettings. MbeSettings..capMode = oldCapMode ' set active capMode to Closed ' restore old capMode MbeSettings.settingErr. If an attempt is made to set MbeSettings.capMode read/write property sets or retrieves the active cap mode as an Integer. ' Use new active cell MbeSettings. MbeSettings.settingErr.. The MicroStation BASIC Guide 8-69 8 MicroStation Extensions to BASIC See also MbeSettings.class read/write property sets or retrieves the active class as an Integer.axisOrigin = oldAxisOrigin MbeSettings.capMode to a value other than 0 or 1.class to a number outside the range 0 through 15. If an attempt is made to set MbeSettings. Example Dim oldCapMode as Integer oldCapMode = MbeSettings.capMode MbeSettings.settingErr is set to TRUE. the active cell is not changed and MbeSettings.cell Descr.settingErr is set to TRUE. The MbeSettings..class Descr. If an attempt is made to set MbeSettings. The MbeSettings. The MbeSettings.settingErr is set to TRUE.capMode Descr.cell = “AC12R2” ' set active cell If MbeSettings.cell read/write property sets or retrieves the active cell as a String.capMode is set to 0 to make uncapped surfaces (treated as open surfaces) and 1 for capped surfaces (treated as solids). MbeSettings.Settings Object MbeSettings. .class MbeSettings..axisAngle = oldAxisAngle See also MbeSettings.

color.Settings Object reference for MbeElement.settingErr.color MbeSettings.colorName = oldColorName ' set active color to Brown ' restore old color See also MbeSettings. Example Dim oldColor as Integer oldColor = MbeSettings. If an attempt is made to set MbeSettings. Example Dim oldClass as Integer oldClass = MbeSettings.. MbeSettings.colorName to a string that does not contain a valid color. The colorName on assignment can be a numeric string as well.colorName read/write property sets or retrieves the active color as a string.class = oldClass ' set class to construction ' restore old class See also MbeSettings.colorName MbeSettings. the active color is unchanged and MbeSettings.colorName = “Brown” .color to a number outside the range 0 . the string will contain the numeric value of the color on retrieval. MbeSettings.color MbeSettings.colorName. MbeSettings.. MbeSettings.settingErr is set to TRUE Example Dim oldColorName as String oldColorName = MbeSettings.class = MBE_ConstructionClass .colorName MbeSettings.color = oldColor ' set active color to 12 ' restore old color See also MbeSettings. The MbeSettings.color Descr.. MbeSettings. it is not set and MbeSettings... 8-70 MicroStation BASIC Guide . The MbeSettings. If an attempt is made to set MbeSettings..colorName Descr.255.color = 12 .settingErr is set to TRUE.class includes a discussion of the meanings of class values. MbeSettings.settingErr. MbeSettings.class MbeSettings. If the active color does not have a name.settingErr.color read/write property sets or retrieves the active color as an Integer.

fillColor Descr.settingErr.fillMode read/write property sets or retrieves the active fill mode as an Integer. the active color is used for the fill color. closed elements are not filled and fillColor is irrelevant.fillMode is set to 0. MbeSettings. If an attempt is made to set MbeSettings.fillMode Descr. Example ' set the current graphic group to the next available graphic group MbeSettings. MbeDgnInfo..currentGraphicGroup MbeSettings..nextGraphicGroup ' place elements that go into the graphic group . Dim oldFillColor as Integer Example oldFillColor = MbeSettings.fillColor is set to -1.settingErr. The active graphic group is the graphic group that MicroStation assigns to newly created elements.graphicGroup.currentGraphicGroup to a number outside the range 0 through 65535.currentGraphicGroup = MbeDgnInfo.currentGraphicGroup = 0 See also MbeSettings.currentGraphicGroup should be always be set to 0 when a macro exits. MbeSettings. The MbeSettings.fillColor read/write property sets or retrieves the active fill color as an Integer.fillMode is set to 0 to make unfilled closed elements and 1 to make filled elements. ' put current graphic group back to zero MbeSettings. it is unchanged and MbeSettings. The MbeSettings. MbeSettings. MbeSettings. MbeDgnInfo. If MbeSettings.fillColor MbeSettings.fillColor = 5 .settingErr is set to TRUE. The MbeSettings. it is not changed and MbeSettings.fillColor = oldFillColor ' set to fill elements with color 5 ' restore old fill color See also MbeSettings.settingErr is set to TRUE.fillMode MbeSettings..nextGraphicGroup.fillColor MbeSettings. MbeSettings..currentGraphicGroup read/write property sets or retrieves the active graphic group as a Long.fillmode to a number other than 0 or 1. Dim oldFillMode as Integer MicroStation BASIC Guide 8-71 8 MicroStation Extensions to BASIC . If an attempt is made to set MbeSettings.currentGraphicGroup Descr. MbeSettings. If MbeSettings.fillMode.Settings Object MbeSettings.

fontName to a font that cannot be found. MbeSettings..font to a number that is outside the range 0 to 255. If the an attempt is made to set MbeSettings.fillMode MbeSettings..settingErr is set to TRUE. MbeSettings.settingErr.fontName MbeSettings..font MbeSettings.fontName read/write property sets or retrieves the active font as a String. If an attempt is made to set MbeSettings. Example Dim oldFont as Integer oldFont = MbeSettings. The MbeSettings.settingErr.Settings Object Example oldFillMode = MbeSettings..font Descr. The MbeSettings. MbeSettings.fontName MbeSettings. the active font is unchanged and MbeSettings.fontName = oldFontName ' set active font ' restore old font See also MbeSettings. The MbeSettings. For example.gridReference is 12. MbeSettings. if MbeSettings.fontName Descr.gridReference Descr.gridReferences MbeSettings.font = oldFont ' set active font to 1 ' restore old font See also MbeSettings.gridReference read/write property sets or retrieves the number of grid points between grid reference crosses.fillMode = 1 ..settingErr. there is one reference grid cross drawn for every 8-72 MicroStation BASIC Guide .. Example Dim oldFontName as String oldFontName = MbeSettings.fillColor. the active font is unchanged and MbeSettings. MbeSettings.font MbeSettings. or there is no font with the specified number.settingErr is set to TRUE. MbeSettings.font = 1 . MbeSettings.font read/write property sets or retrieves the active font as an Integer.fontName = “Italics” .fillMode = oldFillMode ' set to fill elements ' restore old fillMode See also MbeSettings.

level read/write property sets or retrieves the active level as an Integer.. The MbeSettings.gridUnits = oldGridUnits See also MbeSettings. if MbeSettings. If an attempt is made to set MbeSettings.level MbeSettings.gridReference MbeSettings. the active level is unchanged and MbeSettings.gridUnits. the grid is redrawn in all views where it is turned on.. For example..gridReference = 12 ' grid crosses every 12 grid points .gridReferences. If an attempt is made to set MbeSettings.gridUnits to a value less than zero.gridUnits MbeSettings.0..gridUnits = 10. The MbeSettings. The property is of type Integer.0 ' set grids every 10 master units .level = oldLevel ' set active level to 20 ' restore old level See also MbeSettings. The property is a Double measured in master units (or the current units if the MbeCurrentTransform object methods have been used to change units). MbeSettings.gridUnits read/write property sets or retrieves the spacing between grid points. MbeSettings. MbeSettings. MicroStation Extensions to BASIC Descr. MbeSettings.gridUnits Example Dim oldGridUnits as Double oldGridUnits = MbeSettings. When it is changed. MicroStation BASIC Guide 8-73 8 Descr. the grid is redrawn in all views where it is turned on.gridUnits MbeSettings.gridReference = oldGridReference See also MbeSettings.level = 20 . there are 10 master units between grid points. Example Dim oldGridReference as Integer oldGridReference = MbeSettings.. .Settings Object 12 grid points.level MbeSettings.level to a value outside of the range 1 to 63.gridUnits is 10..settingErr is set to TRUE. it is unchanged and MbeSettings. When it is changed. MbeSettings.level Example Dim oldLevel as Integer oldLevel = MbeSettings.settingErr.settingErr is set to TRUE.

.lineStyleName MbeSettings.settingErr. MbeSettings.lineStyle.settingErr is set to TRUE and the active line style is unchanged. 8-74 MicroStation BASIC Guide .lineStyleName = oldLineStyleName ' restore old line style See also MbeSettings. MbeSettings.. if the line style name specified is not found.lineTerminator = “ARROW” ' set active lineTerminator .lineStyle to a value outside of the range 0 to 7. MbeSettings.settingErr. MbeSettings.lineStyleName Descr.Settings Object MbeSettings. MbeSettings.lineStyle MbeSettings.lineStyleName is used. the active line style is unchanged and MbeSettings.lineStyle read/write property sets or retrieves the active line style as an Integer.lineStyle Descr. On assignment. If an attempt is made to set MbeSettings.lineStyle = oldLineStyle ' set active line style to 3 ' restore old line style See also MbeSettings.lineStyleName MbeSettings.. MbeSettings.lineStyle MbeSettings. Example Dim oldLineStyle as Integer oldLineStyle = MbeSettings. MbeSettings.settingErr is set to TRUE.. MbeSettings.lineStyleName = “CENTER” ' set active line style to CENTER . The MbeSettings.lineTerminator Descr. The MbeSettings. MbeSettings. Example Dim oldLineTerminator as String oldLineTerminator = MbeSettings. For setting or retrieving custom line styles.lineTerminator MbeSettings.terminatorScale.settingErr. If an attempt is made to set MbeSettings..lineTerminator to a cell not found in any of the cell libraries in the search path. MbeSettings.lineTerminator read/write property sets or retrieves the active line terminator as a String.lineTerminator = oldLineTerminator ' restore old lineTerminator See also MbeSettings.lineStyle = 3 . The MbeSettings. the active line terminator is not changed and MbeSettings.settingErr is set to TRUE.lineTerminator MbeSettings.. Example Dim oldLineStyleName as String oldLineStyleName = MbeSettings.lineStyleName read/write property sets or retrieves the active line style name as a String.lineStyleName.

nodeJustification Descr.patternAngle1 . MbeSettings.settingErr.patternAngle1 MbeSettings.patternAngle1 = oldAngle ' restore old angle See also MbeSettings. MbeSettings.patternScale.Settings Object MbeSettings.nodeJustification MbeSettings. The MbeSettings..nodeJustification = oldNodeJustification ' restore old node just See also MbeSettings.settingErr is set to TRUE.. MbeSettings. MbeSettings.patternAngle2 read/write property retrieves or sets pattern angle 1 as a Double measured in radians. MbeSettings.justification.patternAngle2. The MbeSettings.patternAngle2 MbeSettings..nodeJustification MbeSettings. If an attempt is made to set the node justification to a value outside of the range 0 to 14.patternAngle2 Descr.patternAngle1 Descr.nodeJustification = MBE_CenterCenter .patternAngle2 MbeSettings.patternAngle1 = PI/4 ' set pattern angle 1 to 45 degrees ..textJustification. The MbeSettings. Example Dim oldAngle as Double oldAngle = MbeSettings. and MbeSettings. Pattern angle 1 is used as the rotation angle for the cells in patterning and for the angle of the hatch lines and the first set of crosshatch lines. MbeSettings.nodeJustification read/write property sets or retrieves the active text node justification as an Integer. Example Dim oldNodeJustification as Integer oldNodeJustification = MbeSettings.setPatternDelta.patternAngle1 read/write property retrieves or sets pattern angle 1 as a Double measured in radians. For a list of the defined constants for node justification. Pattern angle 2 is used as the angle of the second set of crosshatch lines Example Dim oldAngle as Double oldAngle = MbeSettings. it is not set. see the reference description of MbeElement. The text node justification is used to position multiline text elements relative to the user’s insertion point. MbeSettings.patternAngle2 = -PI/4 ' set pattern angle 2 to -45 degrees MicroStation BASIC Guide 8-75 8 MicroStation Extensions to BASIC MbeSettings.

MbeSettings.patternScale. stat = MbeSettings. the function groups the deltas together as type MbePoint. MbeSettings.patternCell MbeSettings. the active pattern cell is not changed and MbeSettings. The deltas. The MbeSettings.settingErr is set to TRUE.x = 2. 8-76 MicroStation BASIC Guide .setPatternDelta.getPatternDelta(oldDeltas) newDelta.patternDelta(deltas as MbePoint) Descr.patternCell Descr. MbeSettings.0 newDelta.patternAngle1.patternCell.patternScale.patternAngle1. For convenience.setPatternDelta MbeSettings. Example Dim oldDeltas as MbePoint Dim newDeltas as MbePoint stat = MbeSettings.patternAngle2. MbeSettings. It returns MBE_Success if the delta values are greater than zero. MbeSettings.setPatternDelta.patternAngle1.z value is not used and will always be set to zero. If an attempt is made to set MbeSettings.getPatternDelta object function sets the active pattern deltas.x value corresponds to the distance between pattern components in the x direction of a coordinate system rotated by MbeSettings.5 stat = MbeSettings...patternCell to a cell not found in any of the cell libraries in the search path.settingErr.patternAngle2 = oldAngle ' restore old angle See also MbeSettings. MbeSettings.setPatternDelta(oldDeltas) ' restore old deltas See also MbeSettings. MbeSettings.y corresponds to the distance between crosshatch lines in the other direction. The MbeSettings. MbeSettings.patternCell = “BRICK” . and the deltas. MbeSettings.patternAngle1. MbeSettings. and an error code otherwise. The deltas. Example Dim oldPatternCell as String oldPatternCell = MbeSettings.. MbeSettings.setPatternDelta.patternCell = oldPatternCell ' set pattern cell ' restore old pattern cell See also MbeSettings...patternCell read/write property sets or retrieves the active pattern cell as a String.getPatternDelta.patternScale.setPatternDelta(newDeltas) ..y = 1.patternCell MbeSettings. MbeSettings.Settings Object . MbeSettings. MbeSettings.

MbeSettings.000.patternScale to a value less than or equal to zero or greater than 100. It always returns MBE_Success.point MbeSettings.getPatternDelta(deltas as MbePoint) Descr. The property is a Double. the active point is not changed and MbeSettings. MbeSettings.settingErr.patternScale = oldPatternScale See also MbeSettings. For an example see MbeSettings.point read/write property sets or retrieves the active point cell as a String.patternAngle2. MbeSettings.point = “MANHOL” . The MbeSettings.settingErr.patternScale = 2. MbeSettings.getPatternDelta stat = MbeSettings. MbeSettings.patternScale MbeSettings.settingErr is set to TRUE.0 .patternScale read/write property sets or retrieves the pattern scale. The MbeSettings. MbeSettings.. MbeSettings.point Example Dim oldPointCell as String oldPointCell = MbeSettings. If an attempt is made to set MbeSettings.point = oldPointCell ' set active point ' restore old point cell See also MbeSettings.. the pattern scale is unchanged and MbeSettings. the function returns them grouped together as type MbePoint.point MbeSettings.setPatternDelta.patternCell. MbeSettings.patternScale Descr.getPatternDelta object function retrieves the active pattern deltas.patternScale MbeSettings. See also MbeSettings.Settings Object MbeSettings...setPatternDelta. so there is no point in checking the return value. For convenience.patternScale. If an attempt is made to set MbeSettings. MbeSettings. oldPatternScale = MbeSettings. MbeSettings. The MbeSettings.settingErr is set to TRUE.patternAngle1. MicroStation BASIC Guide 8-77 8 Descr.patternCell.patternAngle1. MicroStation Extensions to BASIC Example Dim oldPatternScale as Double . which is the scale factor used for cells in area and linear patterning.point to a cell not found in any of the cell libraries in the search path.

MbeSettings. the function returns them grouped together as type MbePoint.y = 1. The MbeSettings. stat = MbeSettings. If an attempt is made to set MbeSettings.tagIncrement MbeSettings. the active tag increment is unchanged MbeSettings.setScale object function sets the active scale. For convenience. The MbeSettings. MbeSettings.y the active scale in the y direction.x = 1.settingErr is set to TRUE. The tag increment is used in the Copy and Increment Text and Enter Data field commands.000. The MbeSettings.tagIncrement read/write property sets or retrieves the active tag increment as an Integer.5 newScale.tagIncrement = oldIncrement ' set tag increment to 2 ' restore old tag increment See also MbeSettings.z the active scale in the z direction.. and scale.tagIncrement to a value outside of the range 1 to 1000.settingErr.setScale(oldScale) ' restore old scale See also MbeSettings.setScale(scale as MbePoint) Descr..getScale object function retrieves the scales. the function fails and returns an error code of 1 or otherwise MBE_SUCCESS.x value corresponds to the active scale in the x direction. It always returns MBE_Success.getScale(scale as MbePoint) Descr.setScale.z = 1.setScale(oldScale) newScale. MbeSettings. Example Dim oldScale as MbePoint Dim newScale as MbePoint stat = MbeSettings.setScale MbeSettings. See also MbeSettings.tagIncrement MbeSettings. If an attempt is made to set any of the three scale factors to a value less than or equal to zero or greater than 100.tagIncrement = 2 .5 stat = MbeSettings.5 newScale. Example Dim oldIncrement as Integer oldIncrement = MbeSettings.getScale stat = MbeSettings. 8-78 MicroStation BASIC Guide . For convenience. scale.setScale(newScale) .setScale. The scale.Settings Object MbeSettings..tagIncrement Descr.. the function groups the scale factors together as type MbePoint.

textWidth MbeSettings.terminatorScale MbeSettings.settingErr is set to TRUE.textHeight. If an attempt is made to set it too large. MbeSettings.terminatorScale MbeSettings. The MbeSettings.settingErr. Example Dim oldTextWidth as Double oldTextWidth = MbeSettings.terminatorScale Descr.settingErr is set to TRUE.textWidth MicroStation Extensions to BASIC MbeSettings. MbeSettings. Example Dim oldTextHeight as Double oldTextHeight = MbeSettings.terminatorScale read/write property sets or retrieves the active line terminator scale as a Double.textWidth = 0...Settings Object MbeSettings.20 .textHeight Descr.terminatorScale = 0. The MbeSettings.. If an attempt is made to set MbeSettings. the terminator scale is unchanged and MbeSettings.terminatorScale = oldTerminatorScale ' set line terminator ' restore previous value See also MbeSettings. The property is a Double measured in master units (or the current units if the MbeCurrentTransform object methods have been used to change units).settingErr.textWidth.textHeight = oldTextHeight See also MbeSettings. it is not set.settingErr is set to TRUE..settingErr. MbeSettings.textWidth read/write property sets or retrieves the active text width. MbeSettings. If an attempt is made to set it too large. The MbeSettings.textWidth = oldTextWidth See also MbeSettings.5 scale . and MbeSettings.lineTerminator. and MbeSettings. MbeSettings.textHeight . MbeSettings.terminatorScale to a value less than or equal to zero or greater than 100.. it is not set.textHeight read/write property sets or retrieves the active text height. The property is a Double measured in master units (or the current units if the MbeCurrentTransform object methods have been used to change units). MicroStation BASIC Guide 8-79 8 MbeSettings.25 .000.textHeight = 0. MbeSettings. MbeSettings.. Example Dim oldTerminatorScale as Double oldTerminatorScale = MbeSettings.textWidth Descr.textHeight MbeSettings.

This is the spacing between lines in a text node created by entering multiline text.textJustification to a value other than 0. 7.textLineLength = oldlineLength See also MbeSettings. it is not set. Example Dim oldLineLength as Integer oldLineLength = MbeSettings.. The text line length is used to determine where to automatically “wrap” text in the place text command.settingErr is set to TRUE.settingErr. MbeSettings. The MbeSettings.Settings Object MbeSettings. the active text line length is unchanged and MbeSettings.. The MbeSettings.textLineLength = 80 ' set for 80 column text lines .textLineLength. The property is a Double measured in master units (or the current units if the MbeCurrentTransform object methods have been used to change units). For 8-80 MicroStation BASIC Guide . MbeSettings.textLineSpacing = oldTextSpacing See also MbeSettings.textJustification read/write property sets or retrieves the active text justification as an Integer. MbeSettings. Example Dim oldTextSpacing as Double oldTextSpacing = MbeSettings. 6.textLineSpacing MbeSettings.settingErr is set to TRUE.textLineLength read/write property sets or retrieves the active text line length as an Integer. 1.. The MbeSettings. If an attempt is made to set MbeSettings.textLineLength MbeSettings. The text justification is used to position single line text elements relative to the user’s insertion point. MbeSettings.. If an attempt is made to set the text spacing less than or equal to zero or too large.textLineSpacing Descr. 8. 13 or 14.textJustification Descr.settingErr is set to TRUE. MbeSettings.textLineSpacing MbeSettings. If an attempt is made to set MbeSettings.textLineLength to a value outside of the range 1 to 255.textLineLength MbeSettings.textLineSpacing read/write property sets or retrieves the active text line spacing. and MbeSettings. the active text justification is unchanged.textLineLength Descr. 12. and MbeSettings.15 .textJustification MbeSettings.2.settingErr.textLineSpacing = 0.

Example Dim oldTextJustification as Integer oldTextJustification = MbeSettings.associationLock MbeSettings. the active line weight is unchanged.. MbeSettings. If an attempt is made to set MbeSettings.associationLock = 0 ' turn off association lock .textJustification = MBE_LeftTop . The MbeSettings. and MbeSettings. MbeSettings.associationLock Descr.settingErr. and setting it to zero turns association lock off.weight Descr.justification.weight to a value outside of the range 0 to 31. The MbeSettings.associationLock MbeSettings.textJustification = oldTextJustification See also MbeSettings.textJustification MbeSettings.weight MbeSettings.associationLock read/write property sets or retrieves the association lock as an Integer.weight read/write property sets or retrieves the active line weight as an Integer. see the reference description of MbeElement.associationLock = oldAssociationLock MicroStation BASIC Guide 8-81 8 MicroStation Extensions to BASIC oldLineWeight = MbeSettings. Example Dim oldAssociationLock as Integer oldAssociationLock = MbeSettings. Setting MbeSettings. MbeSettings..settingErr. MbeSettings..Settings Object a list of the defined constants for text justification.weight MbeSettings. MbeSettings.. Example Dim oldLineWeight as Integer ' set active weight to 1 ' restore old weight See also MbeSettings.nodeJustification. MbeSettings..weight = oldLineWeight .settingErr is set to TRUE.associationLock to any non-zero value turns association lock on.weight = 1 ..

. and setting it to zero turns boresite lock off.axisLock read/write property sets or retrieves the axis lock as an Integer.. MbeSettings.axisAngle.cellStretchLock to any nonzero value turns cell stretch lock on. The MbeSettings..boresiteLock = 1 . and setting it to zero turns axis lock off. MbeSettings.axisLock to any nonzero value turns axis lock on. and setting it to zero turns it off. which affects the behavior of cells straddling a fence when the Fence Stretch command is used.axisLock Descr. MbeSettings. Example Dim oldCellStretchLock as Integer oldCellStretchLock = MbeSettings. MbeSettings.axisLock MbeSettings.axisLock MbeSettings. Setting MbeSettings.cellStretchLock Descr. Setting MbeSettings.cellStretchLock = 1 ' turn on cell stretch lock .boresiteLock read/write property sets or retrieves the boresite lock as an Integer. The MbeSettings.. Setting MbeSettings. Example Dim oldBoresiteLock as Integer oldBoresiteLock = MbeSettings.cellStretchLock MbeSettings.boresiteLock = oldBoresiteLock ' turn on boresite lock ' restore boresite lock MbeSettings.boresiteLock to any nonzero value turns boresite lock on.cellStretchLock MbeSettings.axisLock = oldAxisLock ' turn on axis lock ' restore axis lock See also MbeSettings.boresiteLock Descr..axisOrigin. The MbeSettings.cellStretchLock read/write property sets or retrieves the cell stretch lock.Settings Object MbeSettings.axisLock = 1 .boresiteLock MbeSettings. MbeSettings.cellStretchLock = oldCellStretchLock 8-82 MicroStation BASIC Guide . Example Dim oldAxisLock as Integer oldAxisLock = MbeSettings.boresiteLock MbeSettings..

constructionPlaneLock = 1 ' turn on ConstructionPlane lock . and setting it to zero turns depth lock off.depthLock = 1 .graphGroupLock to any nonzero value turns it on.graphGroupLock = oldGroupLock ' turn off graphic group lock ' restore graphic group lock MicroStation BASIC Guide 8-83 8 MicroStation Extensions to BASIC Descr. Setting MbeSettings.graphGroupLock MbeSettings. MbeSettings.constructionPlaneLock read/write property sets or retrieves the construction plane lock as an Integer.Settings Object MbeSettings..depthLock = oldDepthLock ' turn on depth lock ' restore depth lock MbeSettings. .graphgroupLock = 0 . If depth lock is off.graphGroupLock Descr.constructionPlaneLock MbeSettings. When depth lock is on and the user snaps to an element in a 3D file.ConstructionPlaneLock Descr. The MbeSettings.. and setting it to zero turns graphic group lock off.depthLock read/write property sets or retrieves the depth lock as an Integer. the input data point is the point on the element that was snapped to. the input data point is projected onto the active depth for the input view before it is processed. The MbeSettings. Setting MbeSettings. Example Dim oldPlaneLock as Integer oldPlaneLock = MbeSettings.graphGroupLock MbeSettings. and setting it to zero turns it off..ConstructionPlaneLock to any nonzero value turns the lock on. The MbeSettings.depthLock MbeSettings.depthLock to any nonzero value turns it on.depthLock MbeSettings.depthLock Example Dim oldDepthLock as Integer oldDepthLock = MbeSettings..constructionPlaneLock = oldPlaneLock MbeSettings. Example Dim oldGroupLock as Integer oldGroupLock = MbeSettings.ConstructionPlaneLock MbeSettings.graphGroupLock read/write property sets or retrieves the graphic group lock as an Integer. Setting MbeSettings. MbeSettings.. MbeSettings..

fenceOverlap = 1 . and setting it to zero turns fence clipping off.gridUnits.fenceOverlap Descr.fenceClip read/write property sets or retrieves the fence clip lock as an Integer.fenceOverlap to any nonzero value causes fences to process any graphic elements that overlap the fence. the setting of MbeSettings.fenceClip Descr.fenceClip is TRUE. MbeSettings. MbeSettings.fenceVoid. while setting it to zero causes fences to process only graphic elements that are completely inside the fence.fenceOverlap.fenceOverlap read/write property sets or retrieves the fence overlap lock as an Integer. MbeSettings.fenceVoid.gridLock MbeSettings.gridLock read/write property sets or retrieves the grid lock as an Integer.gridLock = 1 . When MbeSettings.fenceClip MbeSettings..fenceOverlap MbeSettings.fenceVoid is TRUE and MbeSettings. MbeSettings. all graphics elements except those completely within the fence are processed.Settings Object MbeSettings.fenceClip = oldFenceClip ' turn on fence clipping ' restore fence clipping See also MbeSettings. MbeSettings... 8-84 MicroStation BASIC Guide . The MbeSettings.gridLock Descr. and setting it to zero turns grid lock off.fenceClip.fenceOverlap = oldFenceOverlap ' turn on fence overlap ' restore fence overlap See also MbeSettings.fenceClip to any nonzero value turns fence clipping on. Setting MbeSettings. Example Dim oldFenceClip as Integer oldFenceClip = MbeSettings. The MbeSettings. Setting MbeSettings.gridLock to any nonzero value turns grid lock on.fenceOverlap MbeSettings. MbeSettings. Setting MbeSettings.gridReferences. MbeSettings. Example Dim oldFenceOverlap as Integer oldFenceOverlap = MbeSettings. When MbeSettings. The MbeSettings.fenceClip MbeSettings.. Example Dim oldGridLock as Integer oldGridLock = MbeSettings. MbeSettings.fenceClip = 1 .gridLock MbeSettings..gridLock = oldGridLock ' turn on grid lock ' restore grid lock See also MbeSettings..fenceOverlap is irrelevant.fenceOverlap is FALSE.

Example Dim oldFenceVoid as Integer oldFenceVoid = MbeSettings.levelLock = 1 .. .fenceVoid MbeSettings. the user can locate for manipulation only elements on the active level.levelLock = oldLevelLock ' turn on level lock ' restore it MbeSettings.fenceVoid to any nonzero value causes fence commands to process graphic elements outside the fence. The MbeSettings.fenceVoid = 1 . while setting it to zero causes fence commands to process graphics element inside the fence.levelLock Example Dim oldLevelLock as Integer oldLevelLock = MbeSettings. and setting it to zero turns it off.selectionSetLock = oldSetLock MicroStation BASIC Guide 8-85 8 MicroStation Extensions to BASIC Descr. Setting MbeSettings.selectionSetLock = 0 ' turn off selection set lock .levelLock MbeSettings. The MbeSettings. MbeSettings..selectionSetLock MbeSettings.selectionSetLock MbeSettings. MbeSettings.fenceVoid Descr.the user must locate elements for modification interactively.fenceVoid MbeSettings.fenceVoid read/write property sets or retrieves the fence void lock as an Integer. MbeSettings.levelLock MbeSettings.fenceClip.. When level lock is on..fenceVoid = oldFenceVoid ' process elements outside fence ' restore fence void mode See also MbeSettings.selectionSetLock Descr. Example Dim oldSetLock as Integer oldSetLock = MbeSettings. MbeSettings.selectionSetLock to any nonzero value turns it on. The MbeSettings.. Setting MbeSettings. When selection set lock is off.selectionSetLock read/write property sets or retrieves the selection set lock as an Integer. Setting MbeSettings.Settings Object MbeSettings..levelLock to any nonzero value turns it on. and setting it to zero turns level lock off.fenceOverlap. MbeSettings.levelLock read/write property sets or retrieves the level lock as an Integer. MicroStation commands will not operate on selection sets .

The MbeSettings..snapLock = oldSnapLock ' turn on snap lock ' restore snap lock MbeSettings.settingErr read-only property reveals whether or not the last attempt to retrieve or set one of the MbeSettings properties was successful or not. When text node lock is on.. Example Dim oldNodeLock as Integer oldNodeLock = MbeSettings. Example Function setLevelFunc(userSpecifiedLevel as Integer) ' userSpecifiedLevel obtained from user keyin ' Don’t know whether it is valid or not MbeSettings.settingErr <> MBE_Success Then Call MbeWriteError(“Level out of range . Example Dim oldSnapLock as Integer oldSnapLock = MbeSettings..TextNodeLock MbeSettings.settingErr Descr. MbeSettings. it must be checked after the statement that retrieves or sets the property but before another MbeSettings property is accessed. and setting it to zero turns it off.textNodeLock = 1 ' turn on text node lock .textNodeLock to any nonzero value turns text node lock on.level = userSpecifiedLevel If MbeSettings.Settings Object MbeSettings. and setting it to zero turns snap lock off.textNodeLock read/write property sets or retrieves the text node lock as an Integer.. Setting MbeSettings.snapLock read/write property sets or retrieves the snap lock as an Integer. The MbeSettings.settingErr MbeSettings. The MbeSettings. Since MbeSettings. text can only be placed by attaching it to an existing text node.snapLock to any nonzero value turns snap lock on.settingErr is set for each property retrieval or assignment.textNodeLock Descr.reenter”) setLevelFunc = 1 Else setLevelFunc = 0 ' acceptable level End If End Function 8-86 MicroStation BASIC Guide .snapLock MbeSettings.snapLock = 1 . Setting MbeSettings.snapLock MbeSettings.snapLock Descr. MbeSettings.textNodeLock = oldNodeLock MbeSettings.textNodeLock MbeSettings.

Retrieve and reserve the next available graphic group number.graphicGroup (page 8-90) MbeDgnInfo. The MbeDgnInfo. Retrieve the global origin of the design file.dgnFileName Descr.cellFileReadOnly (page 8-92) Used To Return the full file name of the current design file.dgnFileName MicroStation Extensions to BASIC Set or retrieve the number of sub-units per master unit in the current design file.dgnFileReadOnly (page 8-88) MbeDgnInfo. Example Dim designFile as String designFile = MbeDgnInfo. MbeDgnInfo. Determine if the attached cell library is a read-only file. Set or retrieve the name of the sub units used by the current design file. Determine if the attached cell library is 3D.getGlobalOrigin (page 8-90) MbeDgnInfo.subUnitName (page 8-89) MbeDgnInfo.dgnFileName read-only String property returns absolute pathname of the currently active design file.dgn3D (page 8-88) MbeDgnInfo.nextGraphicGroup (page 8-91) MbeDgnInfo.subPerMaster (page 8-90) MbeDgnInfo.dgnFileName MicroStation BASIC Guide 8-87 8 MbeDgnInfo.endOfFile (page 8-88) MbeDgnInfo.cell3D (page 8-91) MbeDgnInfo.cellFileName (page 8-91) MbeDgnInfo.masterUnitName (page 8-88) MbeDgnInfo. Determine if the current design file is opened for readonly access.Design File Information Object Design File Information Object Properties and Methods MbeDgnInfo. Return the file position of the end of file marker in the current design file. . Determine if the current design file is 3D. Retrieve the graphic group number that will be used the next time a graphic group is created. Return the full file name of the cell library attached to the attached design file. Set or retrieve the number of units of resolution (UORs) per sub unit in the current design file.uorPerSub (page 8-89) MbeDgnInfo. Set or retrieve the name of the master units used by the current design file.dgnFileName (page 8-87) MbeDgnInfo.

dgnFileReadOnly = 0 Then Call MbeSendCommand(“PLACE LINE”) Else Call MbeWriteError(“Cannot perform operation on Read-only design file”) End If MbeDgnInfo.0.0.dgn3D Descr.0.dgnFileReadOnly MbeDgnInfo. 1) Call MbeSendDataPoint(10. 0. 10. The MbeDgnInfo. The MbeDgnInfo. The master unit name is an abbreviation limited to two characters.masterUnitName MbeDgnInfo.endOfFile MbeSendCommand “Place line” Call MbeSendDataPoint(0.0. 0. The MbeDgnInfo. Although this String property can be set. 10.endOfFile Descr.0.0. Example If MbeDgnInfo..Design File Information Object MbeDgnInfo.dgnFileReadOnly read-only Integer property returns 1 if the currently active design file is opened for read-only access and 0 if it is writable.dgn3D MbeDgnInfo. ' Process element just created here End If MbeDgnInfo. Example If MbeDgnInfo.masterUnitName read/write property sets or retrieves the master unit name of the currently active design file.dgn3D read-only Integer property returns 1 if the currently active design file is 3D and 0 if it is 2D.endOfFile read-only Long property returns the file position of the end of file marker in the active design file.endOfFile MbeDgnInfo.masterUnitName Descr. 1) If newElem..dgnFileReadOnly Descr. it is not 8-88 MicroStation BASIC Guide .fromFile(endOfFilePos) == MBE_Success Then . Example Dim endOfFilePos as Long Dim newElem as New MbeElement endOfFilePos = MbeDgnInfo. The MbeDgnInfo.dgn3D <> 0 Then Call MbeSendCommand(“PLACE CONE”) Else Call MbeWriteError(“Operation valid for 3D file only”) End If MbeDgnInfo.

subUnitName = oldUnitName MbeDgnInfo.masterUnitName to a string longer than two characters. The property is a Long. a run-time error MBE_StringTooLong (1401) is generated.Design File Information Object recommended. The sub unit name is an abbreviation limited to two characters..subUnitName MbeDgnInfo.uorPerSub MbeDgnInfo. it is seldom necessary for a BASIC program to access MbeDgnInfo. The MbeDgnInfo.uorPerSub = oldUorPerSub MicroStation BASIC Guide 8-89 8 MicroStation Extensions to BASIC .uorPerSub MbeDgnInfo. and even more seldom necessary for a BASIC program to change it. The MbeDgnInfo. it is not recommended..uorPerSub Descr.subUnitName Descr.uorPerSub = oldUorPerSub / 2 . MbeDgnInfo. MbeDgnInfo. it is not recommended.subUnitName to a string longer than two characters.masterUnitName = “ft” .. since changing its value indiscriminately resizes every graphics element in the design file.subUnitName MbeDgnInfo.uorPerSub. Example Dim oldUnitName as String oldUnitName = MbeDgnInfo.subUnitName = “in” . Although this property can be set.. If an attempt is made to set MbeDgnInfos.masterUnitName MbeDgnInfo.. Although this String property can be set.subUnitName read/write property sets or retrieves the sub unit name of the currently active design file. a run-time error MBE_StringTooLong (1401) is generated. If an attempt is made to set MbeDgnInfo. Since coordinates that are passed to and from MicroStation BASIC extensions are (by default) in design file master units. MbeDgnInfo..uorPerSub read/write property sets or retrieves the number of units of resolution (or positional units) per subunit. Example Dim oldUnitName as String oldUnitName = MbeDgnInfo.masterUnitName = oldUnitName MbeDgnInfo. Example Dim oldUorPerSub as Long oldUorPerSub = MbeDgnInfo.

getGlobalOrigin object function retrieves the global origin of the design file. The property is a Long. The MbeDgnInfo.subPerMaster Descr.subUnitName. in a state plane coordinate system).graphicGroup read-only Long property retrieves the next graphic group number that will be assigned to a graphic group when a MicroStation command that creates a graphics group is executed (e.getGlobalOrigin(globalOrg as MbePoint) Descr. The global origin is an offset that is applied to the position of every graphics element in the design file.. A macro must use the ACTIVE ORIGIN MicroStation command to change the global origin. Example Dim graphGroup as Long graphGroup = MbeDgnInfo. it is not recommended. GROUP ADD). Since coordinates that are passed to and from MicroStation BASIC extensions are (by default) in design file master units. it is seldom necessary for a BASIC program to access MbeDgnInfo.Design File Information Object MbeDgnInfo.g.subPerMaster = oldSubPerMaster * 2 .subPerMaster MbeDgnInfo. Example Dim oldSubPerMaster as Long oldSubPerMaster = MbeDgnInfo. MbeDgnInfo. 8-90 MicroStation BASIC Guide .. MbeDgnInfo. MbeSettings.graphicGroup MbeDgnInfo. The MbeDgnInfo.graphicGroup Descr. The MbeDgnInfo. Although this property can be set.getGlobalOrigin(globalOrg) MbeDgnInfo. They are interdependent and should not be set without a thorough consideration of the effect of the changes.subPerMaster change the size or meaning of the design file untis. since changing its value indiscriminately resizes every graphics element in the design file.getGlobalOrigin stat = MbeDgnInfo. MbeDgnInfo.currentGraphicGroup..uorPerSub and MbeDgnInfo. It is typically used to set the position of the design file in a larger plane (for example.getGlobalOrigin object function always returns MBE_Success. MbeDgnInfo.subPerMaster.subPerMaster read/write property sets or retrieves the number of subunits per master unit.masterUnitName. and even more seldom necessary for a BASIC program to change it.subPerMaster = oldSubPerMaster ✍ The four properties MbeDgnInfo. The MbeDgnInfo.subPerMaster MbeDgnInfo.graphGroup See also MbeDgnInfo.nextGraphicGroup. Example Dim globalOrg as MbePoint stat = MbeDgnInfo.

graphicGroup or MbeDgnInfo. so that the next graphic group retrieved using MbeDgnInfo. ' set the current graphic group to the next available graphic group MbeSettings. The MbeDgnInfo. Call MbeSendCommand(“CREATE CELL NEWCELL”) Else Call MbeWriteError(“Cannot create cell: 2D library / 3D file”) End If MicroStation BASIC Guide 8-91 8 Example If MbeDgnInfo.cellFileName read-only String property returns the absolute pathname of the currently attached cell library.nextGraphicGroup Descr.currentGraphicGroup = 0 See also MbeDgnInfo. The MbeDgnInfo. The MbeDgnInfo. A typical use of MbeDgnInfo. To reserve the graphic group.currentGraphicGroup. ' put current graphic group back to zero MbeSettings..dgn3D <> 0 And MbeDgnInfo.cellFileName MbeDgnInfo.Design File Information Object MbeDgnInfo.nextGraphicGroup will be one higher..cellFileName MbeDgnInfo.currentGraphicGroup = MbeDgnInfo.cell3D MbeDgnInfo. it increments the internal counter.cellFileName Descr.cell3D read-only Integer property returns 1 if the currently attached cell library is 3D and 0 if it is 2D.graphicGroup. MbeSettings.cell3D Descr.currentGraphicGroup.cell3D <> 0 Then MicroStation Extensions to BASIC .nextGraphicGroup MbeDgnInfo.nextGraphicGroup ' place elements that go into the graphic group . It differs from MbeDgnInfo.nextGraphicGroup is to get a graphic group number to use with MbeSettings. Example Dim cellFile as String cellFile = MbeDgnInfo.nextGraphicGroup read-only Long property retrieves the next graphic group number that will be assigned to a graphic group.graphicGroup in that it reserves the graphic group number that is returned for the macro’s exclusive use. MbeDgnInfo.

Example If MbeDgnInfo.cellFileReadOnly = 0 Then Call MbeSendCommand(“CREATE CELL”) Else Call MbeWriteError(“Cannot create cell: library read only”) End If 8-92 MicroStation BASIC Guide .cellFileReadOnly MbeDgnInfo.cellFileReadOnly read-only Integer property returns 1 if the currently attached cell library is opened for read-only access and 0 if it is writable.cellFileReadOnly Descr. The MbeDgnInfo.Design File Information Object MbeDgnInfo.

If the macro changes the coordinate system using one of the other MbeCurrentTransform methods.masterUnits MbeCurrentTransform.pointFromUors (page 8-98) Used to Initialize the macro’s coordinate transform to reflect master unit coordinates of the design file. Translate the origin of the macro’s coordinate system in terms of the current coordinate system.scalarFromUors (page 8-98) MbeCurrentTransform.masterUnits (page 8-93) MbeCurrentTransform.moveOrigin (page 8-96) MbeCurrentTransform.rotate (page 8-96) MbeCurrentTransform. Initialize the macro’s coordinate transform to reflect design file units (UORs).masterUnits Descr. it has no need of this (or any other) MbeCurrentTransform method. so if a macro simply wants to use master units.moveOriginWorld (page 8-96) MbeCurrentTransform. This is the default coordinate transform when a macro is started. The MbeCurrentTransform.pointToUors (page 8-98) MbeCurrentTransform.scale (page 8-97) MbeCurrentTransform.masterUnits is very useful for going back to the default MicroStation BASIC Guide 8-93 8 MicroStation Extensions to BASIC .scalarToUors (page 8-97) MbeCurrentTransform. Scale a value that is relative to the macro’s current coordinate system into the design file coordinate system (UORs). Translate the origin of the macro’s coordinate system in terms of design file coordinates (UORs).fromView (page 8-97) MbeCurrentTransform. Match the macro’s coordinate system to that of a specific view. MbeCurrentTransform. Transform a point specified in the macro’s current coordinate system to the design file coordinate system.dgnUnits (page 8-95) MbeCurrentTransform. Rotate the macro’s coordinate system about its origin. Transform a point specified in the design file coordinate system to the macro’s current coordinate system. MbeCurrentTransform. however.Current Transformation Object Current Transformation Object Properties and Methods MbeCurrentTransform.masterUnits object method initializes the macro’s coordinate transform such that all geometric properties it retrieves or sets are in the master unit coordinates of the design file. Scale the macro’s coordinate system. Scale a value that is relative to the macro’s current coordinate system into the design file coordinate system (UORs).

view) point.inputType = MBE_ResetInput Then Exit Sub ElseIf MbeState.getInputDataPoint(origin. MBE_ResetInput) ' reset aborts. data point gives upper left corner If MbeState.y = origin. view) point. view) point.pointToUors uorPoint 8-94 MicroStation BASIC Guide . view) point.inputType = MBE_DataPointInput Then stat = MbeState.entry point '--------------------------------------------------------------Sub Main Dim origin as MbePoint Dim moveDist as MbePoint Dim uorPoint as MbePoint Dim view as Integer Dim saveLocTol as Integer ' set locate tolerance to 0 so PLACE SHAPE works at any zoom level saveLocTol = MbeState.x + totalWidth Call MbeSendDataPoint(point.totalHeight Call MbeSendDataPoint(point.x Call MbeSendDataPoint(point.locateTolerance MbeState.y = origin. use Uors uorPoint = origin MbeCurrentTransform. totalHeight as Double) Dim point as MbePoint point = origin Call MbeSendCommand("PLACE SHAPE") Call MbeSendDataPoint (origin.locateTolerance = 0 Call MbeSendCommand("NULL") Call MbeWritePrompt("Enter Center Point") ' wait for data or reset Call MbeGetInput(MBE_DataPointInput . view) End Sub '--------------------------------------------------------------' Main .x = origin.x = origin. view) End If ' we need the origin point in a fixed coordinate system. _ totalWidth as Double. view as Integer. The following example illustrates many of the MbeCurrentTransform object methods: Example ' Example of using MbeCurrentTransform object '--------------------------------------------------------------' DrawShape '--------------------------------------------------------------Sub DrawShape(origin as MbePoint.y Call MbeSendDataPoint(point.Current Transformation Object coordinate system.y .

MbeCurrentTransform. MbeCurrentTransform..0.masterUnits End Sub See also MbeCurrentTransform.dgnUnits MbeCurrentTransform.dgnUnits.0 For iCol = 1 to 4 For iPat = 1 To 8 Call DrawShape(origin.1 Next iCol MbeState.0.moveOrigin moveDist MbeCurrentTransform. but if we had more to do we'd have to) MbeCurrentTransform.z = 0.0 : moveDist. view. MbeCurrentTransform. also known as Units Of Resolution (UOR). ' some manipulations in UORs MbeCurrentTransform.scalarToUors. but transforming points to and from the design file coordinate system is convenient because it functions as a convenient fixed coordinate system in which to store points when changing the coordinate system using one of the MbeCurrentTransform object methods.scale 1..y = 0 : origin. ' back to master units.masterUnits. MicroStation BASIC Guide 8-95 8 MicroStation Extensions to BASIC .x = 0 : origin.dgnUnits to work in UORs.rotate PI/4 Next iPat MbeCurrentTransform.0 : moveDist.masterUnits .x = 12.dgnUnits Descr.y = 0.fromView view ' set coordinate system origin to the input point MbeCurrentTransform.dgnUnits object method initializes the macro’s coordinate transform such that all geometric properties it retrieves or sets are in the design file units. Example MbeCurrentTransform.z = 0 moveDist.0 since we set up our coordinate system origin. See also MbeCurrentTransform. 2.locateTolerance = saveLocTol ' return to master units (don't really have to do this here ' since we're done.. It is rare that a macro finds it convenient to use MbeCurrentTransform. 5.pointFromUors.moveOriginWorld uorPoint ' set origin to 0.Current Transformation Object ' set up current transform from the view the data point was in MbeCurrentTransform.0) MbeCurrentTransform. The MbeCurrentTransform..dgnUnits .

moveOriginWorld MbeCurrentTransform. See also MbeCurrentTransform. rotateY and rotateX are optional and specify rotation about the Y and Z axes. a point can be converted to design coordinates (using MbeCurrentTransform. when you have set the coordinate system to align with a view and want to move the origin in the view coordinate system) and sometimes it is a disadvantage. For an example see MbeCurrentTransform..moveOrigin moveDistance as MbePoint Descr.masterUnits. moveDistance specifies distances in the design file coordinate system..pointToUors.moveOrigin object method moves the origin of the coordinate system by changing the MbeCurrentTransform appropriately. rotateZ is required and represents the rotation about the current Z axis. rotateY as Double[. Specifying the distances in the design file coordinate system is an advantage when you have a specific point to which you want to move the origin (i.rotate object method rotates the coordinate system about its current origin. Sometimes specifying the distance in the current coordinate system is advantageous (i. The MbeCurrentTransform.e. 8-96 MicroStation BASIC Guide .Current Transformation Object MbeCurrentTransform. For an example see MbeCurrentTransform. The MbeCurrentTransform.moveOrigin MbeCurrentTransform.pointToUors) and saved. rotateX as Double]] Descr. the MbeCurrentTransform.moveOriginWorld object method moves the origin of the coordinate system by changing the MbeCurrentTransform appropriately. For an example see MbeCurrentTransform.masterUnits. The MbeCurrentTransform. moveDistance specifies distances in the current coordinate system. to yield the same physical point.rotate MbeCurrentTransform.fromView.moveOrigin. Since the design file coordinate system does not change when the MbeCurrentTransform object methods are invoked. the MbeCurrentTransform methods can be used to change the coordinate system.moveOriginWorld object method is provided.moveOriginWorld moveDistance as MbePoint Descr. See also MbeCurrentTransform.rotate _ rotateZ as Double[. and the saved point converted back to the new coordinate system. MbeCurrentTransform. MbeCurrentTransform.e. See also MbeCurrentTransform.moveOriginWorld. respectively. MbeCurrentTransform. the coordinate system rotates only about the Z axis. If they are not specified. For the latter situation. which takes distances specified in the (unchanging) design file coordinate system. when you want to move it to a user’s input point after having rotated the coordinate system or matched it to a view).masterUnits.

See Appendix A for more information on OLE Automation. scaleY and scaleZ. The MbeCurrentTransform. The optional scaleY and scaleZ arguments are seldom used. The MbeCurrentTransform. See also For an example see MbeCurrentTransform.masterUnits. Example Dim axis as Double .scale object method scales the coordinate system according to scaleX. See also MbeCurrentTransform. MicroStation BASIC Guide 8-97 8 MicroStation Extensions to BASIC In Visual Basic.scalarToUors object method scales the Double specified in the value argument by the conversion factor from the current coordinate system to design coordinates (UORs). ' use axis in UOR’s for some calculation See also MbeCurrentTransform.scalarToUors MbeCurrentTransform. the method name scaleTrans must be used instead of scale.. For an example see MbeCurrentTransform. After the statement. scaleY as Double[. scaleZ as Double]] Descr. the X and Y axes of the macro’s coordinate system align with horizontal and vertical in the view.rotate..masterUnits. . MbeCurrentTransform.primaryAxis MbeCurrentTransform..scale MbeCurrentTransform. the coordinate system is scaled in each direction by scaleX. MbeCurrentTransform.. ' get an arc or ellipse element distance = element. which is the recommended practice.scalarToUors value as Double Descr. since if they are omitted.scalarToUors axis .scalarFromUors.Current Transformation Object MbeCurrentTransform.scale _ scaleX as Double[. "Appendix A".fromView view as Integer Descr. The MbeCurrentTransform.fromView object method matches the rotation of the current coordinate transformation to that of the specified view.fromView MbeCurrentTransform.

pointFromUors origin ' get point into new coord system See also MbeCurrentTransform.pointToUors point as MbePoint Descr. Example Dim result as Double . The MbeCurrentTransform.measureResult1 MbeCurrentTransform.pointFromUors object method transforms the MbePoint specified by point from design coordinates (UORs) to the current coordinate system. For an example see MbeCurrentTransform. ' result now scaled for use in our macro.pointFromUors point as MbePoint Descr.pointFromUors.masterUnits.pointToUors object method transforms the MbePoint specified by point from the current coordinate system to design coordinates (UORs).getInputDataPoint(origin... Example Dim origin as MbePoint Dim view as Integer .scalarToUors. MbeCurrentTransform.pointToUors MbeCurrentTransform. 8-98 MicroStation BASIC Guide . ' get origin and view from the user If MbeState.fromView view ' change to view coordinate system MbeCurrentTransform. See also MbeCurrentTransform.scalarFromUors object method scales the Double specified by value by the conversion factor from design coordinates (UORs) to the current coordinate system.pointFromUors. view) MbeCurrentTransform.Current Transformation Object MbeCurrentTransform.pointToUors origin ' get point into dgn units MbeCurrentTransform..scalarFromUors MbeCurrentTransform.scalarFromUors result . MbeCurrentTransform... See also MbeCurrentTransform.scalarFromUors value as Double Descr. ' sequence measure distance command result = MbeState. The MbeCurrentTransform. MbeCurrentTransform.moveOriginWorld.pointFromUors MbeCurrentTransform.. The MbeCurrentTransform.

Set or retrieve whether elements of the pattern class are displayed in the view. Set or retrieve whether level symbology display is in use for the view.levelsOn. Set or retrieve whether text node elements are displayed in the view. Turn on slow (correct) fonts or the fast font for the view. Determine which master file levels are on for the view. Set or retrieve whether reference file boundaries are displayed in the view. Control whether changes to view display parameters causes an immediate redraw of the view. MbeView.slowFont (page 8-102) MbeView.noText (page 8-101) MbeView.getLevels (page 8-106) MbeView.fastRefClip (page 8-105) MbeView. Set or retrieve whether line weights are displayed in the view.grid (page 8-103) MbeView.fastCurve (page 8-101) MbeView.construction (page 8-104) MbeView.textNode (page 8-103) MbeView.dimension (page 8-104) MbeView. Set or retrieve the fast curve state of the view.areaFill (page 8-105) MbeView. The properties of the MbeView object so MicroStation BASIC Guide 8-99 8 MicroStation Extensions to BASIC Set or retrieve whether enter data fields of text elements are displayed in the view.refBoundary (page 8-105) MbeView. Turn on or off text display for the view. Set or retrieve whether reference files are clipped to their boundary rectangle.lineWeight (page 8-102) MbeView. Set or retrieve whether area fills are displayed in the view.levelsOff (page 8-107) Used to Determine if the view (corresponding to the MbeView object) is active.update (page 8-106) MbeView. Set or retrieve whether dimension class elements display in the view.active (page 8-100) MbeView. Turn on or off master file levels in the view. . Determine which screen the view is on. with the view 1 corresponding to index = 1. MbeViews(index) MbeViews(index) Descr. MbeViews(index) retrieves the MbeView object associated with the index view.View Object View Object Properties and Methods MbeView. Set or retrieve whether construction class elements display in the view.deferApply (page 8-105) MbeView. Immediately redraw the view. Set or retrieve whether grid points are displayed in the view.levelSymbology (page 8-103) MbeView.pattern (page 8-102) MbeView.screenNum (page 8-101) MbeView.enterDataField (page 8-103) MbeView.

The MbeView..active MbeView. Process view End If Next iView 8-100 MicroStation BASIC Guide . or an MbeView object can be declared and Set to MbeViews(index).slowFont = 1 view. Example Dim view as MbeView Dim iView as Integer ' Turn on areafill.deferApply = 0 view. and turn off grid in all active views For iView = 1 to MBE_MaxViews If MbeViews(iView).View Object retrieved can be directly referenced.update ' update to see the changes End If Next iView MbeView.active read-only property returns an Integer that is nonzero if the view to which MbeView refers is active.active <> 0 Then .active <> 0 Then Set view = MbeViews(iView) view.deferApply = 1 ' defer actual changes to avoid multiple updates view.. slow font.areaFill = 1 view. Example Dim iView as Integer For iView = 1 to MBE_MaxViews If MbeViews(iView).grid = 0 view. The example below demonstrates both methods.active Descr.

deferApply is FALSE.fastCurve Descr. and the new value differs from the present state. Example Dim viewsOnScreen(0 to 1) as Integer Dim iView as Integer Dim screenNum as Integer ' Count views active on each screen For iView = 1 to MBE_MaxViews If MbeViews(iView).screenNum MbeView. the view is updated to reflect the new state of the fast curve flag.fastCurve = 1 See also MbeView. The MbeView.screenNum read-only property returns an Integer that is the screen that the view to which the MbeView refers is on.deferApply. The MbeView.deferApply is FALSE.deferApply. the view is updated to reflect the new state of text display.fastCurve read/write integer property sets or retrieves the fast curve state for the view to which MbeView refers. and MbeView.screenNum Descr. and the new value differs from the present state. MicroStation BASIC Guide 8-101 8 MicroStation Extensions to BASIC . Example Dim view as MbeView ' Turn off text in view 1 MbeViews(1).noText read/write integer property sets or retrieves whether text is displayed in the view to which MbeView refers. MbeView.fastCurve MbeView. and MbeView.noText Descr.noText = 1 See also MbeView.screenNum viewsOnScreen(screenNum) = viewsOnScreen(screenNum) + 1 End If Next iView MbeView.noText MbeView. If the property is assigned.View Object MbeView.active <> 0 Then screenNum = MbeViews(iView). If the property is assigned. The MbeView. Example Dim view as MbeView ' Turn on fast curve for view 2 MbeViews(2).

If the property is assigned.deferApply is FALSE.deferApply is FALSE. MbeView.pattern Descr. and the new value differs from the present state.slowFont See also MbeView. and the new value differs from the present state.lineWeight MbeView. 8-102 MicroStation BASIC Guide .deferApply.deferApply.pattern MbeView.deferApply. The MbeView.slowFont Descr. and MbeView. the view is updated to reflect the new state of text display.slowFont read/write integer property sets or retrieves whether text is displayed in the correct fonts or the fast font in the view to which MbeView refers.lineWeight Descr. The MbeView.lineWeight = 1 Next iView See also MbeView.pattern read/write integer property sets or retrieves whether elements of the pattern class are displayed in the view to which MbeView refers. the view is updated to reflect the new state of line weight display. Example Dim iView as Integer ' Turn on line weight in all views For iView = 1 to MBE_MaxViews MbeViews(iView). MbeView. and MbeView.slowFont = MbeViews(1).View Object MbeView.slowFont MbeView.lineWeight read/write integer property sets or retrieves whether line weights are displayed in the view to which MbeView refers. The MbeView. If the property is assigned. and the new value differs from the present state. Example Dim view as MbeView ' set up slow font in view 3 to match view 1 MbeViews(3). Example Dim iView as Integer ' Turn off pattern display in all views For iView = 1 to MBE_MaxViews MbeViews(iView). the view is updated to reflect the new state of pattern display. and MbeView.pattern = 0 Next iView See also MbeView. If the property is assigned.deferApply is FALSE.

deferApply.enterData Example ' Turn on enter data field display in view 3 MbeViews(3).deferApply is FALSE.enterData = 1 See also MbeView. Example ' Turn off text node display in view 1 MbeViews(1).grid Descr. and MbeView. The MbeView. If the property is assigned. the view is updated to reflect the new state of enter data display.grid MbeView.deferApply.levelSymbology MbeView.grid = 0 See also MbeView. .enterDataField MbeView. If the property is assigned. and MicroStation BASIC Guide 8-103 8 MicroStation Extensions to BASIC Descr.levelSymbology Descr.gridReferences.textNode = 0 See also MbeView.View Object MbeView.textNode MbeView. and the new value differs from the present state.levelSymbology read/write Integer property sets or retrieves whether level symbology display is turned on in the view to which MbeView refers.deferApply.deferApply is FALSE. and the new value differs from the present state. If the property is assigned. MbeView. MbeView. Example ' Turn off grid display in view 4 MbeViews(4).enterDataField read/write Integer property sets or retrieves whether enter data fields in text elements are displayed in the view to which MbeView refers. MbeView. The MbeView. The MbeView. and MbeView. The MbeView.textNode Descr.textNode read/write Integer property sets or retrieves whether text node elements are displayed in the view to which MbeView refers. If the property is assigned. MbeSettings. the view is updated to reflect the new state of text node display. and the new value differs from the present state. and MbeView.gridUnits. the view is updated to reflect the new state of grid display.deferApply is FALSE. and the new value differs from the present state.grid read/write Integer property sets or retrieves whether the grid is displayed in the view to which MbeView refers. MbeSettings.

the view is updated to reflect the new state of dimension display. The MbeView.construction read/write Integer property sets or retrieves whether elements of the construction class are displayed in the view to which MbeView refers.dimension Descr.dimension read/write Integer property sets or retrieves whether elements of the dimension class are displayed in the view to which MbeView refers. Example ' Turn on level symbology in all views For iView = 1 to MBE_MaxViews MbeViews(iView). the view is updated to reflect the new state of level symbology display. Example Dim iView as Integer ' Turn off dimension display in all views For iView = 1 to MBE_MaxViews MbeViews(iView).deferApply. the view is updated to reflect the new state of construction display.View Object MbeView.dimension = 0 Next iView See also MbeView. and the new value differs from the present state. 8-104 MicroStation BASIC Guide .deferApply is FALSE. and the new value differs from the present state.deferApply. Example Dim iView as Integer ' Turn off construction display in all views For iView = 1 to MBE_MaxViews MbeViews(iView). and MbeView.construction Descr. If the property is assigned.construction = 0 Next iView See also MbeView.levelSymbology = 1 Next iView See also MbeView. The MbeView.deferApply is FALSE. and MbeView. MbeView.dimension MbeView. MbeView. If the property is assigned.deferApply.deferApply is FALSE.construction MbeView.

. the view is updated to reflect the new state of reference file boundary display.fastRefClip Descr. and the new value differs from the present state.deferApply is FALSE.refBoundary Example ' Turn off reference file boundary display in view 1 MbeViews(1).deferApply read/write Integer property controls whether changes to view display parameters cause an immediate redraw of the view to which the MbeView refers.deferApply Descr.fastRefClip MbeView.areaFill MbeView.deferApply. If MbeView. If the property is assigned. If the property is assigned.refBoundary MbeView. the view is updated to reflect the new state of reference file clipping.fastRefClip = 1 See also MbeView. The MbeView. If the property is assigned.View Object MbeView.deferApply is TRUE. Example ' Turn on fast reference file clipping view 2 MbeViews(2). and MbeView. and MbeView. MbeView.areaFill read/write Integer property sets or retrieves whether area fills are displayed in the view to which MbeView refers.deferApply MbeView.fastRefClip read/write Integer property sets or retrieves whether reference files are clipped to their boundary rectangle (fast clipping) in the view to which MbeView refers.deferApply. The MbeView. and MbeView. and the new value differs from the present state.areaFill = 1 See also MbeView.areaFill Descr.deferApply is FALSE. The MbeView. and the new value differs from the present state. MbeView. The MbeView.deferApply is FALSE.deferApply.refBoundary = 0 See also MbeView. Example ' Turn on area fill in view 6 MbeViews(6). then the changes made to viewing parameters do not take effect until the next time the view is updated (either by the user or using MicroStation BASIC Guide 8-105 8 MicroStation Extensions to BASIC Descr.refBoundary read/write Integer property sets or retrieves whether reference file boundaries are displayed in the view to which MbeView refers. the view is updated to reflect the new state of area fill display. MbeView.

and so on. Similarly the low bit of levelArray(1) gives the state of level 17.getLevels stat = MbeView. any change to the view display flags causes a redraw of the view.deferApply is FALSE.update ' update to see the changes End If Next iView MbeView.deferApply = 0 view. slow font.grid = 0 view. The MbeView.slowFont = 1 view. The macro should call MbeView.deferApply is set to FALSE for all views. The MbeView. The function returns 8-106 MicroStation BASIC Guide .View Object the MbeView.getLevels object function retrieves a level mask that shows which master file levels are on for the view to which MbeView refers. etc.deferApply to TRUE before making multiple changes to the view display flags to avoid multiple redraws. MbeView. the next lowest bit indicates the state of level 2.update MbeView.active <> 0 Then Set view = MbeViews(iView) view.update statement causes the view to which MbeView refers to immediately redraw. Example Dim view as MbeView Dim iView as Integer ' Turn on areafill. Set MbeView. By default.getLevels(levelArray() as Integer) Descr. The low bit of levelArray(0) is 1 if level 1 is on and zero if it is off. Example ' redraw view 2 MbeViews(2).update MbeView.update statement).areaFill = 1 view. and turn off grid in all active views For iView = 1 to MBE_MaxViews If MbeViews(iView). which the function will redimension to levelArray(0 to 3).deferApply = 1 'defer actual changes to 'avoid multiple updates view. If MbeView.update Descr.getLevels with a variable-sized array for levelArray.

MbeView. For both functions. ' process levels in levelArray End If See also MbeView. The functions return MBE_Success if the levels are successfully manipulated.levelsOff stat = MbeView.. For MbeView.deferApply is FALSE. the elements in the affected levels are immediately drawn (or erased). levelArray must be a four-element Integer array.levelsOff.View Object MBE_Success if the levels are successfully retrieved.levelsOff object functions turn on or off master file levels in the view to which MbeView refers. The MbeView. or an error code if levelArray cannot be redimensioned.levelsOff(levelArray() as Integer) When levels are turned on or off.levelsOn.levelsOn(levelArray() as Integer) stat = MbeView. and Mbe_WrongDimensions (801) if levelArray is not a four-element Integer array. Example Dim view as MbeView Dim levelArray() as Integer view = MbeViews(1) If view.levelsOff(levelsOff) <> MBE_Success Then MbeWriteStatus “Error turning levels off” End If MicroStation BASIC Guide 8-107 8 MicroStation Extensions to BASIC Descr.levelsOn(levelsOn) <> MBE_Success Then MbeWriteStatus “Error turning levels on” End If If view. if MbeView..levelsOff.getLevels(levelArray) <> MBE_Success Then MbeWriteStatus “Error getting levels” Else . The bits map to levels as described for MbeView. MbeView. the levels for which corresponding bits are 1 are turned off.levelsOn and MbeView. the display state of the levels corresponding to zero bits is unchanged. MbeView. Example Dim view as MbeView Dim levelsOn(0 to 3) as Integer Dim levelsOff(0 to 3) as Integer view = MbeViews(1) levelsOn(0) = 31 ' Turn on levels 1 through 5 levelsOff(0) = 992 ' Turn off levels 6 through 10 If view. the levels for which corresponding bits are 1 are turned on.getLevels. and for MbeView. .levelsOn.levelsOn.

Make any MbeRefFile changes for a given reference file slot permanent by saving them to the master design file. Determine if the reference file named in the reference file slot was found.Reference File Object Reference File Object Properties and Methods MbeRefFiles.scaleLineStyle (page 8-111) MbeRefFile. Retrieve the attachment name of the reference file attached to the reference file slot. MbeRefFile. The properties and methods listed below in this table refer to an MbeRefFile object and the reference slot to which it refers. Set or retrieve the snap state for the reference file slot. Turn on/off specific levels in a view for the reference file slot.maxRefFiles (page 8-109) MbeRefFiles(index) (page 8-109) Used To Determine the maximum number of reference files that can be attached to the master file. Determine which levels are turned on in a particular view for the reference file slot. MbeRefFile.fileName (page 8-112) MbeRefFile. This slot may or may not have a reference file attached to it. Set or retrieve the display state of the reference file slot.active (page 8-109) MbeRefFile. Set or retrieve the flag that determines if line styles are scaled for the reference file slot Retrieve the full file name of the reference file attached to the reference file slot. Set or retrieve the logical name of the reference file attached to the reference file slot.attachName (page 8-112) MbeRefFile. Return the ratio of master file master units to reference file master units for the reference file attached to the reference file slot.description (page 8-113) MbeRefFile. Set or retrieve the locate state of the reference file slot.levelsOn.getLevels (page 8-114) MbeRefFile.display (page 8-110) MbeRefFile.plot (page 8-111) MbeRefFile.notFound (page 8-110) MbeRefFile. Set or retrieve the plot state for the reference file slot.snap (page 8-111) MbeRefFile. Returns an individual MbeRefFile object corresponding to the reference file slot identified by index.scale (page 8-113) Determine if a reference file is attached to the reference file slot.saveSettings (page 8-115) 8-108 MicroStation BASIC Guide . MbeRefFile.locate (page 8-110) MbeRefFile.levelsOff (page 8-114) MbeRefFile.logical (page 8-113) MbeRefFile. Set or retrieve the description of the reference file attached to the reference file slot.

Example Dim iRef as Integer For iRef = 1 to MbeRefFiles. The properties of the MbeRefFile object so retrieved can be directly referenced. The MbeRefFiles.. This number is set by the user in the User Preferences dialog box..active read-only property returns an Integer that is nonzero if the reference file slot that MbeRefFile refers to has a reference file attached. Process reference file End If Next iRef MicroStation BASIC Guide 8-109 8 MicroStation Extensions to BASIC Descr. ' process reference file End If Next iRef MbeRefFiles(index) MbeRefFiles(index) Example Dim refFile as MbeRefFile Dim iRef as Integer ' Turn on display for all active reference files that MicroStation found For iRef = 1 to MbeRefFiles. Dim iRef as Integer For iRef = 1 to MbeRefFiles.display = 1 End If End If Next iRef MbeRefFile..notFound = 0 Then refFile. The example below demonstrates both methods.maxRefFiles read-only property returns an Integer that is the maximum number of reference files that can be attached to a master file.active <> 0 Then . or an MbeRefFile object can be declared and Set to MbeRefFiles(index).maxRefFiles If MbeRefFiles(iRef)..active MbeRefFile. MbeRefFiles(index)retrieves the MbeRefFile object associated with the index reference file attachment. The MbeRefFile.maxRefFiles Descr.Reference File Object MbeRefFiles.active <> 0 Then .maxRefFiles If MbeRefFiles(iRef).maxRefFiles If MbeRefFiles(iRef).active <> 0 Then Set refFile = MbeRefFiles(iRef) If refFile. . with the first reference file attachment corresponding to index = 1.active Descr.maxRefFiles MbeRefFiles.

notFound <> 0) Then MbeWriteError "could not find " &refFile.notFound MbeRefFile. Example Dim refFile as MbeRefFile Dim iRef as Integer For iRef = 1 to MbeRefFiles.display read/write Integer property sets or retrieves the display state for the reference file slot to which MbeRefFile refers.locate read/write Integer property sets or retrieves the locate state for the reference file slot to which MbeRefFile refers. The MbeRefFile.display Descr. Example Dim iRef as Integer ' Turn on locate for all active reference file For iRef = 1 to MbeRefFiles.attachName End If Next iRef MbeRefFile.saveSettings.locate Descr. MbeRefFile.maxRefFiles refFile = MbeRefFiles(iRef) If (refFile.display = 1 End If See also MbeRefFile.active <> 0) And (refFile.display MbeRefFile. Example Dim refFile as MbeRefFile ' Turn on display of reference file 2 refFile = MbeRefFiles(2) If refFile.active read-only integer property returns an Integer that is nonzero if the file named in the reference slot to which MbeRefFile refers could not be found by MicroStation.saveSettings. The MbeRefFile. 8-110 MicroStation BASIC Guide .active <> 0 Then MbeRefFiles(iRef).locate MbeRefFile. The MbeRefFile.maxRefFiles If MbeRefFiles(iRef).Reference File Object MbeRefFile.notFound Descr.locate = 1 End If Next iRef See also MbeRefFile.active <> 0 Then refFile.

.snap read/write Integer property sets or retrieves the snap state for the reference file slot to which MbeRefFile refers.maxRefFiles If MbeRefFiles(iRef).scaleLineStyles = 1 MicroStation BASIC Guide 8-111 8 MbeRefFile. Example Dim iRef as Integer ' Turn off snap for all active reference file For iRef = 1 to MbeRefFiles.plot MbeRefFile.plot Descr.snap MbeRefFile.plot = 1 Next iRef See also MbeRefFile.maxRefFiles refFile = MbeRefFiles(iRef) If (refFile.plot Example Dim refFile as MbeRefFile Dim iRef as Integer ' Turn on plot for all reference file that are displayed For iRef = 1 to MbeRefFiles.scaleLineStyle read/write Integer property sets or retrieves the state of scaling line styles for the reference file slot to which MbeRefFile refers.active <> 0) And (refFile.plot read/write Integer property sets or retrieves the plot state (whether the attached reference file should appear in plots) for the reference file slot to which MbeRefFile refers.Reference File Object MbeRefFile. MbeRefFile.maxRefFiles refFile = MbeRefFiles(iRef) If (refFile.saveSettings. The MbeRefFile.active <> 0) And (refFile.active <> 0 Then MbeRefFiles(iRef).display <> 0) Then endif refFile. Example Dim refFile as MbeRefFile Dim iRef as Integer ' Turn on scaleLineStyle for all plotted reference files For iRef = 1 to MbeRefFiles.snap Descr. The MbeRefFile.plot <> 0) Then refFile. The MbeRefFile.saveSettings. MbeRefFile.scaleLineStyle MicroStation Extensions to BASIC Descr.snap = 0 End If Next iRef See also MbeRefFile.

attachName MbeRefFile.active <> 0 Then If StrComp (refFile.attachName Descr.attachName read-only String property retrieves the name by which the reference file for the slot to which MbeRefFile refers is attached.dgnFileName) = 0 Then refFile.maxRefFiles refFile = MbeRefFiles(iRef) If (refFile.notFound = 0) Then If StrComp(refFile.fileName. MbeRefFile.attachName.description.saveSettings.notFound is FALSE. Example Dim refFile as MbeRefFile Dim iRef as Integer ' turn off display for all ref. name as String) If refFile. name) = 0 Then attachedAs = 1 End If End If End Function See also MbeRefFile.fileName MbeRefFile.display = 0 End If End If Next iRef See also MbeRefFile. files that are attachments of master file For iRef = 1 to MbeRefFiles. Example Function attachedAs (refFile as MbeRefFile.logical.fileName read-only String property retrieves the full file name of the reference file for the slot to which MbeRefFile refers.active <> 0) And (refFile. MbeRefFile.attachName. 8-112 MicroStation BASIC Guide . MbeRefFile. MbeDgnInfo. This property is valid only if MbeRefFile. The MbeRefFile. The MbeRefFile.Reference File Object End If Next iRef See also MbeRefFile.fileName Descr.

MbeRefFile. MbeRefFile.Reference File Object MbeRefFile.scale Descr. name as String) If refFile.description read/write String property sets or retrieves the description of the reference file to which MbeRefFile refers.logical.active <> 0 Then MbeWriteStatus “ref file description is “ & refFile. Example Function logicalNameIs(refFile as MbeRefFile.scale MicroStation Extensions to BASIC Descr. MbeRefFile.description Example Sub showDescription(iRef as Integer) Dim refFile as MbeRefFile refFile = MbeRefFiles(iRef) If refFile. name) = 0 Then logicalNameIs = 1 End If End If End Function See also MbeRefFile. The MbeRefFile.logical MbeRefFile.attachName.attachName.logical Descr. MbeRefFile.active <> 0 Then If StrComp(refFile.logical read/write String property sets or retrieves the logical name of the reference file to which MbeRefFile refers.description.scale MicroStation BASIC Guide 8-113 8 MbeRefFile. The MbeRefFile.description MbeRefFile. Example Dim refScale as Double refScale = MbeRefFiles.description Else MbeWriteError “reference file not active” End If End Sub See also MbeRefFile. .logicalName. The MbeRefFile.scale read-only property returns a Double that is the ratio of master file master units to reference file master units for the reference file to which MbeRefFile refers.

Example Dim refFile as MbeRefFile Dim levelArray() as Integer Set refFile = MbeRefFiles(1) If refFile.getLevels object function retrieves a level mask that shows which levels are on for the view specified by viewNum for the reference file to which MbeRefFile refers. MbeRefFile. The function returns MBE_Success if the levels are successfully retrieved. etc.levelsOn and MbeRefFile.getLevels with a variable-sized array for levelArray.getLevels stat = MbeRefFile. and MBE_InvalidView (1501) if the view is outside the range 1-8 or MBE_InvalidRefFile (1601) if the reference file is not active. The functions return MBE_Success if the levels are successfully manipulated. viewNum as Integer) Descr. Similarly. the reference file graphics elements in the levels affected are drawn (or erased) immediately to the view specified. viewNum as Integer) Descr. MbeRefFile. and so on. and MBE_InvalidView (1501) if the view is out of range. Dim refFile as MbeRefFile Dim levelsOn(0 to 3) as Integer Dim levelsOff(0 to 3) as Integer refFile = MbeRefFiles(1) 8-114 MicroStation BASIC Guide . 1) <> MBE_Success Then MbeWriteStatus "Error getting ref levels" Else ' process reference levels in levelArray . viewNum as Integer) stat = MbeRefFile. The low bit of levelArray(0) is 1 if level 1 is on and zero if it is off..getLevels(levelArray() as Integer.levelsOff(levelArray() as Integer. The MbeRefFile.Reference File Object MbeRefFile.levelsOn object functions turn on or off levels in the view specified by viewNum for the reference file to which MbeRefFile refers. When levels are turned on or off.levelsOff stat = MbeRefFile. The bits map to levels as described for MbeRefFile.. the levels for which corresponding bits are 1 are turned off. the low bit of levelArray(1) gives the state of level 17.levelsOn(levelArray() as Integer. levelArray must be a four-element Integer array. which the function will redimension to levelArray(0 to 3).getLevels.levelsOn. and for MbeRefFile. For both functions the state of the levels for which the corresponding bits are zero is unchanged.levelsOn.levelsOff. The macro should call MbeRefFile.getLevels (levelArray. The MbeRefFile. the levels for which corresponding bits are 1 are turned on. MbeRefFile. For MbeRefFile. End If See also MbeRefFile. or Mbe_WrongDimensions (801) if levelArray is not a fourelement Integer array. the next lowest bit indicates the state of level 2.levelsOff. MBE_InvalidRefFile (1601) if the reference file is not active.levelsOn.

saveSettings. MbeRefFile. to the master file reference file attachment.saveSettings stat = MbeRefFile.saveSettings() If status = 1602 Then MbeWriteStatus “Not saving new ref file settings” Else If status = MBE_Success Then MbeWriteStatus “Ref settings saved” Else MbeWriteError “Could not save ref file settings” End If MicroStation BASIC Guide 8-115 8 MicroStation Extensions to BASIC .saveSettings object function saves. In that case mbeRefFile. 1) <> MBE_Success Then MbeWriteStatus “Error turning levels off” End If See also MbeRefFile. If overrideUserPref is nonzero. If this function is not called for a particular reference file object.saveSettings returns MBE_RefSaveDeferred (1602) without actually saving the new settings. If the optional overrideUserPref argument is zero or omitted. the function first checks the state of the “Save Settings to Save Changes” user preference.saveSettings function returns MBE_Success if the settings are successfully saved and MBE_InvalidRefFile (1601) if the reference file to which MbeRefFile refers is not active.Reference File Object levelsOn(0) = 31 ' Turn on levels 1 through 5 levelsOff(0) = 992 ' Turn off levels 6 through 10 If refFile.saveSettings([overrideUserPref]) Descr. it indicates that the user wishes to save reference file manipulations only when the MicroStation “Save Settings” operation is performed. The MbeRefFile. If this preference is TRUE.levelsOff (levelsOff.levelsOn (levelsOn. 1) <> MBE_Success Then MbeWriteStatus “Error turning levels on” End If If refFile. or the “Save Settings to Save Changes” preference is FALSE. Example Dim refFile as MbeRefFile Dim status as Integer refFile = MbeRefFiles(1) status = refFile. the new settings are saved. The MbeRefFile. the changes to the reference file made through the MbeRefFile properties and functions. then any changes made through the MbeRefFile properties and functions are “temporary” and will be reset to their saved settings the next time the master file is entered.

Session Object Session Object Properties and Methods MbeSession.. MbeSession..msProduct MbeSession. ' PowerDraft specific code Case MBE_MSReview Then .msPlatform (page 8-117) MbeSession.language (page 8-118) MbeSession. Possible codes include: Product MicroStation MicroStation Review MicroStation Constant MBE_MicroStation MBE_MSReview MBE_MSPowerDraft Value 10 30 50 Example Select Case MbeSession..msPlatform. The MbeSession. Return the version string of the product on which the macro is being run. Return the number of display screens to which MicroStation has access.msProduct Descr. 8-116 MicroStation BASIC Guide .msProduct (page 8-116) MbeSession.msVersion (page 8-117) MbeSession. Returns the name of the language in which MicroStation prompts and dialog boxes are being displayed.elapsedTime (page 8-119) Used to Determine which product in the MicroStation family is executing the macro. ' MicroStation specific action Case MBE_MSPowerDraft .canSwapScreen (page 8-119) MbeSession.msProduct read-only property returns an Integer code specifying which product within the MicroStation family that the macro is beginning executed by.. ' MS Review code Case Else MbeWriteError “Unrecognized MicroStation product” End Select See also MbeSession. Determine on which platform the macro is being executed. Return the elapsed time in seconds since the MicroStation session was started. MbeSession.msProduct Case MBE_MicroStation ..numScreens (page 8-118) MbeSession.msVersion. Determine if the SWAP command can be used to switch to another logical screen..

.msVersion. ' DOS specific code Case MBE_PlatformIntelNT. _ MBE_PlatformRS6000 . ' Mac specific code Case Else MbeWriteError “unrecognized MS Platform” End Select See also MbeSession.. MBE_PlatformAlphaNT . MBE_PlatformHP700. The MbeSession..msVersion MbeSession. MBE_PlatformPowerMac .msPlatform MbeSession.. Possible codes include: Platform PC-DOS Clipper EnvV Clipper X Macintosh PowerMac Sparc HP700 SGI RS6000 Intel WinNT Alpha WinNT Constant MBE_PlatformPC MBE_PlatformClipperEV MBE_PlatformClipperX MBE_PlatformMac MBE_PlatformPowerMac MBE_PlatformSparc MBE_PlatformHP700 MBE_PlatformSGI MBE_PlatformRS6000 MBE_PlatformIntelNT MBE_PlatformAlphaNT Value 1 21 22 3 14 4 6 7 9 10 11 Example Select Case MbeSession.Session Object MbeSession..msVersion read-only property returns a String containing the full four-digit version specifier for the product the macro is running on.msVersion Descr. ' Windows NT specific code Case MBE_PlatformClipperEV.msPlatform Descr. Since MicroStation takes care of most differences between platforms for macros.. ' Other unix specific code Case MBE_PlatformMac.. The MbeSession.msProduct. MBE_PlatformSGI. This string is in the MicroStation BASIC Guide 8-117 8 MicroStation Extensions to BASIC . MbeSession... most do not need to know what platform they are running on. MbeSession. MBE_PlatformClipperX ..msPlatform read-only property returns an Integer code specifying which hardware platform the macro is beginning executed on.msPlatform Case MBE_PlatformPC . ' Clix specific code Case MBE_PlatformSparc.

Most macros need not be concerned with the version of MicroStation they are running on. The MbeSession..msProduct.cc. Example If MbeSession. 8-118 MicroStation BASIC Guide .numScreens Descr.language read-only property returns a String containing the name of the language that the MicroStation prompts and dialog boxes are displayed in. MbeSession. where aa is the 2-digit major version number.numScreens < 2 Then .language MbeSession.. Example Dim language as String language = MbeSession.language Descr.bb. and in any case usually only the major version number is significant. ' open views on both screens End If See also MbeSession. bb is the 2-digit minor version number. and dd is the 2-digit build number. ' open views only one screen Else .numScreens read-only property returns an Integer that is the number of display screens that MicroStation has access to.numScreens MbeSession.msVersion majorVers = Val (Word$ (version. 1)) minorVers = Val (Word$ (version.canSwapScreen.Session Object format “aa. The MbeSession. cc is the 2-digit revision number. MbeSession. Example Dim version as String Dim majorVers as Integer Dim minorVers as Integer version = MbeSession..msPlatform.. 2)) If majorVers <> 5 Then MbeWriteError “Wrong MicroStation Version” Exit Sub End If If minorVers < 4 Then MbeWriteError “Need newer MicroStation” Exit Sub End If See also MbeSession.dd”. 1. 2.language MbeSession.

It returns the time in the maximum resolution that it can get from the system. since the MicroStation session was started.numScreens < 2) And (MbeSession. The MbeSession. Example If (MbeSession.canSwapScreen read-only property returns an Integer that is nonzero if the MicroStation “SWAP” command can be used to swap to another logical screen and zero if there is only one logical screen.Session Object MbeSession. The MbeSession.elapsedTime ’ (some compute intensive operation goes here) Print "The operation took ".numScreens.canSwapScreen MbeSession. Example Sub main Dim startTime As Double Dim endTime As Double startTime = MbeSession. MbeSession. which varies from platform to platform.elapsedTime function returns the elapsed time.canSwapScreen Descr... endTime . ' open views only one screen Else .elapsedTime Descr..startTime.canSwapScreen = 0) Then . in seconds. ' open views on both screens End If See also MbeSession.. "seconds to complete" End sub MicroStation BASIC Guide 8-119 8 MicroStation Extensions to BASIC . The primary use of this function is for timing operations in MicroStation.

MbeCExpressionLong MbeCExpressionLong (expression as String) as Long Descr. If the MbeCExpression given cannot be evaluated because the variable it references is not found. The MbeCExpressionLong function attempts to evaluate the C expression specified in the expression argument and return the result as a Long. int. short. promoted to a Long variable if necessary. unsigned short or char expression. It provides access to MicroStation internal variables in the rare instances where there is no interface to them available through the BASIC extensions. structure or pointer. MbeElement. MbeCExpressionString. an MBE_VariableNotFound (1702) runtime error is generated. 2.C Expression Statements C Expression Statements Statements MbeCExpressionLong (page 8-120) MbeCExpressionDouble (page 8-120) MbeCExpressionString (page 8-121) Used to Evaluate C expression and return result as a Long. since none of the safeguards provided by the BASIC interface are in place when it is used. If the MbeCExpression evaluates to a C double. an MBE_VariableWrongType (24) runtime error is generated. the function returns the value of the C long. Evaluate C expression and return result as a String. Otherwise. Effective use of MbeCExpressionLong requires a good working knowledge of C and MDL (MicroStation Development Language). It should be used with extreme caution.publish. Evaluate C expression and return result as a Double. This function has two purposes: 1. It can provide access to variables published (using the MbeCExpression_ functions) by MDL applications. ✍ Assignments to published C variables can be made by making the expression argument an assignment statement. Example Dim nextNodeNum as Long nextNodeNum = MbeCExpressionLong (“tcb->canode”) See also MbeCExpressionDouble. MbeCExpressionDouble MbeCExpressionDouble(expression as String) as Double 8-120 MicroStation BASIC Guide .

This function has two purposes: MicroStation Extensions to BASIC Otherwise. Effective use of MbeCExpressionDouble requires a good working knowledge of C and MDL (MicroStation Development Language). promoted to a Double variable if necessary. since none of the safeguards provided by the BASIC interface are in place when it is used.publish. . The MbeCExpressionString function attempts to evaluate the C expression specified in the expression argument and return the result as a String. This function has two purposes: 1.C Expression Statements Descr. an MBE_VariableWrongType (24) runtime error is generated. the function returns the value of the C double. unsigned short or char expression. It provides access to MicroStation internal variables in the rare instances where there is no interface to them available through the BASIC extensions. It can provide access to variables published (using the MbeCExpression_ functions) by MDL applications. long. It can provide access to variables published (using the MbeCExpression_ functions) by MDL applications. short. 2. ✍ Assignments to published C variables can be made by making the expression argument an assignment statement. int. Effective use of MbeCExpressionString requires a good working knowledge of C and MDL (MicroStation Development Language). MbeCExpressionString MbeCExpressionString(expression as String) as String 1. If the MbeCExpression evaluates to a C structure or pointer. The MbeCExpressionDouble function attempts to evaluate the C expression specified in the expression argument and return the result as a Double. It should be used with extreme caution. 2. MbeCExpressionString. an MBE_VariableNotFound (1702) runtime error is generated. If the MbeCExpression given cannot be evaluated because the variable it references is not found. MicroStation BASIC Guide 8-121 8 Descr. It should be used with extreme caution. It provides access to MicroStation internal variables in the rare instances where there is no interface to them available through the BASIC extensions. since none of the safeguards provided by the BASIC interface are in place when it is used. Example Dim trueNorthAzimuth as Double trueNorthAzimuth = MbeCExpressionDouble(“tcb->azimuth”) See also MbeCExpressionLong. MbeElement.

unsigned short or char expression. int. long. an MBE_VariableNotFound (1702) runtime error is generated. If the MbeCExpression evaluates to a C structure or other type of pointer.C Expression Statements If the MbeCExpression given cannot be evaluated because the variable it references is not found. MbeCExpressionDouble. If the MbeCExpression evaluates to a C double. MbeElement. 8-122 MicroStation BASIC Guide . If the MbeCExpression evaluates to a C char pointer. an MBE_VariableWrongType (24) runtime error is generated. the string is returned in the output variable. the value is formatted into a string and returned. short. Example Dim altLibraryName as String altLibraryName = MbeCExpressionString("tcb->altLibraryName") See also MbeCExpressionLong.publish. ✍ Assignments to published C variables can be made by making the expression argument an assignment statement.

Display a string as an error message in the status bar. Parse a string. into a point in the design plane/cube. Display a string in the message field of the status bar. Activate a command. Send the last input from MbeGetInput to MicroStation for processing. Definition of a point in the design plane/cube. Send a data point to the active command. Reset. Parse a string. Statements and Functions MbeGetInput (page 8-124) MbePoint (page 8-125) MbeSendAppMessage (page 8-125) MbeSetAppVariable (page 8-125) MbeSetScaledAppVar (page 8-126) MbeSendCommand (page 8-127) MbeSendDataPoint (page 8-127) MbeSendDragPoints (page 8-128) MbeSendLastInput (page 8-129) MbeSendKeyin (page 8-129) MbeSendReset (page 8-129) MbeSendTentPoint (page 8-129) MbeWriteCommand (page 8-130) MbeWriteError (page 8-130) MbeWriteMessage (page 8-131) MbeWritePrompt (page 8-131) MbeWriteStatus (page 8-131) MbeRelocate (page 8-131) MbeStartLocate (page 8-132) MbeLocateElement (page 8-139) MbeScalarFromString (page 8-141) MbePointFromString (page 8-141) MbeAngleFromString (page 8-141) MbeStringFromScalar (page 8-142) Used to Obtain a data point. Locate a specific element in the master file or an attached reference file. subject to the macro’s current coordinate system.CAD Input Operations CAD Input Operations The statements documented in this section allow a BASIC macro to access the fundamental drawing capabilities of MicroStation. Send an application-defined string to the indicated task. Set the value of a variable belonging to a dialog box item of an MDL task. subject to the macro’s current coordinate system. Parse a string. subject to the macro’s coordinate system. or command from the user. MicroStation BASIC Guide 8-123 8 MicroStation Extensions to BASIC . into an angle specified in radians. Send a tentative point to the active command. Format a scalar value in the macro’s current coordinate system into a string. into a scalar value. Set the value of a variable belonging to dialog box item that represents a coordinate or a distance. Display a string as the command name in the status bar. Allow the macro to control the element location process. Display a string in the status field of the status bar. Send starting and ending data points with a drag between the two. key-in. Send a key-in to the active command. Send a Reset to the active command. Relocate an element that was located by macro using the MbeStartLocate. Display a prompt in the status bar.

This integer constant. is used when getting input from the user. Format an angle in the macro’s current coordinate system into a string. Start the default MicroStation command. This statement waits for the user to enter the desired input. MbeStartDefaultCommand (page 8-144) Constant MBE_CommandInput MBE_DataPointInput MBE_KeyinInput MBE_ResetInput Description This integer constant. whose value is 3. whose value is 4. whose value is 1. This integer constant. is used when getting input from the user. MbeGetInput MbeGetInput inputType as Integer[.CAD Input Operations Statements and Functions MbeStringFromPoint (page 8-142) MbeStringFromAngle (page 8-143) MbeGetConfigVar (page 8-143) MbeFindFile (page 8-143) Used to Format a point in the macro’s current coordinate system into a string. is used when getting input from the user. wait for either a data point or a reset 8-124 MicroStation BASIC Guide . is used when getting input from the user. Example Sub main() 'After prompting. This integer constant. Find a file matching a given list of file name components and/or configuration variable directory specifications. inputType as Integer]]] Descr. The inputType parameter can be one or more of the following: inputType MBE_DataPointInput MBE_ResetInput MBE_KeyinInput MBE_CommandInput Meaning Wait for a data point Wait for a reset Wait for a keyin Wait for a command If the user selects a primitive command when MbeGetInput is not waiting for a command. inputType as Integer[. whose value is 2. Get the value of a configuration variable. an MBE_ReceivedCommand (1102) runtime error is generated. inputType as Integer[.

This statement sends the message in string$ to the indicated task. MBE_ResetInput End Sub MbePoint Type MbePoint x As Double y As Double z AS Double End Type Descr. Example Sub Main ' Send message to update the Text Editor MbeSendAppMessage "MGDSHOOK". This structure defines a point in the design plane/cube. "TextEdit A text string" End Sub MbeSetAppVariable MbeSetAppVariable task as String. varName as String.25# point.mask as Long] MicroStation BASIC Guide 8-125 8 MicroStation Extensions to BASIC . string as Integer Descr. Example Sub main() Dim point as MbePoint ' Set the coordinates point.value as Long[.z = 1000# ' Send the point to the active command MbeSendDataPoint point.5# point. This statement is output by the macro generator when the user’s actions cannot be adequately described by commands and application variables. 1% End Sub MbeSendAppMessage MbeSendAppMessage task as Integer.y = -2.CAD Input Operations MbeWritePrompt "Accept/Reject" MbeGetInput MBE_DataPointInput. value as String OR MbeSetAppVariable task as Long. The coordinates are specified in the current coordinate system. The format of the message is defined by task.varName as Long.x = 5.

70000# End Sub See also Appendix A MbeSetScaledAppVar MbeSetScaledAppVar task as String. varName as String.0&. The variables are associated with a task’s dialog box items. 5. a function call of this form uses the function name MbeSetAppVariableInteger instead of MbeSetAppVariable. OR MbeSetAppVariable task as String."tcb->textUnderline". varName as String."smrtlineInfo. Both MbeSetAppVariableReal and MbeSetAppVariableInteger are only available in OLE Automation Descr. this statement sets varName. Example Sub main() 'Clear the variable for underlining text MbeSetAppVariable "MGDSHOOK". to the specified value. Like MbeSetAppVariable. a function call of this form uses the function name MbeSetAppVariableReal instead of MbeSetAppVariable. Example Sub main() MbeSendCommand "PLACE CIRCLE RADIUS" 'Set the radius of the circle to 5. -3. 1& End Sub 8-126 MicroStation BASIC Guide .25#. This statement sets varName$ to the specified value. the variables represent coordinates or distances and the values are specified in the current coordinate system. value as Double Descr.5# MbeSendDataPoint 10#.1& 'Set the radius of the arcs when placing "smart" lines MbeSetAppVariable "SMRTLINE". Unlike MbeSetAppVariable.CAD Input Operations ✍ In OLE Automation. value as Long OR MbeSetScaledAppVar task as String. a variable associated with a task’s dialog box item. value as Double ✍ In OLE Automation. varName as String.radius". The optional mask parameter is used when the associated dialog item displays only part of the underlying variable’s value. "tcb->arc_radius".0#.5 m MbeSetScaledAppVar "MGDSHOOK". 0.

need this information.x = 100# MicroStation BASIC Guide 8-127 8 MicroStation Extensions to BASIC . Using the second syntax. qualifiers are associated with the data points. MbeSendDataPoint -1000. for example. z as Double _ [. Views are numbered from 1 to 8. qualifier as Long]] OR MbeSendDataPoint point as MbePoint [. The x. qualifier as Long]] Descr. Interactively. ✍ Only the second form of this function call is supported in OLE Automation. y and z parameters in the first syntax and the point parameter in the second syntax specify the data point coordinates. The optional view parameter specifies the view to which the data point is directed. this is generally done by holding down the <Ctrl> key. See Appendix A for more information on OLE Automation. Using the first syntax. This statement sends a data point to the active command. Example Sub main() Dim point As MbePoint 'Send a data point. if any. 0. view as Long [. the coordinates are specified individually in master units. The optional qualifier parameter specifies what. y as Double. Example Sub main() MbeSendCommand "PLACE SMARTLINE" End Sub MbeSendDataPoint MbeSendDataPoint x as Double. This statement activates the command cmdString$ using its corresponding key-in string cmdString$.5#. The Selection Tool makes use of this qualifier: 1 Toggle the selection of an element. WINDOW AREA and SET FILL ON. view as Long [. 0# 'Send a data point for view 5 using an MbePoint point. the coordinates are specified through an MbePoint structure. Commands that work with views.CAD Input Operations MbeSendCommand MbeSendCommand cmdString as String Descr.58#.

The Selection Tool makes use of the qualifiers which are: 1 3 Toggle the selection of the elements enclosed by the dynamic rectangle. 0#. _ point2 as MbePoint[.y = 50# point. -200. z2 as Double[. qualifiers are associated with the data point information. 5% End Sub See also Appendix A.z = -88# MbeSendDataPoint point.5#. y1 and z1 parameters in the first syntax and the point1 parameter in the second syntax specify the coordinates where the data button was pressed down.8875#. The x1.view as Long[. Using the second syntax. the coordinates are specified individually in master units. ✍ Only the second form of this function call is supported in OLE Automation. point2 As MbePoint 'Send data point information. The optional view parameter specifies the view to which the data point information is directed.CAD Input Operations point. Toggle the selection of the elements enclosed by and overlapping the dynamic rectangle. if any.qualifier as Long]] Descr. y2 and z2 parameters in the first syntax and the point2 parameter in the second syntax specify where the data button was released. 0# 8-128 MicroStation BASIC Guide . This statement sends data point information to the active command as if the user pressed and held the data button while moving the mouse (or pointer). The optional qualifier parameter specifies what. -507. y2 as Double. the coordinates are specified through MbePoint structures. 0. _ x2 as Double. MbeSendDragPoints -1000#. z1 as Double. See Appendix A for more information on OLE Automation.5#. y1 as Double. The x2. Example Sub main() Dim point1 As MbePoint. MbeSendDragPoints MbeSendDragPoints x1 as Double.view as Long[. Using the first syntax.qualifier as Long]] OR MbeSendDragPoints point1 as MbePoint.

This statement sends the last input from MbeGetInput to MicroStation for processing. Example Sub main() 'Send a "yes" response to a prompt MbeSendKeyin "yes" End Sub MbeSendReset MbeSendReset Descr. MBE_ResetInput MbeSendLastInput End Sub MbeSendKeyin MbeSendKeyin string as String Descr.x = 95. 1% End Sub See also Appendix A.2# point2. This statement sends a reset to the active command. This statement sends the key-in string$ to the active command. y as Double. include a qualifier point1.z = 0# MbeSendDragPoints point1. point2.456# point1. MbeSendLastInput MbeSendLastInput Descr. z as Double [.CAD Input Operations 'Send data point information using MbePoints.y = 176.y = 55.x = 200. Sub main() MbeStartLocate MbeGetInput MBE_DataPointInput. Example Sub main() MbeReset End Sub MbeSendTentPoint MbeSendTentPoint x as Double.350# point1.806# point2. 1%.z = 0# point2.view as Integer] MicroStation BASIC Guide 8-129 8 MicroStation Extensions to BASIC .

the coordinates are specified individually in master units. If a string is not specified.z = -88# MbeSendTentPoint point. the coordinates are specified through an MbePoint structure.x = 100# point. The optional view parameter specifies the view to which the tentative point is directed. MbeSendTentPoint -1000. See Appendix A for more information on OLE Automation. the command name area is cleared.view as Integer] Descr. Example Sub main() Dim point As MbePoint 'Send a tentative point.58#. 5% End Sub See also Appendix A. 0. Views are numbered from 1 to 8. This statement sends a tentative point to the active command.y = 50# point. Using the second syntax. This statement displays the given string as the command name in the status bar. 0# 'Send a tentative point for view 5 using an MbePoint point. MbeWriteCommand MbeWriteCommand [string as String] Descr. Using the first syntax.CAD Input Operations OR MbeSendTentPoint point as MbePoint [. The x. Example Sub main() MbeWriteCommand "Place Widget" End Sub MbeWriteError MbeWriteError [string as String] 8-130 MicroStation BASIC Guide . ✍ Only the second form of this function call is supported in OLE Automation. y and z parameters in the first syntax and the point parameter in the second syntax specify the tentative point coordinates.5#.

This statement displays the given message string in the status bar. This statement displays the given error message in the status bar. Example Sub main() MbeWriteStatus "Type=LINE. the message area is cleared. Level=5" End Sub MbeRelocate MbeRelocate [point as MbePoint [. This statement displays the given status string in the status bar.CAD Input Operations Descr. the prompt message is cleared. If a string is not specified. This statement displays the given prompt string in the status bar. the status area is cleared. Example Sub main() MbeWritePrompt "Enter origin" End Sub MbeWriteStatus MbeWriteStatus [string as String] Descr. view as Integer]] MicroStation BASIC Guide 8-131 8 MicroStation Extensions to BASIC . the error message is cleared. If a string is not specified. If a string is not specified. If a string is not specified. Example Sub main() MbeWriteMessage "Current position MARKed" End Sub MbeWritePrompt MbeWritePrompt [string as String] Descr. Example Sub main() MbeWriteError "Element not found" End Sub MbeWriteMessage MbeWriteMessage [string as String] Descr.

display) if it wants it hilited. levelMask() as Integer [. _ elemTypes() as Integer [. When an acceptable element is found. All nine arguments to MbeStartLocate are optional. _ classMask() as Integer [. The usefulness of this statement is that MbeStartLocate can be used to gain more control over the element location process than is possible when a MicroStation command is active. If 0. If 0.locateHeaderFilePos points to the outermost header. If 2. If the optional arguments are omitted. respectively. the macro must supply its own messages.If 1. propVal as Integer[.CAD Input Operations Descr. all of the arguments that follow it must be omitted as well.locateComponentFilePos points to it. wantHilite as Integer [. _ allowComponents as Integer [. The default is 0. MicroStation prompts to locate the element. The arguments and their meanings are as follows: wantMsgs . MbeRelocate relocates the element that was located by the macro using the MbeStartLocate function. allowComponents . MicroStation starts looking for an element to locate at the position following the last located element. MbeStartLocate starts a special command within MicroStation that gives a macro a higher degree of control over the element selection process than is possible by simply sequencing a command that requires an element location by the user (some control in the latter situation is available by using the MbeState. If 0. the macro starts a MicroStation command that requires an element to be located and calls MbeRelocate. If the optional point and view arguments are provided. wantHilite . they become the user entered data point and view.locate* properties). but if any argument is omitted.If continueLocate is 1. 8-132 MicroStation BASIC Guide . and MbeState. continueLocate as Integer[. the data point and view that were entered during the MbeStartLocate user interaction is used. see MbeLocateElement. continueLocate . while MbeState. The default is 1. MbeState. _ propMask as Integer ]]]]]]]]] Descr. the macro must hilite the selected element (using MbeElement. See also MbeStartLocate. MbeStartLocate MbeStartLocate [wantPrompts as Integer [.locateHeaderFilePos.If 1.If 1.locateComponentFilePos will always be the same as MbeState. The default is 0. the outermost element header is considered to be located. MicroStation hilites the located element.locateComponentFilePos points to the inner header and MbeState. The default is 1. The effect of calling MbeRelocate to a MicroStation command that is prompting to locate an element is as if the user entered a data point (at point and view) and located the exact same element that was located during the MbeStartLocate user interaction (regardless of whether point and view would have resulted in MicroStation locating the previously located element or not). allows the component element to be located.locateHeaderFilePos points to the outermost header. For an example. and MbeState.

but this same technique can be used to implement a more sophisticated manipulation. all classes are allowed. . If this argument is not provided. It performs a simple manipulation on selected elements. new status. all of the entries beyond those provided are assumed to be zero (the element types are disabled).The arguments are used together to limit the elements eligible for location based on the element properties. If the bit is 1. etc. all of the entries beyond those provided are assumed to be zero (the levels are disabled). the corresponding bit in the propMask argument is set. otherwise they are not. The element properties are a group of bits in the element header that indicate locked status. The array must be one-dimensional. If these arguments are omitted. If the array is smaller than 8 entries. the technique can be readily extended. no filtering is done on element properties. attributes present. modified status. classMask . The low bit of elemTypes(0) corresponds to element type 1. The bit name and meaning are summarized in the reference section for the MbeElement. hole or solid status. and the corresponding bit in the propVal argument is set to the desired value. If this argument is not provided. planar. elements on all levels are eligible. view independent. The low bit of classMask corresponds to class 0 (primary class) which cannot be turned off. propMask is set to MBE_LockedProperty and propVal is set to 0. The array must be one-dimensional.class reference. Example of element location techniques This example uses a number of the MicroStation Basic Extension element location techniques. If the bit is 1. If the bit is 1. otherwise they are not. while the filtering during the element selection logic is simple.a bit map containing one bit for each element type. levelMask . Similarly.a bit map containing one bit for each element class. The low bit of levelMask(0) corresponds to level 1. and can have from 1 to 4 entries. The next bit corresponds to class 1.a bit map containing one bit for each level. etc. to locate only unlocked elements (without caring about the state of other properties bits). and snappable. This example looks complicated because it emulates all of the behavior that MicroStation exhibits when it locates elements: • When you reject an element that is hilited. all element types are eligible. otherwise it is not. etc. the next bit corresponds to element type 2. To indicate that the value of a particular property should be used to determine locate eligibility. it keeps looking around the data point for more elements that have not been processed. elements on the corresponding level are eligible for locate.properties. elements of the corresponding class are eligible for locate. The MicroStation element classes are discussed in the MbeElement.CAD Input Operations elemTypes . and can have from 1 to 8 entries. If classMask is omitted. MicroStation BASIC Guide 8-133 8 MicroStation Extensions to BASIC propVal and propMask . For example. the corresponding element is eligible for locate. the next bit corresponds to level 2. If the array is smaller than 4 entries.

color = saveColor MbeSettings.fromSelectionSet(1) = MBE_Success Then elemSet. skipping elements already processed. '--------------------------------------------------------------' Main subroutine '--------------------------------------------------------------Sub main Dim saveColor as Integer Dim saveWeight as Integer Dim saveMsgs as Integer Dim elemSet as New MbeElementSet ' set up for manipulation by saving the old settings and ' setting new ones saveColor = MbeSettings. • In addition.solicits user for elements 8-134 MicroStation BASIC Guide .messages = saveMsgs MbeWritePrompt MbeWriteCommand End Sub '--------------------------------------------------------------' locate_selectElementsToModify .color = 3 MbeSettings.weight = saveColor MbeState. it provides a step that filters elements so that only elements that are acceptable to the program are presented to the user for acceptance or rejection.color saveWeight = MbeSettings. it uses the accept point to begin looking for more elements to process. it looks for more elements around the same point.weight = 3 MbeState.CAD Input Operations • When you select an element and accept it with a point that is close to the selection point.messages ' set MicroStation to a neutral state MbeSendCommand "NULL" ' get rid of any selection set If elemSet.weight saveMsgs = MbeState.messages = 0 locate_selectElementsToModify MbeWriteStatus "Leaving locate function" ' Clear the messages MbeSettings. • When you select an element and accept it with a point that is not close to the selection point.clear End If MbeSettings.

If MbeState. If haveAcceptPoint Or continueLocate Then Call MbeSendDataPoint(acceptPoint. exit the loop.inputType = MBE_ResetInput Then Exit Do ' On a data point. MBE_ResetInput ' If user resets. retrieve the point for future use. 0. don't allow components. acceptView) continueLocate = FALSE ' If previous element accepted. MicroStation BASIC Guide 8-135 8 MicroStation Extensions to BASIC . then ' send it through to be processed. future comparisons are to ' accept point If haveAcceptPoint Then haveAcceptPoint = FALSE point = acceptPoint view = acceptView firstScreenPt = acceptScreenPt End If Else ' Wait for a data point or a reset MbeGetInput MBE_DataPointInput. continueLocate ' If accepted element or continuing from a reset ' send the previously entered point. '--------------------------------------------------------------Sub locate_selectElementsToModify Dim elem as New MbeElement Dim filePos as Long Dim point as MbePoint Dim acceptPoint as MbePoint Dim acceptScreenPt as MbePoint Dim firstScreenPt as MbePoint Dim stat as Integer Dim view as Integer Dim acceptView as Integer Dim continueLocate as Integer Dim haveAcceptPoint as Integer continueLocate = FALSE haveAcceptPoint = FALSE Do ' Display messages Call locate_displayPrompts() ' Start locating an element.CAD Input Operations ' to modify and manipulates them. ' don't hilite when found. MbeStartLocate 0. ' continue locate from previous element if appropriate. 0. don't put out msgs.

Send resets to the locate logic to cause it to retrieve the next closest element in range 8-136 MicroStation BASIC Guide .cmdResult = MBE_AcceptQuery Then ' if we did not find a line. MBE_ResetInput If MbeState. view. firstScreenPt) haveAcceptPoint = TRUE Else ' user rejected it . accept element and modify it stat = MbeState. acceptView. keep resetting until ' either we find one or we run out of candidates Do filePos = elem.display MBE_NormalDraw acceptPoint = point acceptView = view continueLocate = TRUE End If Exit Do Else ' ' ' ' found element but it’s not acceptable to our filter. elem. firstScreenPt) MbeSendLastInput End If End If ' If we found an element. acceptScreenPt) Call locate_manipulateElement(point.display MBE_Hilite ' prompt the user to accept or reject it MbeWritePrompt "Accept / Reject" ' get data to accept. check for acceptability If MbeState.inputType = MBE_DataPointInput Then stat=MbeState. reset to reject MbeGetInput MBE_DataPointInput. view) ' continue locating if accept ' point near first point continueLocate=locate_pointsCloseEnough( _ acceptScreenPt.continue looking around ' the same point by continuing the locate ' operation in the loop.getInputDataPoint(point.getInputDataPoint( _ acceptPoint.inputType = MBE_DataPointInput Then ' on Data pnt.hilite it elem.CAD Input Operations ElseIf MbeState.fromLocate() If locate_isElementAcceptable(elem) Then ' located an acceptable element .

point2.CAD Input Operations MbeSendReset If MbeState.cmdResult End If Loop End Sub '--------------------------------------------------------------'locate_pointsCloseEnough .type <> MBE_Line ElseIf MbeState.returns TRUE if points roughly 'within the locate tolerance.y) _ < MbeState. view MbeSendDataPoint point. FALSE otherwise '--------------------------------------------------------------Function locate_pointsCloseEnough(point1 as MbePoint.noElementDisplay = 1 ' start change color and relocate element MbeSendCommand "CHANGE COLOR" MbeRelocate point.y .x . view as Integer) Dim elem as New MbeElement Dim filePos as Long ' turn off graphics while changing element MbeState.LocateTolerance Then locate_pointsCloseEnough = TRUE End If End Function '--------------------------------------------------------------' locate_manipulateElement .x) + Abs (point1. view ' start change weight and relocate element MbeSendCommand "CHANGE WEIGHT" MicroStation BASIC Guide 8-137 8 MicroStation Extensions to BASIC .cmdResult = MBE_ElementNotFound Then MbeWriteError "Element Not Found" Else print "unexpected MbeState. This manipulation sequences commands ’ and uses the MbeRelocate subroutine to make the command work ’ on the previously selected element '--------------------------------------------------------------Sub locate_manipulateElement(point as MbePoint.cmdResult of ".point2. MbeState.cmdResult = MBE_ElementNotFound Then Call locate_elementUnacceptable Exit Do End If End If Loop While elem.performs the actual manipulation ' on the selected element. point2 as MbePoint) as Integer If Abs (point1.

view MbeState.type = MBE_Line Then locate_isElementAcceptable = TRUE End If End Function '--------------------------------------------------------------' locate_elementUnacceptable .fromLocate() elem. view MbeSendDataPoint point. '--------------------------------------------------------------Sub locate_elementUnacceptable MbeWriteStatus "Only lines allowed" End Sub '--------------------------------------------------------------' locate_displayPrompts ." If we continue the locate (first we will ' continue with the next element ). view ' Relocate the manipulated element to reset the "locate ' context.CAD Input Operations MbeRelocate point. '--------------------------------------------------------------Function locate_isElementAcceptable(elem as MbeElement) as Integer If elem.reports an error saying that ' no acceptable element was located. MbeSendCommand "NULL" End Sub '--------------------------------------------------------------' locate_isElementAcceptable .returns TRUE if element passes ' filter criteria and FALSE otherwise.display MBE_NormalDraw ' set MicroStation to a neutral state. MbeSendCommand "LOCELE" MbeRelocate point. but this looks ' a bit confusing). set the command so ' the data point sent by MbeRelocate doesn't change the ' weight of an element that may have been selected by ' sending the accept data point to the CHANGE WEIGHT command.tell the user what to identify '--------------------------------------------------------------Sub locate_displayPrompts MbeWriteCommand "Locate Test " 8-138 MicroStation BASIC Guide . ' This section could have been shortened by substituting ' MbeRelocate for the above MbeSendDataPoint.noElementDisplay = 0 ' get the element to redraw it with its new symbology filePos = elem.

_ fileNum as Integer [. The optional arguments have the following meanings: componentFilePos . and it represents the line number within the multiline that is to be located. they are considered to be the point entered by the user to locate the specified element. meaning the master file. point. all the arguments following must be omitted. filePos is required. view . MbeLocateElement. MbeLocateELement directs MicroStation to locate the element specified by the arguments.this argument is valid only if a multiline element is being located. Example Sub main Dim Dim Dim Dim Dim Dim Dim Dim elemSet as New MbeElementSet elem as New MbeElement setMember as MbeSetMember point as MbePoint filePos as Long fileNum as Integer saveGGLk as Integer saveMsgs as Integer ' turn off graphic group lock MicroStation BASIC Guide 8-139 8 MicroStation Extensions to BASIC fileNum . regardless of whether point and view would have resulted in MicroStation locating the specified element or not. componentIndex]]]]] Descr. this is taken to be the same as filePos.CAD Input Operations MbeWritePrompt "Identify line" End Sub See also MbeStartLocate.if the point and view arguments are included. componentFilePos as Long [. and use MbeLocateElement to direct the command to work on the desired element. the last data point entered by the user is used. point as MbePoint [. it can start the appropriate MicroStation command to perform the manipulation. The usefulness of this statement is that when a macro discovers an element that it wants to process (using an MbeElementSet object or reading the elements sequentially). Other values denote reference files by attachment number. and specifies the file position of the outermost header of the element to be located. The default is 0. The remaining arguments are all optional. but if any are is omitted. componentIndex . If the arguments are omitted. The effect of calling MbeLocateELement when a MicroStation command is prompting to locate an element is as if the user entered a data point (at point and view) and located the element specified in the call. MbeLocateElement MbeLocateElement filePos as Long [. .the design file from which the element is to be located. If omitted. _ view as Integer [.the file position of the component element that is to be located.

fromFile(setMember. setMember.fromSelectionSet(1) <> MBE_Success Then If elemSet. 8-140 MicroStation BASIC Guide . MbeLocateElement.getOrigin(point) = MBE_Success Then MbeSendCommand "SCALE" MbeLocateElement setMember.filePos.graphGroupLock = 0 ' turn off messages saveMsgs = MbeState.messages = 0 ' get element set from either selection set or fence If elemSet.fileNum.clear ' restore graphic group lock and messages MbeSettings.CAD Input Operations saveGGLk = MbeSettings.fileNum) If elem.messages = saveMsgs End Sub See also MbeStartLocate.messages MbeState. as accept point ' may select another elem MbeSendCommand "NULL" End If End If End If status = elemSet.getNext (setMember) Loop ' clear selection set elemSet.type = MBE_Text Then If elem.graphGroupLock MbeSettings. setMember.fromFence() <> MBE_Success Then MbeWriteStatus "No fence or selection set" Else MbeWriteStatus "Processing Fence" End If Else MbeWriteStatus "Processing Selection Set" End If ' set an undo mark so we can go back MbeSendCommand "MARK" status = elemSet.componentFilePos.graphGroupLock = saveGGLk MbeState.filePos. point If MbeState. _ elem.cmdResult = MBE_AcceptQuery Then MbeSendDataPoint point ' cancel scale.getFirst(setMember) ' process each graphic group member Do While status = MBE_Success filePos = elem.

z = 5. MbeScalarFromString parses a string of any form accepted by MicroStation to specify a point.y = 0. Y. ' get distString from user If MbeScalarFromString(distance. and point. and converts it to a point in the current coordinate system of the macro (design file master units by default). MbeScalarFromString parses a string of any form accepted by MicroStation to specify a scalar value (a distance..2. inString as String) Descr. the corresponding member of the point MbePoint will be zero.CAD Input Operations MbeScalarFromString stat = MbeScalarFromString(value as Double. MbeAngleFromString stat = MbeAngleFromString(angle as Double. ✍ If inString is null.7”. then point. pntString) = MBE_Success Then ' can use point here End If See also MbeScalarFromString. distString) = MBE_Success Then ' can use distance here End If See also MbePointFromString. MbeStringFromPoint.. Example Dim point as MbePoint Dim pntString as String ' get pntString from user . MbeStringFromScalar.7. for example) and converts it to the current coordinate system of the macro (design file master units by default).5. 0). For example. you will get the point (0. MbePointFromString stat = MbePointFromString(point as MbePoint. If the parsed string omits any of X. The function returns MBE_Success if the string was successfully parsed and MBE_CantParseString (1100) if it could not parse the string. Example Dim distance as Double Dim distString as String . TheinString argument supplies the string and the output is stored in the value argument. inString as String) MicroStation BASIC Guide 8-141 8 MicroStation Extensions to BASIC . 0. MbeAngleFromString. MbeAngleFromString. The function returns MBE_Success if the string was successfully parsed and MBE_CantParseString (1100) if it could not parse the string. 0. inString as String) Descr. If MbePointFromString(point.. 0)..2. This also means that if you enter a null string. The inString argument supplies the string and the output is stored in the point argument.. then point is: (0. point. if inString is “4. or Z.x = 4.

8-142 MicroStation BASIC Guide . MbeStringFromScalar formats a scalar value in the macro’s current coordinate system (design file master units by default) into a string suitable for display to the user. If MbeStringFromScalar(distString. Example Dim angle as Double Dim angString as String ' get angString from user . MbeStringFromPoint stat = MbeStringFromPoint(outString as String. Example Dim point as MbePoint Dim pntString as String ' extract point from element . The function returns MBE_Success if the string was successfully parsed and MBE_CantParseString (1100) if it could not parse the string.. The inString argument supplies the string and the output is stored in the angle argument. MbeStringFromPoint formats point in the macro’s current coordinate system (design file master units by default) into a string suitable for display to the user. value as Double) Descr. The function returns MBE_Success.. except in the rare instance that it runs out of memory creating the output string. point as MbePoint) Descr. in which case it returns MBE_OutOfMemory (7).. angString) = MBE_Success Then ' can use angle here End If See also MbeScalarFromString. The format is determined by the settings in MicroStation’s Coordinate Readout dialog. in which case it returns MBE_OutOfMemory (7).. MbeStringFromScalar stat = MbeStringFromScalar(outString as String. If MbeAngleFromString(angle. and converts it to an angle in radians as a Double. The format is determined by the settings in MicroStation’s Coordinate Readout dialog. distance) = MBE_Success Then MbeWriteStatus “distance is “ & distString End If See also MbeStringFromPoint.. MbeStringFromAngle. MbeStringFromAngle.. MbePointFromString. The function returns MBE_Success.CAD Input Operations Descr. except in the rare instance that it runs out of memory creating the output string. MbeScalarFromString parses a string of any form accepted by MicroStation to specify an angle. MbeScalarFromString. Example Dim distance as Double Dim distString as String ' calculate a distance .

MbeGetConfigVar function returns the expansion of the configuration variable specified by cfgVarName. It must include the root filename. angle) = MBE_Success Then MbeWriteStatus “angle is “ & angString End If See also MbeStringFromPoint.CAD Input Operations If MbeStringFromPoint(pntString. The format is determined by the settings in MicroStation’s Coordinate Readout dialog. Example Dim angle as Double Dim angString as String ' calculate an angle . point) = MBE_Success Then MbeWriteStatus “point is “ & pntString End If See also MbeStringFromScalar. angle as Double) Descr. "Environ$". except in the rare instance that it runs out of memory creating the output string.. MbeStringFromScalar. _ cfgVarName as String [. MbeStringFromAngle. MbeFindFile stat = MbeFindFile(fileName as String. If MbeStringFromAngle (angString. in which case it returns MBE_OutOfMemory (7). MbePointFromString. MbeAngleFromString. extension as String ]]) Descr.. inputName as String [. MbeGetConfigVar string = MbeGetConfigVar(cfgVarName as String) Descr. The fileName argument is set to the name of the file if it is found. and it can optionally include a directory or a MicroStation BASIC Guide 8-143 8 MicroStation Extensions to BASIC . MbeStringFromAngle stat = MbeStringFromAngle(outString as String. The function returns MBE_Success. Configuration variables are used by MicroStation to specify directories and files. Example Dim defaultDgnDir as String defaultDgnDir = MbeGetConfigVar("MS_DEF") See also MbeFindFile. inputName specifies the file as a user might enter it. MbeStringFromAngle formats the angle in radians into a string suitable for display to the user. MbeStringFromAngle. and in some cases to specify operational parameters. an empty string is returned. MbeFindFile attempts to find the specified file. They are modified using the Configuration Variables dialog box. If cfgVarName is not in the configuration variable table.

MbeFindFile returns MBE_Success if the file is found and MBE_FileNotFound (53) otherwise. Example Submain() ' Restart the Element Selection tool . "MS_CELL". The filename components included in the inputName argument are used first in searching for the file. and must including the trailing path separator character. and/or an extension. MbeStartDefaultCommand MbeStartDefaultCommand Descr. Use the statement to return MicroStation to a known state at the end of a macro. Example Dim cellLibrary as String If MbeFindFile(cellLibrary.cell") = MBE_Success Then MbeSendCommand("ATTACH LIBRARY " & cellLibrary) End If See also MbeFindFile.. The optional cfgVarName argument can be used to specify a configuration variable that specifies one or more directories to search for the file. The optional extension argument can be used to specify a default extension for the file that is used if no extension is provided in inputName. but in that case the directory specification must be appropriate to the operating system MicroStation is running on. Alternatively. it can specify a directory.CAD Input Operations configuration variable specifying a directory. MbeStartDefaultCommand EndSub 8-144 MicroStation BASIC Guide . "arch2d". ".. This statement starts the default command .generally the ElementSelection tool. If inputName includes a directory or extension. they will not be overridden by the other arguments in trying to find the file.

filter contains the filter to use for determining which files to include in the file list. _ filter as String. An asterisk (*) matches any string and a question mark (?) matches any single character. It is useful for limiting files displayed to a particular type. directory contains the directory where the selection process starts. Upon successful return. Solicit string input from a user.directory as String. If directory is an empty string. It returns 1 if the user clicked the Cancel button. This argument can be overwritten with the suggest argument. MicroStation BASIC Guide 8-145 8 . MbeFileCreate MicroStation Extensions to BASIC MbeFileOpen as Long (filename as String [. Simple wild carding is allowed.*). _ filter as String. suggest suggests a filename for opening or creating a file. Display a message in a dialog box using one of a variety of icons or pushbutton configurations. the current working directory will be used. the directory associated with the variable is used. the filename argument will contain the name of the file to be opened or created. MbeFileCreate (page 8-145) MbeMessageBox (page 8-146) MbeInputBox (page 8-147) MbeSelectBox (page 8-147) MbeOpenModalDialog (page 8-148) Used to Obtain a file name using the standard MicroStation file Open dialog box. If a directory is attached to the filename.title as String]) MbeFileCreate as Long (filename as String [. In the latter case. but can also be an environment variable. This argument should normally be an empty string when it is called for opening files.suggest as String. or an error if the dialog box could not be opened.suggest as String. If filter is an empty string. MbeFileOpen.directory as String.Dialog Box Statements Dialog Box Statements Statement and Functions MbeFileOpen. Open a customized dialog box that was previously generated for the macro using the Dialog Builder. Display a list of items in a dialog box and obtain a selection of one of the items in the list. It displays in the text field of the dialog. this argument serves as the default directory and the directory argument is ignored. the filter string will match all files (*.title as String]) Descr. The MbeFileOpen and MbeFileCreate functions lets the user conveniently choose a file (through a dialog box) for opening or creating. They return MBE_Success if the user chose a file name and clicked the OK button.

Dialog Box Statements title contains the title of the dialog box.") End If MbeMessageBox stat=MbeMessageBox(msg as String [. Display Yes. The function returns a Long which button was selected. The following values may be stored in type along with the button specification using the OR operator: 8-146 MicroStation BASIC Guide . filter$.") Else button = MbeMessageBox("File not selected. directory$. The following values are valid: Constant MBE_BUTTON_OK MBE_BUTTON_CANCEL MBE_BUTTON_YES MBE_BUTTON_NO Value 3 4 6 7 Description OK was pressed. Cancel was pressed. No was pressed. The msg string can contain new line characters to separate lines in the message. Yes was pressed. Display OK and Cancel buttons. type is also used to specify an icon in the dialog to be displayed with the message. Long lines in the message are automatically word-wrapped to the next line. Example suggest$ = "junk. title$) If status = MBE_Success Then button = MbeMessageBox("Selected filename is (" + filename$ + "). The MsgBox function displays the message contained in msg in a dialog box with a set of predefined buttons and optional alert icon. Display Yes and No buttons. No and Cancel buttons. suggest$. The defaults button is the OK button. The following values are valid: Constant MBE_OKBox MBE_OKCancelBox MBE_YesNoBox MBE_YesNoCancelBox Value 1 3 12 14 Description Display OK button only. The type parameter may be used to specify which pushbuttons and which icon (if any) should be displayed.type as Long]) Descr.bas" filter$ = "*. The default behavior is “no icon”.bas" directory$ = "MS_MACRO" title$ = "Choose a Macro File to Open" filename$ = "" status = MbeFileOpen(filename$.

Display “question mark” icon. Press OK to continue. If title is not specified. MBE_YesNoBox or MBE_QuestionIcon) If button = MBE_BUTTON_NO Then ’ Statements to abort processing. Display “information” icon. prompt can contain multiple lines. then no title appears in the dialog box’s title bar. _ title as String]) Descr. each separated with a newline character (Chr$(10)).Dialog Box Statements returns one of the following values: Constant MBE_CriticalIcon MBE_QuestionIcon MBE_InfoIcon MBE_WarningIcon Value 256 512 1024 2048 Description Display “stop” icon. items as String(). The MbeInputBox method prompts the user for input into a text field in the Input dialog box. If the user cancels the dialog box.") Else button = MbeMessageBox ("Error found. Continue processing?".. an empty string is returned.. End If End If MbeInputBox string = MbeInputBox(prompt as String [. Display “exclamation point” icon. _ title as String) MicroStation BASIC Guide 8-147 8 MicroStation Extensions to BASIC . title specifies the text that appears in the dialog box’s title bar. See also MbeSelectBox. If status = MBE_Success Then button = MbeMessageBox ("Success. MbeSelectBox MbeSelectBox as Integer(prompt as String.defaultText as String. defaultText may be used to specify an initial entry in the input text field. It returns the text contained in the text field when the user clicks the OK button.

An index value of -1 is returned if the user clicks the Cancel button. prompt is provided to instruct the user to select an item from the list. -1 is returned as the button value. It returns one of the following standard button values or a user-defined button value (a positive integer >= 1000). then no title appears in the dialog box’s title bar. items is used to construct the selection list. the dialog remains on the screen until the user dismisses it.Dialog Box Statements Descr. It must be a single dimension array of strings. The MbeSelectBox method displays a dialog box containing a list of items. MbeOpenModalDialog MbeOpenModalDialog as Long (dialogId as Long [. It appears directly above the list in the dialog box. dialogId is the identifier of the custom dialog to be displayed. the index of that item is returned. If not supplied. See also MbeInputBox.timeout as Integer _ [timeoutButton as Integer]]) Descr. title specifies the text that appears in the dialog box’s title bar. The optional timeout parameter specifies the number of seconds that the dialog is to remain on the screen before being closed automatically. If title is not specified. 8-148 MicroStation BASIC Guide . Constant MBE_BUTTON_APPLY MBE_BUTTON_OK MBE_BUTTON_CANCEL MBE_BUTTON_DEFAULT MBE_BUTTON_YES MBE_BUTTON_NO MBE_BUTTON_RETRY MBE_BUTTON_STOP Value 1 3 4 5 6 7 8 9 If the custom dialog could not be loaded. The MbeOpenModalDialog method is used to display a customized dialog box designed by the user. If the user selects an item and clicks the OK button.

(this only applies if the timeout parameter was supplied and a timeout occured).Dialog Box Statements The optional timeoutButton parameter is used to set the button value associated with a custom dialog that was dismissed because the timeout value is MBE_BUTTON_OK. MicroStation BASIC Guide 8-149 8 MicroStation Extensions to BASIC .

column(iCol) Next iCol end sub See also MbeSqlda.MbeSqlda Object MbeSqlda Object Statement and Functions MbeSqlda.length (page 8-151) MbeSqlda.numColumns is a read only Integer property which gets the total number of fields available in MbeSqlda object.scale (page 8-152) MbeSqlda.numColumns-1 print sqlda. Get whether null is allowed. MbeSqlda.column (page 8-150) MbeSqlda. Get the field type.numColumns Descr. Get the field value.precision (page 8-152) MbeSqlda.numColumns. Example sub listAllColumns(dim sqlda as new MbeSqlda) dim iCol as Integer For iCol=0 To iCol=sqlda.column.type (page 8-151) MbeSqlda. Get index for a field name.numColumns (page 8-150) MbeSqlda.column(index as Integer) Descr.isNull (page 8-151) MbeSqlda. Get total chars in a field. See also MbeSqlda.numColumns.value(index as Integer) 8-150 MicroStation BASIC Guide . MbeSqlda.getIndex (page 8-152) Used to Get total number of fields.value MbeSqlda. MbeSqlda. MbeSqlda. MbeSqlda.value (page 8-150) MbeSqlda. Get the scale portion of the field. Get the field name.numColumns MbeSqlda.column MbeSqlda. index must be greater than or equal to 0 and less than MbeSqlda. Get the field length.column is a read-only String property which retrieves the index field name from the MbeSqlda object.

type can be one of the following values: MBE_DBChar. MbeSqlda. MbeSqlda.numColumns. index must be greater than or equal to 0 and less than MbeSqlda.numColumns. MbeTable.recordNext.isNull(index as Integer) Descr.numColumns. MbeSqlda.isNull MbeSqlda. MBE_DBDate.value(iCol)) exit for End If Next iCol End Function See also MbeSqlda.type.length MbeSqlda.length is significant only where MbeSqlda. See also MbeSqlda.numColumns.value. MbeSqlda.type(index as Integer) . index must be greater than or equal to 0 and less than MbeSqlda.numColumns. MbeTable. MbeSqlda. See also MbeSqlda.numColumns. MBE_DBInteger. index must be greater than or equal to 0 and less than MbeSqlda.column(iCol)="MSLINK" Then getMslink=var(sqlda. MBE_DBRaw or MBE_DBBinary.length is a read-only Integer property which retrieves the length of the index field value from the MbeSqlda object.type(index) is MBE_DBCHAR and returns zero for all other type fields.isNull is a read-only boolean property which returns TRUE or FALSE depending on if nulls are allowed in index field of the MbeSqlda object. MbeSqlda.MbeSqlda Object Descr.value is a read-only String property which retrieves the index field value from the MbeSqlda object. MbeSqlda.numColumns-1 If sqlda. MbeSqlda.length(index as Integer) Descr. MbeSqlda.recordFirst. See also MbeSqlda. MBE_DBNumber. index must be greater than or equal to 0 and less than MbeSqlda.type is a read-only String property which retrieves the index field type from the MbeSqlda object. MbeSqlda. MbeSqlda.numColumns.type Descr.numColumns. MbeSqlda.column(iCol)="mslink" Or sqlda.column. Example Function getMslink(sqlda as MbeSqlda) as Long dim iCol as Integer For iCol=0 To iCol=sqlda. MicroStation BASIC Guide 8-151 8 MicroStation Extensions to BASIC MbeSqlda.

See also MbeSqlda. MbeSqlda. MbeSqlda.precision(index as Integer) Descr. 8-152 MicroStation BASIC Guide .numColumns. MbeSqlda. MbeSqlda.type.scale MbeSqlda.MbeSqlda Object MbeSqlda. MbeSqlda.getIndex(fieldname as String) Descr. index must be greater than or equal to 0 and less than MbeSqlda. MbeSqlda. See also MbeSqlda. index must be greater than or equal to 0 and less than MbeSqlda.precision is a read-only Integer property which returns the maximum number of characters in the number field at index field position of the MbeSqlda object. MbeSqlda.column.scale.scale(index as Integer) Descr.type. MbeSqlda.numColumns.numColumns.getIndex is a read-only Integer property which returns the position of the field having name fieldname in MbeSqlda object.numColumns. MbeSqlda.getIndex MbeSqlda. index must be greater than or equal to 0 and less than MbeSqlda.type.numColumns. See also MbeSqlda.precision MbeSqlda.scale is a read-only Integer property which returns the maximum number of digits after the decimal for the index field of the MbeSqlda object.

Example Sub setTableName(tb as MbeTable.name (page 8-153) MbeTable.recordUpdate (page 8-158) MbeTable. MbeTable. Get next record in the table.recordFirst (page 8-156) MbeTable.largestMslink (page 8-154) MbeTable. Makes a duplicate table structure. Get the largest MSLINK key.create. A valid MbeTable. Create a new table.name=tbName end sub See also MbeTable.name MbeTable.name Descr.activeReview (page 8-154) MbeTable.copy (page 8-159) MbeTable. Get or set review filter. MbeTable.entityNumber (page 8-154) MbeTable. MbeTable.object. Insert a row in the table.name is a read/write String property which sets or retrieves the name of the MbeTable object.create (page 8-159) MbeTable.criteria Descr.criteria must be of the formats: MicroStation BASIC Guide 8-153 8 MicroStation Extensions to BASIC .reportTable (page 8-155) MbeTable. Drop the table from database. Delete the specified row.MbeTable Object MbeTable Object Statement and Functions MbeTable.criteria is a read/write String property which sets or retrieves the current selection criteria for MbeTable. Update the specified row. tbName as String) tb.recordInsert (page 8-158) MbeTable. MbeTable.criteria MbeTable. Get or set report table. Describes the table.recordLast (page 8-157) MbeTable.recordNext (page 8-157) MbeTable. Get the last record.drop (page 8-160) Used to Get or set the table object name. Get or set the selection criteria.criteria (page 8-153) MbeTable. Get the entity number for the table.describe (page 8-156) MbeTable. This should be set before using any other methods of the MbeTable object. Get the first record.recordDelete (page 8-159) MbeTable.

largestMslink.name.name.activeEntity <> tb. MbeTable.defineActiveEntity tb.criteria="firstname.largestMslink Endif end sub See also MbeTable. MbeTable.largestMslink is a read-only property of type Long and retrieves the highest MSLINK key of the table in the MbeTable. MbeTable.object.largestMslink Descr. Example Sub defineActiveEntity(tb as MbeTable) dim db as New MbeDatabase If db.activeEntity.entityNumber. MbeTable. tb.expr][where condition]" ’-select only firstname and lastname where mslink is greater than 5 tb.activeReview 8-154 MicroStation BASIC Guide .entityNumber MbeTable.entityNumber Then db. tb.entityNumber Descr. MbeTable.recordFirst.largestMslink Endif end sub See also MbeTable.entityNumber Then db.criteria="where lastName=’Smith’" ’-select all fields with no condition tb.activeEntity.MbeTable Object "[column(s)][. Example Sub defineActiveEntity(tb as MbeTable) dim db as New MbeDatabase If db. lastname where mslink > 5" ’-select all fields where lastName is ’Smith’ tb.entityNumber is a read-only Integer property which retrieves the entity number for the table in the MbeTable object.name.largestMslink MbeTable.activeEntity <> tb. MbeDatabase.activeReview MbeTable. MbeDatabase.defineActiveEntity tb.criteria="" See also MbeTable. MbeTable.

reportTable="" Then See also MbeElement.fenceFilter MbeTable. MbeTable.reportOpen.activeReview is equivalent to the MicroStation ACTIVE_REVIEW keyin (RA=).rewrite.fenceFilter="" Then filterString="select ownername. MbeDatabase.name tb. The fence filter limits all fence operations to only those elements which meet the database criteria expressed by this SELECT statement. MicroStation BASIC Guide 8-155 8 MicroStation Extensions to BASIC reviewString="select mslink.activeReview="" Then reviewString="select mslink.reportTable MbeTable.reportTable is a read/write String property which sets or retrieves the report table name used during FENCE REPORT operations for the table in MbeTable object.fenceFilter Descr. MbeTable.reportTable Descr. mslink from " + tb. MbeTable.name tb.name tt.activeReview is a read/write String property which sets or retrieves the SQL SELECT statement specifying a subset of the table in MbeTable object. Example If tb.MbeTable Object Descr.activeReview is a read/write String property which sets or retrieves the SQL SELECT statement used for attribute review operations for the table in MbeTable object. MbeTable.fenceFilter=filterString Endif See also MbeElement.review. Example If tb. MbeTable. mapname from " + tb. MbeTable.reportDBLinkages. mapname from " + tb.activeReview=reviewString Endif See also MbeElement. Example If tb.reportTable="parcel_tab" Endif .

name=table If tb.recordFirst(sqlda as MbeSqlda) Descr. Example Sub getFirstSmith(table as String) Dim tb as New MbeTable Dim sqlda as New MbeSqlda Dim idx as Integer tb.numColumns -1 Call processFields(sqlda.value(0).sqlda.describe(sqlda) = MBE_Success Then For idx=0 To sqlda.MbeTable Object MbeTable. Example Sub profileTable(table as String) Dim tb as New MbeTable Dim sqlda as New MbeSqlda Dim idx as Integer tb. A new MbeSqlda object should be passed to the function to receive the table structure. MbeSqlda.describe(sqlda as MbeSqlda) Descr.output the result print tab(2).column(idx)) Next idx End If end Sub See also MbeSqlda.name=table ’--.recordNext.create a query tb."First Name:".value(2) End If End sub See also MbeSqlda.describe method describes the structure of the underlying table in MbeTable object.describe stat = MbeTable.recordFirst(sqlda)=MBE_Success Then ’--.column. MbeSqlda.criteria="where lastName=’Smith’" If tb. MbeDatabase.sqlda.recordFirst method retrieves the first record from the table according to the criteria set in the MbeTable object. MbeTable. The MbeTable. MbeTable.value. MbeTable.numColumns. 8-156 MicroStation BASIC Guide .describe. The MbeTable.recordFirst stat = MbeTable.numColumns."mslink:".recordLast.tab(44). A new MbeSqlda object should be passed to the function to receive query result.

recordFirst. sqlda.sqlda.output the result print tab(2).tab(44).create a query tb.recordNext(sqlda as MbeSqlda) Descr. .sqlda. The MbeTable.criteria="where lastName=’Smith’" If tb. Example Sub getAllSmiths(table as String) Dim tb as New MbeTable Dim sqlda as New MbeSqlda Dim idx as Integer tb. MbeTable. MbeTable.value(2) End If End sub MbeTable. The MbeTable.recordLast(sqlda as MbeSqlda) Descr.create a query tb.value(2) Loop while tb.recordNext method retrieves the Next record from the table according to the criteria set in the MbeTable object.name=table ’--.recordNext(sqlda)=MBE_QueryNotFinished End If End sub Return MicroStation BASIC Guide 8-157 8 MicroStation Extensions to BASIC See also MbeSqlda. A new MbeSqlda object should be passed to the function to receive query result.MbeTable Object MbeTable.recordNext.criteria="where lastName=’Smith’" If tb.recordLast(sqlda)=MBE_Success Then ’--.recordFirst(sqlda)=MBE_Success Then ’--."mslink:"."mslink:".recordNext. A new MbeSqlda object should be passed to the function to receive query result.recordLast stat = MbeTable.recordFirst should be called before the first MbeTable. Example Sub getLastSmith(table as String) Dim tb as New MbeTable Dim sqlda as New MbeSqlda Dim idx as Integer tb.output the result Do print tab(2).value(0).sqlda."First Name:".value. MbeTable.value(0).name=table ’--."First Name:".recordLast method retrieves the last record from the table query according to the criteria set in the MbeTable object.tab(44).recordNext stat = MbeTable.

recordInsert. 'Tim'. MbeTable. Example Sub renameSmithToJohn(table as String) Dim tb as New MbeTable Dim mslink as long tb.recordNext returns MBE_QueryNotFinished if there is more to retrieve and returns MBE_QueryFinished when query is finished. Example Sub insertThreeRecords(table as String) Dim tb as New MbeTable tbname = table tb. 8-158 MicroStation BASIC Guide . mslink is a Long specifying the row to change and updateList a string containing columns and values to changed.recordLast.recordInsert "firstname. The MbeTable.lastname.recordUpdate mslink as long.recordUpdate command updates the row specified by the mslink value passed.recordUpdate mslink.recordInsert "'Michael'.recordInsert needs a string argument with the column values to be inserted.recordDelete.recordInsert command inserts a row to the table in the MbeTable object.criteria = "where lastName = 'Smith'" If tb. “lastname = ‘John’” Loop while tb. lastname values 2.recordInsert stat=MbeTable.recordInsert insertString as String Descr. It can be a list of values separated by commas or list of columns and their values separated with a ‘values’ clause. MbeTable. The MbeTable. mslink values 'Matt'.recordFirst.recordUpdate MbeTable. MbeTable. 'Best'" tb. firstname.recordInsert "mslink. 3" end sub See also MbeTable.recordDelete.recordNext(sqlda) = MBE_Success End If end sub See also MbeTable. updateList as String Descr.name = table tb.value(2)) tb. MbeTable. 'Smith'.1" tb. MbeTable. See also MbeSqlda.recordFirst(sqlda) = MBE_Success Then Do mslink = val(sqlda.value. MbeTable.MbeTable Object MbeTable. MbeTable.recordUpdate needs two arguments. MbeTable.'Smith'.recordUpdate.

create MbeTable. The MbeTable.recordDelete command deletes the row specified by the mslink value passed.create.copy MbeTable. MbeTable. columnList defines the columns and optional column constraints of the table. The MbeTable.recordUpdate.recordDelete mslink Loop while tb.recordDelete mslink as Long Descr. Refer to your Database manuals for more information on CREATE TABLE syntax. MbeTable.recordInsert.recordFirst(sqlda) = MBE_Success Then Do mslink = val(sqlda. Rows for the existing table are not copied into the new table.recordNext(sqlda) = MBE_Success End If end sub See also MbeTable.value(2)) tb.copy newTableName as String Descr.create columnsList as String Descr. MbeTable.copy command creates a new table with the same structure as the existing table in the MbeTable object.recordInsert. Example Sub removeAllMedlocks(table as String) Dim tb as New MbeTable Dim sqlda as New MbeSqlda Dim mslink as long tb. Example Sub copyTable(newTableName as String) Dim tb as New MbeTable tb. Example Sub createTable (tableName as String) Dim tb as New MbeTable MicroStation BASIC Guide 8-159 8 MicroStation Extensions to BASIC .criteria = "where lastName = 'Jones'" If tb. MbeTable.create command creates a new table with the column list specified.MbeTable Object MbeTable.recordDelete MbeTable.copy newTableName end sub See also MbeTable.name = table tb. The MbeTable.name = table tb.

drop. lastname char(20). MbeTable. 8-160 MicroStation BASIC Guide .drop MbeTable.MbeTable Object tb.drop method removes the table in MbeTable object and all its data from the database.drop end sub See also MbeTable. mslink int" end sub See also MbeTable.recordInsert. The MbeTable.create "firstname char(20).create.drop Descr.name = tableName tb. Example Sub dropTable (tableName as String) Dim tb as New MbeTable tb. MbeTable.name = tableName tb.

Retrieves table names in an array.activeEntity (page 8-162) MbeDatabase.) Get or set the active displayable attribute type. Connect the database to MS Disconnect the database.connect (page 8-163) MbeDatabase. It extracts the active database name if no name is set for the MbeDatabase object. Get or set the linkage mode (new. Example Sub databaseConnect(dbName as String) Dim db as New MbeDatabase If db.name is a read/write String property which sets or retrieves the database name.name = “” Then db. Let user edit the AE if any. Close the report tables. Define AE from an SQL statement Shows current AE if any. duplicate. Initializes all report tables. Get detailed text for an error code. Get or set screen forms mode.connect MicroStation BASIC Guide 8-161 8 MbeDatabase.dAType (page 8-167) MbeDatabase.modeConfirm (page 8-165) MbeDatabase. etc. Set database commit mode.describe (page 8-163) MbeDatabase.MbeDatabase Object MbeDatabase Object Statement and Functions MbeDatabase.reportClose (page 8-167) Used to Get or set database name.modeLinkage (page 8-166) MbeDatabase.name = dbName db.name MicroStation Extensions to BASIC .errorText (page 8-162) MbeDatabase.showActiveEntity (page 8-164) MbeDatabase.reportOpen (page 8-167) MbeDatabase.defineActiveEntity (page 8-164) MbeDatabase.modeForms (page 8-166) MbeDatabase. Get or set the database rows delete mode.editActiveEntity (page 8-164) MbeDatabase.mslink (page 8-162) MbeDatabase. MbeDatabase.disconnect (page 8-163) MbeDatabase.name (page 8-161) MbeDatabase. MbeDatabase. Get or set the confirmation mode. Get MSLINK key field of a record.modeCommit (page 8-165) MbeDatabase.modeDelete (page 8-165) MbeDatabase.name Descr. Get the current active entity.

activeEntity = tb. MbeDatabase. MbeTable.defineActiveEntity tb. MbeDatabase. Example Sub defineActiveEntity(tb as MbeTable) dim db as New MbeDatabase If db.mslink MbeDatabase.largestMslink Then db. MbeDatabase.entityNumber.errorText stat = MbeDatabase. errorCode as Integer) Descr. MbeDatabase.defineActiveEntity.name.activeEntity MbeDatabase. MbeDatabase.entityNumber Then db.entityNumber Then If db.largestMslink End If End If end sub See also MbeDatabase.mslink Descr. MbeTable.defineActiveEntity tb.largestMslink End If end sub See also MbeDatabase. Returns MbeDatabase.defineActiveEntity.MbeDatabase Object End If end sub See also MbeDatabase.activeEntity Descr. tb.mslink. MbeDatabase.errorText method retrieves a detailed description in errorDescr for the errorCode. tb.activeEntity. The MbeDatabase.entityNumber. MbeDatabase.errorText returns MBE_Success if errorCode is a valid database error.mslink <> tb. Example Sub handleDBError(errorCode as integer) dim db as New MbeDatabase 8-162 MicroStation BASIC Guide .connect. Example Sub defineActiveEntity(tb as MbeTable) dim db as New MbeDatabase If db.activeEntity is a read only Integer property which returns the current active entity number if defined any and else returns 0.errorText(errorDescr as String.name.mslink is a read only Integer property which returns the MSLINK key field of the current active entity record.activeEntity <> tb.

disconnect MbeDatabase.name. MbeDatabase.name. The MbeDatabase. MbeTable.disconnect method disconnects the database from MicroStation.connect connectString See also MbeDatabase.describe. MbeTable. See also MbeDatabase. MicroStation BASIC Guide 8-163 8 Descr. Returns MbeDatabase.disconnect is equivalent to |DISCONNECT key-in in MicroStation. it will try to connect using the MbeDatabase.disconnect.describe returns numTables an Integer which specifies the total number of tables available in tableArray.MbeDatabase Object dim txt as String If db.errorText(txt. tableArray. MbeDatabase.connect is equivalent to DB=<schema> or |CONNECT commands in MicroStation. MicroStation Extensions to BASIC . The MbeDatabase. MbeDatabase.name.connect.name if it is set. MbeDatabase. The MbeDatabase.describe function retrieves names of all the tables in the database and puts them in a dynamically allocated string array.describe(tableArray() as String) Descr.describe(tabArray) If numTables <> 0 Then For idx =0 To numTables -1 processTable(tabArray(idx)) Next idx End If end sub See also MbeTable. If no argument is supplied.connect MbeDatabase.connect command connects the database to MicroStation.disconnect Descr. errorCode) = MBE_Success Then MbeMessageBox(txt) End If end sub MbeDatabase. MbeDatabase.describe numTables = MbeDatabase. Example Sub processAllTables(db as MbeDatabase) dim tabArray() as String dim numTables as Integer dim idx as integer numTables = db.

showActiveEntity MbeDatabase. MbeDatabase.modeLinkage) is DUPLICATE. MbeDatabase.attachActiveEntity.defineActiveEntity MbeDatabase. MbeDatabase. See also MbeElement.editActiveEntity MbeDatabase. MbeDatabase. The active entity is the target row to which graphics elements will be linked. This case is equivalent to MicroStation ACTIVE ENTITY (AE=) key-in. MbeDatabase.modeLinkage. MbeDatabase. See also MbeElement. MbeDatabase.mslink.defineActiveEntity Select_Statement as String Insert_Statement as String tablename as String. MbeDatabase.editActiveEntitym.MbeDatabase Object MbeDatabase. If the linkage mode is NEW.showActiveEntity is equivalent to the MicroStation SHOW AE key-in.attachActiveEntity. The MbeDatabase. If the SELECT statement returns multiple rows the first one is used as the basis for the active entity.defineActiveEntity is equivalent to FI = select * from tablename where mslink = mslink command. MbeDatabase. If a tablename and a mslink value are passed.defineActiveEntity MbeDatabase. MbeDatabase.defineActiveEntitym.editActiveEntity.modeLinkage. 8-164 MicroStation BASIC Guide . This case is equivalent to the MicroStation FIND (FI=) key-in.defineActiveEntity MbeDatabase.activeEntitym. If only tablename is passed it will try to define active entity using ‘FI= select * from tablename ‘ command. the active entity represents an actual table row and edits are written directly to the database. The MbeDatabase.defineActiveEntity MbeDatabase. mslink as long tablename as String Descr. MbeDatabase.defineActiveEntity command defines a new active entity using the parameters passed.showActiveEntity.editActiveEntity method displays the active entity and allows editing of the individual fields. the active entity is a prototype row. Select_Statement is an SQL SELECT statement.showActiveEntity Descr. and edits are written in-memory only. If the active linkage mode (MbeDatabase.showActiveEntity method displays the active entity if defined one. MbeDatabase. The MbeDatabase. The active entity is the target row to which graphics elements will be linked.editActiveEntity Descr. Insert_Statement is an SQL INSERT statement with no mslink field as MicroStation will automatically assign an mslink when a linkage is created.

defineActiveEntity. See also MbeElement.activeEntity.modeCommit = autoCommitMode as Integer Descr. Informix. MbeTable. deleteRows is TRUE when linked rows are to be MicroStation BASIC Guide 8-165 8 MicroStation Extensions to BASIC . MbeDatabase. MbeDatabase. MbeDatabase.modeCommit is a write only boolean property which controls when a transaction-capable database commits work. MbeTable.modeConfirm Descr.recordInsert. The DEFINE AE and ATTACH DA commands require selecting a graphics element which may contain more than one linkage. MicroStation will prompt for confirmation of the row in the SQL Window.attachActiveEntity.modeConfirm = confirmRows as Integer confirmRows = MbeDatabase.modeCommit MbeDatabase. MbeDatabase. If there are multiple linkages and confirmRows is TRUE. Normally.modeDelete MbeDatabase. MbeDatabase.showActiveEntity.recordDelete. MbeDatabase. MbeDatabase. MbeDatabase. Work performed since the last COMMIT may be undone by submitting a ROLLBACK. See also MbeTable. MbeDatabase. Most RDBMSs (Oracle.modeDelete = deleteRows as Integer Descr.modeConfirm is equivalent to the MicroStation SET CONFIRM (ON | OFF) key-in. A transaction is a unit of work which must be committed in its entirety before being posted to the database.editActiveEntity equivalent to the MicroStation EDIT AE key-in.modeConfirm MbeDatabase.modeDelete is a write only boolean property which controls whether database rows linked to graphics elements are deleted when the graphics element is deleted or the linkages are detached.MbeDatabase Object MbeDatabase. MbeDatabase.mslink. Ingres) support the concept of transactions.recordUpdate. MbeDatabase.modeLinkage. the first linkage on the element will be selected. the MicroStation database interfaces immediately commit each SQL statement as it is processed. Applications which require greater control over database operations can turn off automatic commits. If confirmRows is FALSE.modeConfirm is a read/write boolean property which controls when MicroStation prompts for confirmation on a database operation which requires selecting a graphics element with an existing linkage. MbeDatabase.

See also MbeDatabase.attachActiveEntity.modeLinkage is equivalent to the MicroStation key-in ACTIVE LINK (NEW | DUPLICATE | INFORMATION | NONE).modeLinkage is a write only String property which sets the active database linkage mode. MbeElement.modeDelete is equivalent to the MicroStation SET DELETE (ON | OFF) key-in. MicroStation uses the linkage mode to determine when to add new rows to the database. MbeDatabase.modeForms is equivalent to the MicroStation SET FORMS (ON | OFF) key-in. When linkages are attached to graphics elements and when elements are copied. Descr. MbeDatabase. MbeDatabase. 8-166 MicroStation BASIC Guide . If useForms is FALSE then the SQL Window dialog box is used.defineActiveEntity.modeLinkage MbeDatabase.MbeDatabase Object deleted during graphics delete and detach linkage operations. If useForms is TRUE then the screen forms defined in MSCATALOG for each entity is used for attribute review. MbeDatabase. The linkage mode controls how and when MicroStation adds new rows to the database.modeForms = useForms as Integer useForms = MbeDatabase. MbeDatabase.editActiveEntity. The string may be one of the following values: String Value Description "new" "duplicate" "information" "none" each element is linked to a different row many elements may be linked to the same row like duplicate mode but don't contribute to reports no linkages possible MbeDatabase.showActiveEntity.attachActiveEntity. MbeDatabase. See also MbeDatabase. The argument mode is a character string which specifies the linkage mode. A value of FALSE means delete and detach operations have no effect on linked rows.modeLinkage = mode as String Descr. See also MbeElement. MbeDatabase. Changing the linkage mode will clear the active entity.modeForms Descr.modeForms MbeDatabase.modeForms is a read/write boolean property which controls when MicroStation uses screen forms for attribute review and editing.

reportClose.reportDBLinkages.reportClose Descr.reportOpen command initializes the report tables in the database to prepare for report generation. Subsequent reporting operations must be preceded by MbeDatabase. The MicroStation command ACTIVE REPORT defines the report table names. The displayable attribute type is an index into the displayable attribute table defined for each entity in MSCATALOG.dAType is equivalent to a MicroStation ACTIVE DATYPE (DA=) key-in. as defined by the MicroStation command ACTIVE REPORT. MbeDatabase.reportTable.reportClose MbeDatabase. The MbeDatabase. MbeDatabase. MbeDatabase.reportTable. MbeDatabase. MbeDatabase.loadDAttributes.reportOpen. are deleted.MbeDatabase Object MbeDatabase.dAType Descr. MbeTable.dAType = daCode as Integer dACode = MbeDatabase. The report table contents. See also MbeElement. The displayable attribute type is used when MicroStation builds a displayable attribute linkage for a text node during the ATTACH DA command.reportClose command closes report tables in the database after report generation.dAType MbeDatabase. MbeTable. daType is an integer value between 1 and 255 that maps to a row in a displayable attributes table. The displayable attribute format may be either an SQL SELECT statement or a screen form.reportOpen. See also MbeElement. MbeDatabase. MicroStation BASIC Guide 8-167 8 MicroStation Extensions to BASIC . Subsequent calls to MbeElement.reportOpen Descr.reportDBLinkages.dAType is a read/write Integer property which sets the active displayable attribute type.reportDBLinkages will accumulate rows in the report tables according to the attribute linkages present on the elements. See also MbeElement. The MbeDatabase.reportOpen MbeDatabase.

The first step in using an MbeDatabaseLink object is to declare the object and allocate space for it using either of the following BASIC constructs: Dim link as New MbeDatabaseLink or Dim link as MbeDatabaseLink Set link = New MbeDatabaseLink You can call the MbeDatabaseLink object variable anything you want in your program. Get or set linkage class. or user property bit of the linkage. Either of these constructs establishes a name for an MbeDatabaseLink object and allocates memory. Get or set type of database linkage. modified. remote.isInformation (page 8-169) MbeDatabaseLink. Get or set entity number of the linkage. 8-168 MicroStation BASIC Guide . Statement and Functions MbeDatabaseLink.mslink (page 8-171) MbeDatabaseLink. The following extensions are provided for querying and manipulating MbeDatabaseLink object. Get or set information.tableName (page 8-171) Used to Get or set displayable attribute type.entityNumber (page 8-169) MbeDatabaseLink.linkSize (page 8-170) MbeDatabaseLink. In this example we use link as the variable name. Retrieves size in words of the database link.MbeDatabaseLink Object MbeDatabaseLink Object The MbeDatabaseLink object represents the linkage between graphics and database.linkClass (page 8-170) MbeDatabaseLink.dAType (page 8-169) MbeDatabaseLink. Get or set MSLINK value of a linkage Get or set the associated table name.linkType (page 8-170) MbeDatabaseLink.

appendDBLinkage. This is the read/write boolean property which sets or retrieves the remote bit on the database attribute link.appendDBLinkage. See also MbeElement. See also MbeElement.isInformation Descr.dAType MbeDatabaseLink. This is the read/write boolean property which sets or retrieves the property bit on the database attribute link. See also MbeElement. MbeDatabaseLink.extractDBLinkages. MicroStation BASIC Guide 8-169 8 MicroStation Extensions to BASIC .isModified Descr.entityNumber. MbeDatabaseLink. See also MbeElement. MbeElement. MbeElement. MbeDatabaseLink.dAType.dAType is a read/write Integer property which sets or retrieves the displayable attribute type if any are associated with the linkage object.entityNumber Descr. User must set either or both of the tableName or entityNumber properties of the linkage object before appending the linkage to the graphics element using MbeElement.appendDBLinkage extension.extractDBLinkages. MbeElement. MbeDatabaseLink. See also MbeElement.deleteDBLinkage. MbeDatabase.deleteDBLinkage. MbeDatabaseLink. MbeElement.MbeDatabaseLink Object MbeDatabaseLink.extractDBLinkages. MbeDatabaseLink.entityNumber is a read/write Integer property which sets or retrieves the entity number for the database table associated with the linkage object.entityNumber MbeDatabaseLink. MbeDatabaseLink.dAType Descr.extractDBLinkages. MbeTable. This is the read/write boolean property which sets or retrieves the modify bit on the database attribute link.tableName.extractDBLinkages.isRemote Descr.

deleteDBLinkage.linkClass is a read/write Integer property which sets or retrieves the the linkage class of the database link. MBE_RIS_Linkage.linkSize is a read only Integer property which retrieves the size of the database link in words.appendDBLinkage.MbeDatabaseLink Object MbeDatabaseLink. This is the read/write boolean property which sets or retrieves the user bit on the database attribute link. MbeDatabaseLink. MbeDatabaseLink. MbeDatabaseLink. MBE_SYBASE_Linkage or MBE_INGRES_Linkage. MbeDatabaseLink.linkType MbeDatabaseLink. MbeDatabaseLink. MbeDatabaseLink. MBE_DBASE_Linkage.linkClass Descr. See also MbeElement.extractDBLinkages.linkSize Descr. See also MbeElement.linkType can be any of the following values: MBE_ORACLE_Linkage.linkSize MbeDatabaseLink.linkType is a read/write Integer property which sets or retrieves the type of database linkage associated with the linkage object. MbeElement. Example Sub changeOracleLinksToODBC(lnk as MbeDatabaseLink) If lnk. MBE_XBASE_Linkage. See also MbeElement.isUserLink Descr.type = MBE_ORACLE_Linkage Then lnk.extractDBLinkages.extractDBLinkages. MbeElement. MBE_INFORMIX_Linkage. MBE_DMRS_Linkage. MbeDatabaseLink.linkType Descr. 8-170 MicroStation BASIC Guide .linkClass MbeDatabaseLink.type = MBE_ODBC_Linkage End If end sub See also MbeElement.extractDBLinkages. MBE_ODBC_Linkage.

tableName largestMslink = table.extractDBLinkages. MicroStation BASIC Guide 8-171 8 MicroStation Extensions to BASIC MbeDatabaseLink.name = “parcel” lnk. MbeElement.mslink > largestMsLink Then lnk. Example Sub validateLinkage(lnk as MbeDatabaseLink) Dim table as New MbeTable Dim largestMslink as Long table.tableName Descr. MbeDatabaseLink.entityNumber End If end sub See also MbeElement.tableName is a read/write String property which sets or retrieves the database table name associated with the linkage object.entityNumber = table. User must set either or both the tableName and/or entityNumber properties of the linkage object before appending the linkage to the graphics element using MbeElement.largestMslink lnk. MbeElement.tableName .tableName = “features” Then table.tableName = table.entityNumber. Example Sub changeFeatureToParcel(lnk as MbeDatabaseLink) Dim table as New MbeTable If lnk. MbeDatabaseLink.mslink = largestMsLink End If end sub See also MbeElement.name = lnk. MbeElement.name lnk.mslink Descr.appendDBLinkage.deleteDBLinkage. MbeElement.appendDBLinkage extension. MbeDatabaseLink.mslink is a read/write Integer property which sets or retrieves the MSLINK key value associated with the linkage object MbeDatabaseLink. MbeDatabaseLink.deleteDBLinkage.MbeDatabaseLink Object MbeDatabaseLink.mslink MbeDatabaseLink.appendDBLinkage.extractDBLinkages.

freeAll (page 8-174) MbeDgnLevels.rootGroup MbeDgnLevels.numGroups 8-172 MicroStation BASIC Guide . Its name cannot be modified.getGroup (page 8-173) MbeDgnLevels. including all level name and level group definitions. retrieve the MbeLevelGroup corresponding to the specified name. clear the current level group structures.rootGroup Descr.saveGroupsToFile (page 8-175) MbeDgnLevels. save the level group definitions to the resource file specified.saveLevelsToFile (page 8-175) MbeDgnLevels.freeGroups (page 8-173) MbeDgnLevels. (page 8-173) MbeDgnLevels.loadGroupsFromFile (page 8-174) MbeDgnLevels.rootGroup read-only property returns the MbeLevelGroup object corresponding to the root of the current level structure.loadLevelsFromFile (page 8-174) MbeDgnLevels.numGroups Descr. save the level name and level group definitions to the resource file specified.MbeDgnLevels Object MbeDgnLevels Object Properties and Methods MbeDgnLevels. Example Dim rootGroup As MbeLevelGroup set rootGroup = MbeDgnLevels. clear the current level structure.numGroups read-only Integer property returns the number of groups in the current level structure.saveAllToFile (page 8-176) MbeDgnLevels. return the number of named levels in the current level structure.loadAllFromFile (page 8-175) MbeDgnLevels. load only the level name definitions from the resource file specified. retrieve the MbeNamedLevel corresponding to the specified name.rootGroup (page 8-172) MbeDgnLevels. The MbeDgnLevels.numGroups (page 8-172) MbeDgnLevels. save the level name definitions to the resource file specified. Example Dim numGroups As Integer numGroups = MbeDgnLevels. The MbeDgnLevels.getLevel (page 8-173) MbeDgnLevels. load the level name and level group definitions from the resource file specified. return the number of groups in the current level structure.numNamedLevels Used to return the MbeLevelGroup object corresponding to the root of the current level structure. load the only the level group definitions from the resource file specified.

levelName As String) Descr.getLevel(namedLevel. MbeDgnLevels. “furn/equip”) = MBE_Success Then levelGroup. the method returns MBE_DuplicateLevelName.getGroup (levelGroup.getLevel stat=MbeDgnLevels.numNamedLevels MbeDgnLevels.getLevel(namedLevel As MbeNamedLevel. ✍ The level name definitions are not cleared. MicroStation BASIC Guide 8-173 8 MicroStation Extensions to BASIC Example Dim levelGroup As MbeLevelGroup . “STAIR”) = MBE_Success Then namedLevel. If MbeDgnLevels. the method returns MBE_InvalidLevelName. the method returns MBE_DuplicateLevelGroup.getLevel retrieves the MbeNamedLevel corresponding to the name specified in levelName. If more than one level group in the level structure has the name groupName.numNamedLevels Descr.freeGroups clears the current level group structures.getGroup stat = MbeDgnLevels. If no groups named groupName exist. If more than one named level having the specified name exists in the level structure. groupName As String) Descr. the method returns MBE_InvalidLevelGroup.freeGroups Descr. MbeDgnLevels.numNamedLevels read-only Integer property returns the number of named levels in the current level structure.getGroup retrieves the MbeLevelGroup corresponding to the named specified in groupName. Example Dim numNamedLevels As Integer numNamedLevels = MbeDgnLevels.getGroup(levelGroup As MbeLevelGroup.deleteGroup End If MbeDgnLevels. The MbeDgnLevels.deleteLevel End If MbeDgnLevels. they remain active.MbeDgnLevels Object MbeDgnLevels. If no levels having the specified name exist. MbeDgnLevels. Example Dim namedLevel As MbeNamedLevel If MbeDgnLevels.

loadGroupsFromFile loads the only the level group definitions from the resource file specified by fileName. The full file specification is passed in fileName.MbeDgnLevels Object MbeDgnLevels. MbeDgnLevels.loadGroupsFromFile stat = MbeDgnLevels.loadLevelsFromFile stat = MbeDgnLevels. No level names or level groups are active after this method is called. The method returns MBE_CantLoadLevelsFromFile if the level group definitions are not successfully loaded.loadGroupsFromFile (“c:\ustation\wsmod\arch\data\aiaplumb. Example If MbeDgnLevels. including all level name and level group definitions.lvl”) = MBE_Success Then Call ShowLevelGroupDefinitions() End If MbeDgnLevels. MbeDgnLevels. The full file specification is passed in fileName. they remain active.loadLevelsFromFile loads only the level name definitions from the resource file specified by fileName. The method returns MBE_CantLoadLevelsFromFile if the level name definitions are not successfully loaded.freeLevels clears the current level name structures. MbeDgnLevels. Loading level group definitions from a resource file overrides the level group definitions contained in the design file. ✍ MbeDgnLevels. MbeDgnLevels.freeLevels Descr.lvl) = MBE_Success Then Call ShowLevelNameDefinitions() End If 8-174 MicroStation BASIC Guide . Example If MbeDgnLevel. Descr.loadLevelsFromFile(fileName As String) Descr.freeAll The level group definitions are not cleared.loadLevelsFromFile (“c:\ustation\wsmod\arch\data\aiaplumb. MbeDgnLevels.loadGroupsFromFile(fileName As String) Descr.freeAll clears the current level structure. Loading the level name definitions from a resource file overrides the level name definitions contained in the design file.

The method returns MBE_CantSaveLevelsToFile if the level group definitions are not successfully saved.saveGroupsToFile (“c:\ustation\data\mygroups.freeLevels End If MicroStation BASIC Guide 8-175 8 MicroStation Extensions to BASIC . Example If MbeDgnLevels.saveGroupsToFile saves only the level group definitions to the resource file specified by fileName.saveLevelsToFile saves only the level name definitions to the resource file specified by fileName. The full file specification is passed in fileName.saveGroupsToFile(fileName As String) Descr.loadAllFromFile stat = MbeDgnLevels.lvl”) = MBE_Success Then Call ShowLevelStructure() End If MbeDgnLevels.loadAllFromFile loads the level name and level group definitions from the resource file specified by fileName.saveLevelsToFile(“c:\ustation\data\mylevels. MbeDgnLevels. Example If MbeDgnLevels.lvl”) = MBE_Success Then MbeDgnLevels.lvl”) = MBE_Success Then MbeDgnLevels.freeGroups End If MbeDgnLevels. The full file specification is passed in fileName.MbeDgnLevels Object MbeDgnLevels. Example If MbeDgnLevels. The method returns MBE_CantLoadLevelsFromFile if the level structure is not successfully loaded.loadAllFromFile (“c:\ustation\wsmod\arch\data\aiaplumb. MbeDgnLevels.saveGroupsToFile stat = MbeDgnLevels.saveLevelsToFile stat = MbeDgnLevels.loadAllFromFile(fileName As String) Descr. The full file specification is passed in fileName.saveLevelsToFile(fileName As String) Descr. MbeDgnLevels. Loading the level name and level group definitions from a resource file overrides the level structure contained in the design file. The method returns MBE_CantSaveLevelsToFile if the level name definitions are not successfully saved.

The full file specification is passed in fileName. MbeDgnLevels.saveAllToFile(“c:\ustation\data\mystruct.saveAllToFile(fileName As String) Descr.saveAllToFile stat = MbeDgnLevels.MbeDgnLevels Object MbeDgnLevels. The method returns MBE_CantSaveLevelsToFile if the level structure is not successfully saved.saveAllToFile saves the level name and level group definitions to the resource file specified by fileName.lvl”) = MBE_Success Then MbeDgnLevels.freeAll End If 8-176 MicroStation BASIC Guide . Example If MbeDgnLevels.

getParentGroup (page 8-182) MbeNamedLevel. set or retrieve the level name of the named level.levelName (page 8-181) MbeNamedLevel.levelComment (page 8-182) MbeNamedLevel. Example Dim groupName As String Dim levelGroup As MbeLevelGroup If MbeDgnLevels.getGroup(levelGroup.getLevels retrieves an array of type MbeNamedLevel that contains objects corresponding to all the named levels immediately belonging to the level group.deleteLevel (page 8-183) MbeLevelGroup. Group names are limited to 16 characters in length. The MbeLevelGroup. “furn/equip”) = MBE_Success Then levelGroup.levelNumber Used to set or retrieve the MicroStation number of the named level. Example Dim levelGroup As MbeLevelGroup Dim namedLevels() As MbeNamedLevel MicroStation BASIC Guide 8-177 8 MicroStation Extensions to BASIC .rootGroup) cannot be changed. retrieve a level mask corresponding to the named level.getLevels stat = MbeLevelGroup.groupName Descr. The method returns MBE_InvalidLevelGroup if the level group is not valid in the current level structure.groupName = “furniture” End If MbeLevelGroup. set or retrieve the comment associated with the named level.groupName String property sets or retrieves the name identifying the level group in the current level structure. (page 8-181) MbeNamedLevel.getLevels(namedLevels() As MbeNamedLevel) Descr. ✍ The groupName of the “root” group (MbeDgnLevels.MbeLevelGroup Object MbeLevelGroup Object Properties and Methods MbeNamedLevel. delete the level name definition from the current level structure. MbeLevelGroup.getLevelMask (page 8-182) MbeNamedLevel. retrieve an object of type MbeLevelGroup corresponding to the level group containing the current named level.

getLevels (namedLevels) = MBE_Success Then For iLevel = LBound (namedLevels) to UBound (namedLevels) Print namedLevels(iLevel). “furn/equip”) = MBE_Success Then If levelGroup.getDescendentGroups(levelGroups) = MBE_Success Then For iGroup = LBound (levelGroups) to UBound (levelGroups) 8-178 MicroStation BASIC Guide .rootGroup If rootGroup.getGroup(levelGroup. The method returns MBE_InvalidLevelGroup if the level group is not valid in the current level structure. MbeLevelGroup. Example Dim levelGroup As MbeLevelGroup Dim namedLevels() As MbeNamedLevel Dim iLevel As Integer If MbeDgnLevels. “furn/equip”) = MBE_Success Then If levelGroup.MbeLevelGroup Object Dim iLevel As Integer If MbeDgnLevels.getDescendentGroups retrieves an array of type MbeLevelGroup that contains the objects corresponding to all the level groups descending from the current level group. Example Dim rootGroup As MbeLevelGroup Dim levelGroups() As MbeLevelGroup Dim iGroup As Integer set rootGroup = MbeDgnLevels.levelName Next iLevel End If End If MbeLevelGroup.getDescendentLevels(namedLevels) = MBE_Success Then For iLevel = LBound (namedLevels) to UBound (namedLevels) Print namedLevels(iLevel). MbeLevelGroup.getDescendentGroups stat = MbeLevelGroup.getDescendentLevels(namedLevels() As MbeNamedLevel) Descr.getDescendentLevels stat = MbeLevelGroup.getGroup(levelGroup. The method returns MBE_InvalidLevelGroup if the level group is not valid in the current level structure.getDescendentLevels retrieves an array of type MbeNamedLevel that contains objects corresponding to all the named levels contained by the level group or any level groups descending from the current level group.getDescendentGroups(subGroups() As MbeLevelGroup) Descr.levelName Next iLevel End If End If MbeLevelGroup.

getLevelMask(levelMask) = MBE_Success Then view. The method returns an error code if the array is the wrong dimension.getGroup(levelGroup.MbeLevelGroup Object Print levelGroups(iGroup).getParentGroup retrieves and object of type MbeLevelGroup corresponding to the level group containing the current level group.getLevelMask stat = MbeLevelGroup. MbeLevelGroup. Example Sub ShowParentName(levelGroup As MbeLevelGroup) MbeLevelGroup.getParentGroup (parentGroup As MbeLevelGroup) Descr.getLevelMask retrieves a level mask that shows which levels belong in the level group. the function returns MBE_InvalidLevelGroup. Example Dim levelMask (0 to 3) As Integer Dim levelGroup As MbeLevelGroup Dim view As MbeView view = MbeViews(1) If MbeDgnLevels.getParentGroup stat = MbeLevelGroup.levelsOn(levelMask) End If End If MicroStation BASIC Guide 8-179 8 MicroStation Extensions to BASIC Dim parentGroup As MbeLevelGroup If levelGroup.getParentGroup(parentGroup) = MBE_Success Then Print “Parent Group Name : “. The method returns MBE_RootGroupHasNoParent if it is called from the root level from object. MbeLevelGroup. ✍ The “root” group has no parent. If the parent group does not exist in the level structure.groupName Next iGroup End If MbeLevelGroup. “furn/equip”) = MBE_Success Then If levelGroup. The levelMask argument must be a four-element Integer array.parentGroup.groupName End If End Sub .getLevelMask(levelMask() As Integer) Descr.

The method returns MBE_InvalidLevelGroup if the level group is not valid in the current level structure.addLevel(levelName As String.addLevel(“revisions”) If stat = MBE_Success Then 8-180 MicroStation BASIC Guide . The function returns an error code if the level name definition cannot be added. levelNumber As Integer.addGroup adds a level group definition as a descendant of the current level group.addGroup stat = MbeLevelGroup.deleteGroup deletes the level group from the current level structure. _ [levelComment As String]) Descr.addLevel adds a named level definition in the current level structure. Descendent groups will be deleted unless FALSE is specified. MbeLevelGroup. MbeLevelGroup.addGroup(“notes”) If stat = MBE_Success Then Print “Group Added” End If MbeLevelGroup. Example Dim rootGroup As MbeLevelGroup set rootGroup = MbeDgnLevels.addGroup(subGroupName As String) Descr.deleteGroup End If MbeLevelGroup. The MicroStation number of the new level is passed in levelNumber. Example Dim levelGroup As MbeLevelGroup If MbeDgnLevels. The named level immediately belongs to the current level group. Example Dim rootGroup As MbeLevelGroup set rootGroup = MbeDgnLevels. “notes/ref”) = MBE_Success Then levelGroup. The optional levelComment String argument is limited to 32 characters in length.deleteGroup Descr.addLevel stat=MbeLevelGroup.rootGroup stat = rootGroup. The levelName String argument is limited to 16 characters in length and specifies the name for the definition.rootGroup stat = rootGroup.MbeLevelGroup Object MbeLevelGroup. The subGroupName String argument is limited to 16 characters in length and specifies the name to be assigned to the new level group. MbeLevelGroup.getGroup(levelGroup.

deleteLevel (page 8-183) delete the level name definition from the current level structure.levelNumber Used to set or retrieve the MicroStation number of the named level.levelName = “notes/rev” End If MicroStation BASIC Guide 8-181 8 MicroStation Extensions to BASIC retrieve a level mask corresponding to the named level. set or retrieve the level name of the named level. “revisions”) = MBE_Success Then levelNumber = namedLevel. (page 8-181) MbeNamedLevel. retrieve an object of type MbeLevelGroup corresponding to the level group containing the current named level. set or retrieve the comment associated with the named level. The MbeNamedLevel.levelName Integer property sets or retrieves the level name of the named level.levelNumber Integer property sets or retrieves the MicroStation number of the named level.MbeNamedLevel Object Print “Level Added” End If MbeNamedLevel Object Properties and Methods MbeNamedLevel.levelNumber Descr. MbeNamedLevel.levelName Descr.levelName (page 8-181) MbeNamedLevel. “revisions”) = MBE_Success Then namedLevel. .levelNumber End If MbeNamedLevel.getLevelMask (page 8-182) MbeNamedLevel. Example Dim levelNumber As Integer Dim namedLevel As MbeNamedLevel If MbeDgnLevels.getLevel(namedLevel.getParentGroup (page 8-182) MbeNamedLevel. The MbeNamedLevel. Example Dim namedLevel As MbeNamedLevel If MbeDgnLevels.getLevel(namedLevel.levelComment (page 8-182) MbeNamedLevel.

parentGroup.levelComment Descr.getParentGroup(parentGroup) = MBE_Success Then Print “Parent Group Name : “. MbeNamedLevel.getLevelMask(levelMask() As Integer) Descr.getParentGroup retrieves an object of type MbeLevelGroup corresponding to the level group containing the current named level. “revisions”) = MBE_Success Then If namedLevel.levelComment End If MbeNamedLevel.getLevel(namedLevel. If the parent group does not exist in the level structure. The levelMask argument must be a four-element Integer array. “revisions”) = MBE_Success Then levelComment = namedLevel.getLevel(namedLevel.getLevelMask stat = MbeNamedLevel. Example Dim levelMask (0 to 3) As Integer Dim namedLevel As MbeNamedLevel Dim view As MbeView view = MbeViews(1) If MbeDgnLevels.getLevelMask(levelMask) = MBE_Success Then view.levelsOn(levelMask) End If End If 8-182 MicroStation BASIC Guide . The MbeNamedLevel.getLevelMask retrieves a level mask corresponding to the named level. MbeNamedLevel. Example Dim namedLevel As MbeNamedLevel Dim levelComment As String If MbeDgnLevels. The function returns an error code if the array is the wrong dimension. the function returns MBE_InvalidLevelGroup.getParentGroup stat = MbeNamedLevel. Example Sub ShowParentName(namedLevel As MbeNamedLevel) Dim parentGroup As MbeLevelGroup If namedLevel.MbeNamedLevel Object MbeNamedLevel.groupName End If End Sub MbeNamedLevel.getParentGroup (parentGroup As MbeLevelGroup) Descr.levelComment String property sets or retrieves the comment associated with the named level.

Example Dim namedLevel As MbeNamedLevel If MbeDgnLevels.MbeNamedLevel Object MbeNamedLevel. “revisions”) = MBE_Success Then namedLevel. MbeNamedLevel.getLevel(namedLevel.deleteLevel End If MicroStation BASIC Guide 8-183 8 MicroStation Extensions to BASIC .deleteLevel deletes the level name definition from the current level structure.deleteLevel Descr.

it specifies whether to find the tagset names for the master (fileNum = 0) or one of the reference files (fileNum = the reference file slot to read the element from). is provided. fileNum. MbeGetTagSetNames retrieves a sorted array of tagset names found in the design file. is provided. 8-184 MicroStation BASIC Guide . it specifies whether to find the count for the master (fileNum = 0) or one of the reference files (fileNum = the reference file slot to read the element from). If fileNum is not provided. MbeGetTagSetNames num = MbeGetTagSetNames(setNames as String()) num = MbeGetTagSetNames(setNames as String(). MbeNumberOfTagSets num = MbeNumberOfTagSets() num = MbeNumberOfTagSets(fileNum as Integer) Descr. MbeNumberOfTagSets returns the number of tagsets found in the design file. fileNum as Integer) Descr. file num = MbeNumberOfTagSets(1) See also MbeGetTagSetNames.getTagDefNames. If fileNum is not provided. MbeTagSet.Tag BASIC Extensions Tag BASIC Extensions Properties and Methods MbeNumberOfTagSets (page 8-184) MbeGetTagSetNames (page 8-184) Used to get number of tagsets present in the specified design file. get an array of tagset names present in the specified design file. MbeNumberOfTagSets is calculated for the master file. Example Dim num as Integer ‘ count total tagsets in the master num = MbeNumberOfTagSets() ‘ count total tagsets for the first ref. If the optional argument. fileNum. If the optional argument.

Example Dim numMaster as Integer Dim numRef as Integer Dim setsMaster as String() Dim setsRef as String() ‘ get tagset names for the master numMaster = MbeGetTagSetNames(setsMaster) ‘ count total tagsets for the first ref.numTagDefs. file numRef = MbeGetTagSetNames(setsRef. MbeTagSet.Tag BASIC Extensions MbeGetTagSetNames retrieves the names for the master file. 1) See also MbeNumberOfTagSets. MbeGetTagSetNames returns the number of tagsets found in the specified file. MicroStation BASIC Guide 8-185 8 MicroStation Extensions to BASIC .

name Descr.name should be set before calling other MbeTagSet methods.update (page 8-188) MbeTagSet.numTagDefs (page 8-187) MbeTagSet.reportName Used to get or set the tagset name. (page 8-186) MbeTagSet.name (page 8-186) MbeTagSet. MbeTagSet. get a sorted array of tag names found in the set.MbeTagSet Object MbeTagSet Object Properties and Methods MbeTagSet.name is a read/write String property which sets or retrieves the name of the tagset object.reportName MbeTagSet.getTagDefNames (page 8-187) MbeTagSet. generate an ASCII report file for the tagset. MbeTagSet. delete attribute elements for for all or the specified definition of the tagset. MbeTagSet. MbeTagSet.reportName should be set before calling MbeTagSet.reportName Descr. Example Dim tagset as new MbeTagSet 'set tagset properties tagset.name = "set0001" See also MbeTagSet.fileNum (page 8-187) MbeTagSet. update the set and its report names.deleteInstances (page 8-190) MbeTagSet. get total number of tag definitions in the set. get or set the file number associated with the tagset.name.getTagDefNames. get or set name of the report file for the tagset.generateReport if no fileName argument is provided there. Example Dim tagset as new MbeTagSet 'set tagset properties 8-186 MicroStation BASIC Guide . det the MbeTagDef object for the specified tag from the tagset. add a new tagset to the design file.name MbeTagSet.generateReport (page 8-189) MbeTagSet.delete (page 8-188) MbeTagSet.add (page 8-188) MbeTagSet.reportName is a read/write String property which sets or retrieves the name of the ASCII report file.getTagDef (page 8-189) MbeTagSet. MbeTagSet. delete the tagset from master design file. MbeTagDef.

MicroStation BASIC Guide 8-187 8 MbeTagSet.getTagDefNames retrieves a sorted array of tags defined in the tagset. Example Dim tagset as new MbeTagSet 'check whether the tagset is read from master if tagset. MbeTagSet.add.name = “myset” 'check tagset myset has any tags defined if tagset. num = MbeTagSet.numTagDefs Descr. MbeTagSet. tagset.FileNum is a read/write Integer property which sets or retrieves the file number associated with tagset.getTagDefNames. MbeTagSet.getTagDefNames(tagNames as String()) Descr. MbeTagDef. MbeTagSet.getTagDefNames returns the number of tags found in the tagset.numTagDefs is a read only Integer property which retrieves the total number of tag definitions found in the tagset. Example Dim tagset as new MbeTagSet tagset. MbeTagSet.generateReport.getTagDefNames(tagNames) See also MbeTagSet. MbeTagSet.FileNum Descr.update.FileNum points to the master design file.. Example dim tagset as new MbeTagSet dim tagNames() as string num = tagset. MbeTagSet. MbeTagSet..fileNum = 0 then ‘update tagset end if See also MbeTagSet.numTagDefs.reportName = "c:\\tt" See also MbeTagSet.numTagDefs > 0 then ‘process tags end if See also MbeTagSet.add.MbeTagSet Object .delete. MbeTagSet.fileNum MbeTagSet. By default.getTagDefNames MicroStation Extensions to BASIC .numTagDefs num = MbeTagSet.

name property is not set and a different error code otherwise. MBE_InvalidTagSet if the MbeTagSet. MbeTagSet.name property is not set and a different error code otherwise. MbeTagDef. newReport is the new report file name.delete returns MBE_Success if the tagset is deleted successfully.add.add() See also MbeTagSet. Example Dim tagset as new MbeTagSet 'set tagset properties tagset.name = "set0001" stat = tagset.update returns MBE_Success if the tagset is updated successfully.delete() Descr. MbeTagDef.update(“set0002”) See also MbeTagSet. If newReport is not provided.delete. Example Dim tagset as new MbeTagSet 'set tagset properties 8-188 MicroStation BASIC Guide . newName specifies the new name for the tagset.add returns MBE_Success if the tagset is added successfully. Example Dim tagset as new MbeTagSet 'set tagset properties tagset.update.name = "set0001" stat = tagset. newReport as string) Descr. MbeTagSet. MBE_InvalidTagSet if the MbeTagSet.delete deletes the tagset from design file.update stat = MbeTagSet.MbeTagSet Object MbeTagSet. MbeTagSet. MBE_InvalidTagSet if the MbeTagSet.add adds a new tagset to the design file.name property is not set and a different error code otherwise. MbeTagSet. MbeTagSet. The second (optional) argument.update(newName as string) stat = MbeTagSet.deleteInstances before calling this.update updates the tagset with a new name and report file.add stat = MbeTagSet.update(newName as string. MbeTagSet. MbeTagSet. MbeTagSet. MbeTagSet. User should delete the tag instances if any using MbeTagSet.add.add() Descr.delete stat = MbeTagSet.update does not change the report file name for the tagset.

MbeTagSet.reportName must be set to a valid file path before calling this function. MbeTagSet. MBE_InvalidTagSet if the MbeTagSet.name = "set1" ‘check whether set1 contains tag1 if tagset.e. tagList as String()) stat=MbeTagSet. $type for element type.getTagDef stat = MbeTagSet.MbeTagSet Object tagset.name property is not set and a different error code otherwise. “tag1”) = MBE_Success then ‘process tag end if See also MbeTagDef.generateReport() stat= MbeTagSet.name = "set0001" stat = tagset..generateReport(reportMode as Integer) stat= MbeTagSet.getTagDef creates an MbeTagDef object tagDef for the specified tag name tagName if it is available in the tagset. tagName as string) Descr. Example Dim tagset as new MbeTagSet Dim tagdef as new MbeTagDef 'set tagset properties tagset. The optional tagList argument specifies an array of column names for the report.getTagDef returns MBE_Success if tagName is a valid tag name for the tagset. MbeTagSet. MbeTagSet.generateReport(reportMode as Integer. fileName as String) The optional reportMode argument takes MBE_TagReportAll or MBE_TagReportTagged values. MbeTagDef.generateReport stat= MbeTagSet. If reportMode is not specified it assumes MBE_TagReportTagged and reports only tagged elements. MicroStation Extensions to BASIC . MicroStation BASIC Guide 8-189 8 Descr.numTagDefs.).deleteInstances.generateReport(reportMode as Integer.getTagDef(tagDef as MbeTagDef. They can be either tag names or tag types that MicroStation supports (i. MbeTagSet. MbeTagSet. $color for element color. tagList as String().delete. etc. MbeTagSet.generateReport generates an ASCII report file for the tagset.delete() See also MbeTagSet.add.getTagDef(tagdef.

MbeTagDef. MbeTagSet.reportName can contain.attachTag.reportName = "c:\\tt" ‘set columns to tag names columns(0) = "tag1" columns(1) = "tag2" columns(2) = "tag3" stat = tagset. MBE_InvalidTagSet if the MbeTagSet.name = “set1” tagset.add. it deletes instances of all tags in the tagset.reportName properties are not set or a different error code otherwise.name or MbeTagSet.generateReport(MBE_TagReportTagged.generateReport returns MBE_Success if the report is generated successfully. MBE_InvalidTagSet if the MbeTagSet.deleteInstances returns MBE_Success tag elements are deleted successfully.reportName.name property is not set or a different error code otherwise. MbeTagSet. If the optional argument tagName is not provided. columns) See also MbeTagSet. fileName is used instead of reportName for generating the report.deleteInstances() stat = MbeTagSet.deleteInstances stat = MbeTagSet. Example Dim tagset as new MbeTagSet Dim columns as string() tagset.MbeTagSet Object The optional fileName argument specifies the fully-qualified filename where the report will be generated. Example Dim tagset as new MbeTagSet 'set tagset properties tagset. If provided.name = "set1" ‘delete instances of tag1 if tagset. MbeTagSet.deleteInstances(tagName as string) Descr.deleteInstances(“tag1”) = MBE_Success then ‘now delete the tag definition end if See also MbeElement. 8-190 MicroStation BASIC Guide . tagList can be a zero length array if you want to specify fileName but not tagList. MbeTagSet.deleteInstances deletes all the attribute instances (type 37) of the tag specified by tagName from the design file. This is useful if the path exceeds the 12 characters that MbeTagSet.

isConstant (page 8-194) MbeTagDef. get or set the constant mode of the tag.name should be set before calling most of MbeTagDef methods.name MbeTagDef. MbeTagDef.name.style (page 8-192) MbeTagDef. get or set the parent tagset name.isHidden (page 8-194) MbeTagDef. MicroStation BASIC Guide 8-191 8 MicroStation Extensions to BASIC .add() See also MbeTagSet. update the properties of tag definition.update (page 8-195) MbeTagDef.name (page 8-191) Used to get or set tag name.name Descr. get ot set the text style for creating tag element.tagId (page 8-194) MbeTagDef. Example Dim tagdef as new MbeTagDef 'set tag definition properties tagdef. get the unique ID associated with the tag definition.defaultValue (page 8-193) MbeTagDef.delete (page 8-196) MbeTagDef. MbeTagDef. get or set the default value for the tag. drop the definition from the tagset.tagType (page 8-193) MbeTagDef.name = "tag1" ‘insert the tag to set1 stat = tagdef.name is a read/write String property which sets or retrieves the name of the tag definition object. get or set the display mode of the tag.prompt (page 8-192) MbeTagDef. get or set the data type of the tag.add (page 8-195) MbeTagDef.setName (page 8-192) MbeTagDef.setName. MbeTagDef. add the tag definition to the tagset. get ot set the prompt string used for Dialog operations.MbeTagDef Object MbeTagDef Object Properties and Methods MbeTagDef.setName = “set1” tagdef. MbeTagDef.

style = “newStyle” 8-192 MicroStation BASIC Guide .prompt = “What is your name?” ‘insert the tag to set1 stat = tagdef. Example Dim tagdef as new MbeTagDef 'set tag definition properties tagdef.style MbeTagDef. MbeTagDef.setName MbeTagDef.prompt MbeTagDef.add() See also MbeTagDef.style is a read/write String property which sets or retrieves the style used to overwrite the text style while creating the tag.style Descr. MbeTagDef.add. MbeTagDef.setName should be set before calling most of MbeTagDef methods.MbeTagDef Object MbeTagDef.setName = "set1" tagdef.setName = "set1" tagdef. MbeTagDef.setName is a read/write String property which sets or retrieves name of the tagset which contains the tag definition object.name. MbeTagDef. ✍ Currently MicroStation does not make use of this property. Example Dim tagdef as new MbeTagDef 'set tag definition properties tagdef.name = "name" tagdef.prompt is a read/write String property which sets or retrieves the prompt string used while editing the attributes in MicroStation dialog interface.setName Descr. MbeTagDef.add() See also MbeTagSet. Example Dim tagdef as new MbeTagDef 'set tag definition properties tagdef.add. MbeTagDef.name.setName = “set1” tagdef.name = "name" tagdef.prompt Descr. MbeTagDef.name = "tag1" ‘insert the tag to set1 stat = tagdef.

MbeTagDef.MbeTagDef Object ‘insert the tag to set1 stat = tagdef. MbeTagDef. MBE_TagInteger. MbeTagDef. Example Dim tagdef as new MbeTagDef 'set tag definition properties tagdef.tagType = MBE_TagString tagdef. .tagType is a read/write Integer property which sets or retrieves the data type of the tag value.tagType MbeTagDef.tagType can take any of the following values: MBE_TagString.tagType Descr.defaultValue MbeTagDef. MbeTagDef.tagType = MBE_TagDouble tagdef.add() See also MbeTagDef.add.add() MbeTagDef.defaultValue = “Bentley Systems" ‘insert the tag to set1 stat = tagdef.defaultValue = “3235. MBE_TagLong.defaultValue.45" ‘insert the tag to set1 stat = tagdef. MBE_TagDouble or MBE_TagBinary. MicroStation BASIC Guide 8-193 8 MicroStation Extensions to BASIC See also MbeTagDef.name = “company” tagdef.defaultValue is a read/write String property which sets or retrieves the default tag value. MbeTagDef.name = “salary” tagdef. Example Dim tagdef as new MbeTagDef 'set tag definition properties tagdef.add() See also MbeTagDef.tagType should be set before setting the defaultValue.setName = “empoyee” tagdef.defaultValue Descr.tagType.

isHidden Descr. MbeTagDef.isConstant Descr.setName = “empoyee” tagdef.tagId MbeTagDef.isConstant MbeTagDef.isConstant = TRUE tagdef.setName = “empoyee” tagdef. Example Dim tagdef as new MbeTagDef 'set tag definition properties tagdef.isHidden = 1 ‘update salary tag stat = tagdef.isHidden MbeTagDef.MbeTagDef Object MbeTagDef. MbeTagDef.defaultValue as its value.update.update() See also MbeElement. MbeTagDef. MbeTagDef. If the tag is constant. 8-194 MicroStation BASIC Guide .tagType = MBE_TagString tagdef.tagId Descr. Most Macro users do not need this extension.isHidden is a read/write Integer property which sets or retrieves the display mode for the tag. MbeTagDef. MbeTagDef.isHidden takes values either 1 (hidden) or 0 (display).attachTag.update. Example Dim tagdef as new MbeTagDef 'set tag definition properties tagdef. Example Dim tagdef as new MbeTagDef 'set tag definition properties . MbeTagDef.update() See also MbeElement. Default is FALSE. Default value is 0.defaultValue = “SECT01” ‘update sector tag stat = tagdef..isConstant takes values either TRUE (1 -> constant) or FALSE (0->variable).name = “sector” ‘let every employee has the same sector tagdef. MbeTagDef.attachTag.isConstant is a read/write Integer property which sets or retrieves the constant mode for the tag.tagId is a read only property of type Long which gets the unique ID associated with the tag definition. MbeTagDef. every instance of the tag takes MbeTagDef..name = “salary” ‘hide the salary tag tagdef.

update(“elnumber”) See also MbeTagDef. Example Dim tagdef as new MbeTagDef See also MbeTagDef.delete.update(newName as string) Descr.add stat = MbeTagDef. MBE_InvalidTagSet if the name or setName properties are not set and a different error code otherwise. MbeTagDef. MbeTagDef. If the optional argument newName is provided.setName.isHidden = 1 ‘also rename it to elnumber stat = tagdef.name = "elemnum" ‘hide elemnum tag now onwards tagdef. MbeTagDef. MbeTagDef.update.add() Descr. MicroStation BASIC Guide 8-195 8 MicroStation Extensions to BASIC tagdef. MbeTagDef.name = "elemnum" tagdef.update also renames the tag definition name with it.update stat = MbeTagDef.setName = "set0001" tagdef.id.add.add() ‘query the new tag print tagdef.add adds a new tag definition to the tagset specified by MbeTagDef.add. Example Dim tagdef as new MbeTagDef tagdef.setName. MbeTagSet.add returns MBE_Success if the tag definition is added successfully.MbeTagDef Object ‘insert the tag to set1 stat = tagdef.tagType = MBE_TagLong stat = tagdef.add() . MBE_InvalidTagSet if the name or setName properties are not set and a different error code otherwise.tagId See also MbeTag.setName = "set0001" tagdef. MbeTagDef. MbeTagSet. MbeTagDef.update updates the properties of an existing tag definition in the tagset specified by MbeTagDef.update returns MBE_Success if the tag definition is updated successfully. MbeTagDef.update() stat = MbeTagDef.add.

name = "elemnum" ‘remove all its instances stat = tagset.delete deletes an existing tag definition from the tagset pointed by MbeTagDef. User should delete the tag instances if any using MbeTagSet.delete returns MBE_Success if the tag definition is deleted successfully. MbeTagDef. MbeTagDef. MbeTagSet.deleteInstances function before deleting its definition.add.update. MBE_InvalidTagSet if the name or setName properties are not set and a different error code otherwise.name = "set1" tagdef.delete stat = MbeTagDef.deleteInstances(“elemnum”) ‘drop the tag from set1 stat = tagdef. 8-196 MicroStation BASIC Guide .delete() Descr.MbeTagDef Object MbeTagDef.setName.delete() See also MbeTagDef. Example Dim tagdef as new MbeTagDef Dim tagset as new MbeTagSet tagset.setName = “set1” tagdef.

setName Descr.name.setName should be set before calling most of MbeTag methods.getOffset (page 8-201) MbeTag.MbeTag Object MbeTag Object Properties and Methods MbeTag. (page 8-201) MbeTag. get the data type of tag value. Example Dim tag as new MbeTag 'set tag properties tag.setName MbeTag. get the size of character/binary tag value. get the file number from which the tag is read. get or set tag name. get the data type of tag value.getTextElement (page 8-202) MbeTag.setOffset (page 8-201) MbeTag.name = "tag1" See also MbeTagDef. get the element the tag is attached to. get the underlying attribute element (type 37).getTaggedElement (page 8-202) MbeTag.setName is a read/write String property which sets or retrieves the name of tagset which contains the definition for the tag instance object MbeTag. MbeTagDef.isHidden (page 8-200) MbeTag. get a text element from tag. get or set the tag value. get the unique ID associated with the tag element. get or set the display mode of the tag element.version (page 8-200) MbeTag. get the association ID of the element the tag is attached to.id (page 8-198) MbeTag. MbeTag. MicroStation BASIC Guide 8-197 8 MicroStation Extensions to BASIC .fileNum (page 8-198) MbeTag. get the offset of the tag from the base element.value (page 8-199) MbeTag.type (page 8-199) MbeTag.name (page 8-198) MbeTag.targetId (page 8-199) MbeTag.setName = “set1” tag.setName (page 8-197) MbeTag. set the offset of the tag from the base element. MbeTag.getMbeElement Used to get or set the parent tagset name.size (page 8-200) MbeTag.setName.

setName.fileNum Descr. MbeElement.attachTag.fileNum MbeTag.tagType = MBE_TagString() ‘attach tag end if See also MbeTagDef.fileNum = 0 then ‘attach tag end if See also MbeElement. Example ‘check the validity of the tag if tag.name Descr.getMbeTag.name = "tag1" ‘check the type if tag.name MbeTag.name. MbeTagDef.id Descr. MbeTag.id is a read only property of type Long specifying the unique ID associated with the underlying tag (type 37) instance.fileNum is a read only Integer property specifying the file number from which the MbeTag object is originated. MbeTag. Example ‘check the file number if tag. Example Dim tag as new MbeTag 'set tag properties tag. MbeTag.name is a read/write String property which sets or retrieves the name of the tag definition from which tag instance object MbeTag is derived. 8-198 MicroStation BASIC Guide .id MbeTag. MbeTag.attachTag. MbeTag. MbeElement.id > 0 then ‘extract text element end if See also MbeElement.setName = “set1” tag.MbeTag Object MbeTag.name should be set before calling most of MbeTag methods.getMbeTag. MbeTag.

tagType. MbeTag.targetId is a read only property of type Long specifying the unique association ID of the element the tag is attached to.targetId Descr.tagType. MicroStation BASIC Guide 8-199 8 MicroStation Extensions to BASIC Descr.targetId > 0 then stat = tag.attachTag(tag) See also MbeTagDef. MbeTag.targetId MbeTag.value = Str$ (count) stat = inElem. MbeTag.value is a read/write String property which sets or retrieves the tag value. Example ‘check whether the tag is attached if tag.type can take any of the following values: MBE_TagString. MBE_TagDouble or MBE_TagBinary.size end if See also MbeTagDef.type is a read only Integer property which retrieves the data type of the tag value.getTaggedElement(el) ‘extract text element end if See also MbeElement. MbeTag. MbeTag.value Descr. MbeTag.getTaggedElement. MbeTag.MbeTag Object MbeTag. MBE_TagInteger. MbeTag. Example Dim tag as new MbeTag tag. .setName = "set0001" 'tag element count tag.type MbeTag.attachTag. MBE_TagLong.type Example Dim tag as new MbeTag dim size as integer if tag.tagType = MBE_TagString then size = tag.name = "elemnum" tag.value.value MbeTag.

isHidden value for the parent tag definition.value.version > 5 then ‘ do 95 special end if See also MbeElement.attachTag. MbeTag.version Descr.isHidden.name = "elemnum" tag.tagSize = MBE_TagString then size = tag.isHidden MbeTag. MbeTag.version is a read only Integer property which retrieves the version number of the underlying tag element.value = Str$ (count) ‘hide the tag element tag.tagType. 8-200 MicroStation BASIC Guide .size is a read only Integer property which retrieves the size in bytes of tag value if it is of type MBE_TagString or MBE_TagBinary. Example Dim tag as new MbeTag dim size as Integer if tag.value. MbeTag. MbeTag. Example if tag. MbeTag.isHidden Descr.version MbeTag.isHidden is a read/write Integer property which sets or retrieves the display mode for the tag. MbeTagDef.isHidden takes values either 1 (hidden) or 0 (display). Example Dim tag as new MbeTag Dim inElem as MbeElement 'tag element count tag.size Descr.size end if See also MbeTagDef.MbeTag Object MbeTag. MbeTag.isHidden = 1 stat = inElem. MbeTag. MbeTag.attachTag.attachTag(tag) See also MbeElement. Default value is the MbeTagDef.size MbeTag.

setOffset.x = 10.getMbeElement retrieves the underlying MbeElement of type 37. MBE_InvalidTagSet if the name or setName properties are not and a different error code otherwise.setOffset(offset) stat = inElem.getOffset stat = MbeTag.getMbeElement returns MBE_Success if the element is retrieved successfully.getMbeElement(element as MbeElement) Descr.getOffset returns MBE_Success if the offset is retrieved successfully. Example Dim tag as new MbeTag Dim tagElem as new MbeElement MicroStation BASIC Guide 8-201 8 MicroStation Extensions to BASIC . MbeTag.getOffset(offset) See also MbeTag. MBE_InvalidTagSet if the name or setName properties are not. MbeTag. Example Dim tag as new MbeTag Dim offset as new MbePointObj offset. MbeTag.getOffset gets the offset for the underlying tag element from its attached element MbeTag.attachTag(tag) See also MbeTag. MbeTag. MbeTag.getOffset.getMbeElement stat = MbeTag.setOffset sets the offset for the underlying tag element from its attached element MbeTag. MBE_InvalidTagSet if the name or setName properties are not.0 offset. MbeTag.getOffset(offset as MbePointObj) Descr.MbeTag Object MbeTag.y = 10.setOffset returns MBE_Success if the offset is set successfully.setOffset(offset as MbePointObj) Descr.0 offset. Example Dim tag as new MbeTag Dim offset as new MbePointObj stat = tag.x = 0 stat = tag.setOffset stat = MbeTag.

MBE_InvalidTagSet if the name or setName properties are not and a different error code otherwise.. MbeTag. stat = tag. MbeTag.getMbeElement. MBE_InvalidTagSet if the name or setName properties are not and a different error code otherwise. MbeElement. MbeTag.getTextElement(txtElem) See also MbeTag.getTaggedElement stat = MbeTag. txtElem (of type 17) from the underlying tag element.getTaggedElement.MbeTag Object .getTaggedElement returns MBE_Success if the tag is attached to an element and is retrieved successfully. MbeTag. MbeTag.getTextElement(txtElem as MbeElement) Descr.getTextElement function creates a Text element. stat = tag..getTextElement stat = MbeTag..getTaggedElement retrieves the MbeElement baseElem to which the underlying tag is attached. Example Dim tag as new MbeTag Dim txtElem as new MbeElement . New Text element gets similar properties and symbologies of the tag element.getMbeTag.getMbeElement(tagElem) See also MbeTag.. 8-202 MicroStation BASIC Guide . Example Dim tag as new MbeTag Dim tagElem as new MbeElement .getTextElement returns MBE_Success if the Text element is created successfully.getMbeTag..getTaggedElement(baseElem as MbeElement) Descr. MbeTag..getTaggedElement(baseElem) See also MbeElement. stat = tag.

This BASIC extension is very similar to the Sleep command. This allows the rest of MicroStation to catch up on some of its processing. the MicroStation BASIC interpreter is not suspended therefore other parts of MicroStation are not allowed to "catch up" in their processing. The Sleep command also suspends the macro for a given duration.suspend MbeMacro. MicroStation BASIC Guide 8-203 8 MicroStation Extensions to BASIC Descr. the default for the suspension is 250 ms (0. With MbeMacro. however. MbeMacro.25 seconds). such as refreshing parts of views that were revealed by the closing of modal dialogs during the execution of the macro. The MbeMacro.suspend.suspend [duration As Long] See also Sleep. The number of milliseconds is supplied in the optional duration parameter. the MicroStation BASIC interpreter is also suspended.MbeMacro Object MbeMacro Object The MbeMacro object is used to control certain operational characteristics of the currently executing macro. in that case. If duration is not supplied. .suspend Used to suspend the macro (and the MicroStation BASIC interpreter) such that other parts of MicroStation can get processing time.suspend method will suspend the macro for the stated number of milliseconds [ms]. Properties and Methods MbeMacro.

type (page 8-205) GbeTLayerPoint. GbeTLayerLine.sqlStatement.type.holes.name. GbeTLayerMixed. This is not a member of the GbeTLayerMixed object. Mixed-type topology layer.holes.queryList. Polygon-type topology layer.sqlStatement. GbeTLayerPolygon. This is not a member of the GbeTLayerMixed object.name.Topology Objects Topology Objects Object Type GbeTLayerPoint GbeTLayerLine GbeTLayerPolygon GbeTLayerMixed Description Point-type topology layer.load. GbeTLayerLine. GbeTLayerLine. (page 8-205) GbeTLayerPoint. get or set the topology layer SQL statement.sqlStatement. GbeTLayerMixed. (page 8-206) GbeTLayerPoint. GbeTLayerMixed.name (page 8-205) GbeTLayerPoint. GbeTLayerPolygon.holes. GbeTLayerPolygon. GbeTLayerLine.queryList.shapesAsAreas. GbeTLayerMixed.queryList. 8-204 MicroStation BASIC Guide . GbeTLayerMixed. Line-type topology layer. (page 8-206) GbeTLayerPoint. GbeTLayerLine.name. GbeTLayerMixed.shapesAsAreas.sqlStatement Used to retrieve the type of the topology layer.queryList get or set the topology layer name. This is not a member of the GbeTLayerMixed object.type.load (page 8-206) load the topology layer.holes (page 8-206) GbeTLayerPoint. This is not a member of the GbeTLayerMixed object.shapesAsAreas.shapesAsAreas set whether or not to use holes. GbeTLayerPolygon.load.type. set whether or not to shapes as areas. GbeTLayerLine. Properties and Methods GbeTLayerPoint. GbeTLayerLine. GbeTLayerPolygon. set whether or not to use query lists. GbeTLayerMixed. This is not a member of the GbeTLayerMixed object. The following properties and methods refer to one of the GbeTLayerType objects.load. GbeTLayerPolygon. GbeTLayerPolygon.

name GbeTLayerLine.display.display. The GbeTLayer_. GbeTLayerPolygon.display. GbeTLayerLine. GbeTLayerLine. GbeTLayerPolygon.sqlStatement Descr.sqlStatement. GbeTLayerMixed. GbeTLayerLine.type GbeTLayerPolygon.name GbeTLayerPolygon. add the topology layer to the design file.add. GbeTLayerPolygon. GbeTLayerMixed.type GbeTLayerMixed.Topology Objects Properties and Methods GbeTLayerPoint.type read-only Integer properties return the topology layer type.sqlStatement GbeTLayerMixed. GbeTLayerPoint.display (page 8-207) GbeTLayerPoint.sqlStatement. GbeTLayerMixed. GbeTLayerMixed.sqlStatement read/write String properties set or retrieve the topology layer SQL statement.type. GbeTLayerLine.sqlStatement GbeTLayerPoint.add. GbeTLayerPoint.type GbeTLayerPoint. GbeTLayerMixed.sqlStatement. GbeTLayerPolygon.name.type Descr.name. The GbeTLayer_. GbeTLayerPolygon.add. Type GBE_TypePolygon GBE_TypeLine GBE_TypePoint GBE_TypeMixed Mask Value 1 2 3 4 GbeTLayerPoint.name MicroStation BASIC Guide 8-205 8 MicroStation Extensions to BASIC .sqlStatement GbeTLayerLine.add (page 8-207) Used to display the topology layer.sqlStatement GbeTLayerPolygon.type GbeTLayerLine.type. GbeTLayerLine.name GbeTLayerMixed.name GbeTLayerPoint.name.type.

holes object functions will set whether or not to use holes.load. GbeTLayerMixed.load() 8-206 MicroStation BASIC Guide .holes GbeTLayerPoint. GbeTLayerMixed.shapesAsAreas.queryList [GBE_True.holes.shapesAsAreas.shapesAsAreas [GBE_True.holes.queryList [GBE_True. GBE_False] GbeTLayerPolygon. GbeTLayerLine.queryList. The GbeTLayer_. GBE_False] GbeTLayerMixed. GbeTLayerPoint. GBE_False] GbeTLayerPolygon.queryList.Topology Objects Descr. The GbeTLayer_. GBE_False] GbeTLayerMixed.holes. GbeTLayerPoint.shapesAsAreas [GBE_True.shapesAsAreas [GBE_True.queryList GbeTLayerPoint. GbeTLayerMixed.holes [GBE_True.name read/write String properties set or retrieve the topology layer name.shapesAsAreas GbeTLayerPoint.load.holes [GBE_True.holes [GBE_True.load.queryList [GBE_True. GBE_False] Descr. The GbeTLayer_.load() GbeTLayerPolygon. GbeTLayerPolygon. GbeTLayerPoint.queryList object functions will set whether or not to use query lists. GBE_False] GbeTLayerLine. GbeTLayerMixed. GbeTLayerPoint. GbeTLayerLine. GbeTLayerLine.shapesAsAreas object functions will set whether or not to use shapes as areas.holes [GBE_True. GBE_False] Descr.queryList. GbeTLayerPolygon. GBE_False] GbeTLayerLine.load stat stat stat stat = = = = GbeTLayerPoint. GbeTLayerLine. GbeTLayerPolygon.shapesAsAreas. GBE_False] GbeTLayerLine. The GbeTLayer_. GBE_False] GbeTLayerMixed. GBE_False] Descr. GbeTLayerPolygon. GBE_False] GbeTLayerPolygon.queryList [GBE_True.shapesAsAreas [GBE_True.load() GbeTLayerLine.load() GbeTLayerMixed.

The GbeTLayer_.display object functions display the topology layer.display() GbeTLayerLine. GbeTLayerMixed.add() GbeTLayerPolygon. Will return MBE_Success if the topology layer is loaded successfully.display. MicroStation BASIC Guide 8-207 8 . GbeTLayerPolygon.display() GbeTLayerPolygon. GbeTLayerPolygon.display MicroStation Extensions to BASIC stat stat stat stat = = = = GbeTopoLayerPoint.display() GbeTLayerMixed.add.add() Descr. The GbeTLayer_. GbeTLayerLine.display.add stat stat stat stat = = = = GbeTLayerPoint.add() GbeTLayerMixed. GbeTLayerLine.display() Descr. Will return MBE_Success if the topology layer is added successfully.load object functions create a topology layer based upon the specifications previously defined.add object functions add the topology layer to the design file.display. MBE_Success will be returned if the layer can be displayed. The GbeTLayer_.add() GbeTLayerLine. GbeTLayerPoint.Topology Objects Descr. GbeTLayerMixed.add. The topology layer must have been previously loaded. GbeTLayerPoint.add.

weight Descr. The GbeTLayerPoint.color GbeTLayerPoint. GbeTLayerPoint.level read/write Integer property sets or retrieves the centroid level.color (page 8-208) GbeTLayerPoint. GbeTLayerPoint. GbeTLayerPoint. get or set the node type.color read/write Integer property sets or retrieves the centroid color.nodeType GbeTLayerPoint.weight (page 8-208) GbeTLayerPoint. generate a point overlay.nodeType 8-208 MicroStation BASIC Guide .color Descr. (page 8-209) GbeTLayerPoint.level GbeTLayerPoint.weight GbeTLayerPoint.level Descr.pointPolyOverlay Used to get or set the color.level (page 8-208) GbeTLayerPoint. The GbeTLayerPoint. The GbeTLayerPoint. get or set the level.nodeType (page 8-208) GbeTLayerPoint. get or set the weight.weight read/write Integer property sets or retrieves the centroid weight.GbeTLayerPoint Object GbeTLayerPoint Object Properties and Methods GbeTLayerPoint.

_ polyTopo as GbeTLayerPolygon.selection _ as Integer) Descr. The selection criteria should be based upon a bitwise OR combination of the following selection criteria.pointPolyOverlay(pointTopo as GbeTLayerPoint.pointPolyOverlay stat = GbeTLayerPoint. GBE_False]. polyTopo. The GbeTLayerPoint. The pointTopo and polyTopo objects must have been previously loaded. GBE_TRUE. Set linkage to GBE_True to copy the feature linkages. Node Type GBE_Point GBE_TextNode Mask Value 1 2 GbeTLayerPoint. linkage as [GBE_True.pointPolyOverlay object function will generate a point overlay from a point topology object and a polygon topology object. _ GBE_Inside OR GBE_Overlap) MicroStation BASIC Guide 8-209 8 MicroStation Extensions to BASIC Selection Mask Value . GBE_Inside GBE_Outside GBE_Overlap 4 8 16 Example status = GbeTLayerPoint.GbeTLayerPoint Object Descr.pointPolyOverlay(pointTopo.nodeType read/write Integer property sets or retrieves the centroid node type. The GbeTLayerPoint.

selection _ as Integer) 8-210 MicroStation BASIC Guide .linePolyOverlay stat = GbeTLayerPolygon. GbeTLayerLine.weight (page 8-210) GbeTLayerLine.level read/write Integer property sets or retrieves the boundary level. GbeTLayerLine.level (page 8-210) GbeTLayerLine. The GbeTLayerLine. linkage as [GBE_True. GbeTLayerLine. get or set the level.style (page 8-210) GbeTLayerLine.color Descr. The GbeTLayerLine.color (page 8-210) GbeTLayerLine.color read/write Integer property sets or retrieves the boundary color.weight Descr.linePolyOverlay Used to get or set the color. GbeTLayerLine.linePolyOverlay (lineTopo as GbeTLayerLine.level Descr. get or set the style. The GbeTLayerLine.color GbeTLayerLine. get or set the weight.level GbeTLayerLine. The GbeTLayerLine.GbeTLayerLine Object GbeTLayerLine Object Properties and Methods GbeTLayerLine. (page 8-210) GbeTLayerLine.weight read/write Integer property sets or retrieves the boundary weight.style Descr.weight GbeTLayerLine.style read/write Integer property sets or retrieves the boundary style.style GbeTLayerLine. generate a line overlay. _ polyTopo as GbeTLayerPolygon. GBE_False].

GbeTLayerLine Object Descr. polyTopo. GBE_TRUE. The GbeTLayerLine.linePolyOverlay(lineTopo. The lineTopo and polyTopo objects must have been previously loaded. _ GBE_Inside OR GBE_Overlap) MicroStation BASIC Guide 8-211 8 MicroStation Extensions to BASIC .linePolyOverlay object function will generate a line overlay from a line topology object and a polygon topology object. Selection GBE_Inside GBE_Outside GBE_Overlap Mask Value 4 8 16 Example status = GbeTLayerLine. The selection criteria should be based upon a bitwise OR combination of the following selection criteria. Set linkage to GBE_True to copy the feature linkages.

GbeTLayerPolygon. The GbeTLayerPolygon.style read/write Integer property sets or retrieves the polygon style.doFill (page 8-213) GbeTLayerPolygon. generate a polygon overlay from two polygon overlays.level Descr.fillColor Used to get or set the color. get or set the style.color GbeTLayerPolygon. set whether or not to fill the area.weight 8-212 MicroStation BASIC Guide .color Descr. generate a line overlay from a line and a polygon overlay. The GbeTLayerPolygon.linePolyOverlay (page 8-214) GbeTLayerPolygon. (page 8-213) GbeTLayerPolygon.level GbeTLayerPolygon.level read/write Integer property sets or retrieves the polygon level.polyPolyOverlay (page 8-213) GbeTLayerPolygon.pointPolyOverlay (page 8-213) GbeTLayerPolygon. GbeTLayerPolygon.style Descr.GbeTLayerPolygon Object GbeTLayerPolygon Object Properties and Methods GbeTLayerPolygon. get or set the fill color. get or set the weight.color read/write Integer property sets or retrieves the polygon color.style (page 8-212) GbeTLayerPolygon. generate a polygon overlay from a point and a polygon overlay.weight GbeTLayerPolygon.level (page 8-212) GbeTLayerPolygon.color (page 8-212) GbeTLayerPolygon.style GbeTLayerPolygon. get or set the level. GbeTLayerPolygon. The GbeTLayerPolygon.weight (page 8-212) GbeTLayerPolygon.

Set linkage to GBE_True to copy the feature linkages. operator as [GBE_AND. _ GBE_DIFF].polyPolyOverlay(polyOne as GbeTLayerPolygon. Set linkage to GBE_True to copy the feature MicroStation BASIC Guide 8-213 8 4 MicroStation Extensions to BASIC .weight read/write Integer property sets or retrieves the polygon weight. GBE_OR. GBE_XOR. The GbeTLayerPolygon.fillColor Descr.GBE_False]. the polygon will be filled with the color specified by the fillColor property. The GbeTLayerPolygon.GbeTLayerPolygon Object Descr. GBE_False]) Descr. GBE_False] Descr. linkage as [GBE_True. GbeTLayerPolygon.pointPolyOverlay object function will generate a polygon overlay from a point topology and a polygon topology. The polyOne and polyTwo objects must have been previously loaded.doFill [GBE_True. GbeTLayerPolygon. Set operator to one of the following: operator GBE_ADD GBE_OR GBE_XOR GBE_DIFF Mask Value 1 2 3 GbeTLayerPolygon.polyPolyOverlay object function will generate a polygon overlay from two polygon topology objects. The GbeTLayerPolygon.selection _ as Integer) Descr. _ polyTopo as GbeTLayerPolygon. The GbeTLayerPolygon. GbeTLayerPolygon. The GbeTLayerPolygon. GbeTLayerPolygon.pointPolyOverlay(pointTopo as GbeTLayerPoint.polyPolyOverlay stat = GbeTLayerPolygon.fillColor GbeTLayerPolygon. _ polyTwo as GbeTLayerPolygon.pointPolyOverlay stat = GbeTLayerPolygon. The pointTopo and polyTopo objects must have been previously loaded. linkage as [GBE_True.doFill must be set to GBE_True for this property to have any affect.doFill GbeTLayerPolygon.fillColor read/write Integer property sets or retrieves the polygon fill color.doFill write-only Integer property determines whether or not fill the polygon. If GBE_True is set.

The GbeTLayerPolygon. Selection GBE_Inside GBE_Outside GBE_Overlap Mask Value 4 8 16 Example status = GbeTLayerPolygon. The selection criteria should be based upon a bitwise OR combination of the following selection criteria.selection _ as Integer) Descr. Set linkage to GBE_True to copy the feature linkages.GBE_False].GbeTLayerPolygon Object linkages. _ polyTopo as GbeTLayerPolygon.GBE_TRUE. Selection GBE_Inside GBE_Outside GBE_Overlap Mask Value 4 8 16 Example status = GbeTLayerPolygon.linePolyOverlay stat = GbeTLayerPolygon. polyTopo. _ GBE_Inside OR GBE_Overlap) GbeTLayerPolygon.GBE_TRUE.linePolyOverlay object function will generate a polygon overlay from a line topology and a polygon topology. linkage as [GBE_True. The selection criteria should be based upon a bitwise OR combination of the following selection criteria.linePolyOverlay(lineTopo. The lineTopo and polyTopo objects must have been previously loaded. _ GBE_Inside OR GBE_Overlap) 8-214 MicroStation BASIC Guide .polyTopo.linePolyOverlay(lineTopo as GbeTLayerLine.pointPolyOverlay(pointTopo.

GBE_TRUE. selection as Integer) Descr.linePolyOverlay object function will generate a mixed overlay from a line topology and a polygon topology. linkage as [GBE_True. The pointTopo and polyTopo objects must have been previously loaded.linePolyOverlay (page 8-215) GbeTLayerMixed.pointPolyOverlay stat = GbeTLayerMixed. The GbeTLayerMixed. polyTopo.pointPolyOverlay object function will generate a mixed overlay from a point topology and a polygon topology. GBE_False].pointPolyOverlay(pointTopo. GBE_False]. selection as Integer) Selection GBE_Inside GBE_Outside GBE_Overlap Mask Value 4 8 16 Example status = GbeTLayerMixed. The selection criteria should be based upon a bitwise OR combination of the following selection criteria. polyTopo as GbeTLayerPolygon. Set linkage to GBE_True to copy the feature linkages. (page 8-215) GbeTLayerMixed. _ GBE_Inside OR GBE_Overlap) GbeTLayerMixed. poltTopo as GbeTLayerPolygon. The GbeTLayerMixed. The lineTopo and polyTopo objects must have been previously loaded.pointPolyOverlay (pointTopo as GbeTLayerPoint. generate a mixed overlay from line and polygon topologies.pointPolyOverlay Used to generate a mixed overlay from point and polygon topologies. MicroStation BASIC Guide 8-215 8 MicroStation Extensions to BASIC Descr. Set linkage to GBE_True to copy the feature linkages. .linePolyOverlay stat = GbeTLayerMixed.linePolyOverlay(lineTopo as GbeTLayerLine. linkage as [GBE_True.GbeTLayerMixed Object GbeTLayerMixed Object Properties and Methods GbeTLayerMixed.

linePolyOverlay(lineTopo. Selection GBE_Inside GBE_Outside GBE_Overlap Mask Value 4 8 16 Example status = GbeTLayerMixed. GBE_TRUE. _ GBE_Inside OR GBE_Overlap) Topology Error Codes Error Number Error Message Built-in Constant Name GBE_TopologyInitFail GBE_NoLayerName GBE_NoFenceDefined GBE_EmptyTopology GBE_LayerAlreadyPopulated GBE_ErrorGeneratingOverlay GBE_SqlNotSpecified 2520 2521 2522 2523 2524 2525 2526 Error when trying to initialize the topology layer. Empty topology will not be created. The topology layer name has not been defined. polyTopo. Error when trying to generate an overlay. Attempt to produce an overlay layer in a previously populated topology layer. No fence has been placed previous to performing topology load. 8-216 MicroStation BASIC Guide . The topology SQL statement has not been set.GbeTLayerMixed Object The selection criteria should be based upon a bitwise OR combination of the following selection criteria.

listByMslink(array() as Long) MicroStation BASIC Guide 8-217 8 MicroStation Extensions to BASIC .listMapsByMslink (page 8-219) GbeCategory. (page 8-217) GbeCategories.attachMaps (page 8-218) GbeCategory.maxCategories GbeCategories. GbeCategories.maxCategories Descr.indexFromMslink (page 8-218) The properties and methods listed below in this table refer to a GbeCategory object and the category table slot to which it refers. propagate a Long array with a list of category mslinks available in the currently open project. propagate a Long array with the mslinks of all feature associated with the category. propagate a Long array with the mslinks of all maps currently available to the category.name (page 8-219) GbeCategories.Category Object Category Object Properties and Methods GbeCategories. return an individual GbeCategory object corresponding to the category identified by index. (page 8-219) GbeCategory.mslink (page 8-219) GbeCategory.maxCategories Used to determine the maximum number of categories that are available in the currently open project. retrieve the file extension of the category. detach all maps associated with the category. retrieve the cell library name of the category.cellLibrary (page 8-218) GbeCategory. return the index number of the GbeCategory object identified by mslink. retrieve the name of the category.maxCategories read-only property returns an Integer that is the maximum number of categories which are available to the currently open project.listByMslink (page 8-217) GbeCategories(index) (page 8-218) GbeCategories. retrieve the mslink of the category. The GbeCategories.detachMaps (page 8-218) GbeCategory.fileExt (page 8-219) GbeCategory.listByMslink value = GbeCategories.listFeaturesByMslink Used to attach all maps associated with the category. Properties and Methods GbeCategory.

indexFromMslink returns an Integer representing the index of the GbeCategory matching mslink. or a GbeCategory object can be declared and set to GbeCategory(index). GbeCategories(index) retrieves the GbeCategory object associated with the index.cellLibrary read-only property returns a String that corresponds to the category cell library.detachMaps stat = GbeCategory.cellLibrary GbeCategory. GbeCategory.name Next iCat GbeCategories. GbeCategories. Returns the number of maps attached. Zero is returned if no GbeCategory is found. The properties of the GbeCategory object to be retrieved can be directly referenced.detachMaps() 8-218 MicroStation BASIC Guide .attachMaps stat = GbeCategory. Returns the number of category mslinks added to array.attachMaps command will attach all maps associated with the category being referenced.cellLibrary Descr. The GbeCategory. The GbeCategories.maxCategories print "Category Names: " & GbeCateogies(iCat). GbeCategories(index) GbeCategories(index) Descr.attachMaps() Descr.listByMslink command propagates array with Longs corresponding to the mslinks of all categories available in the currently open project. Example Dim iCat as Integer For iCat = 1 to GbeCategories.Category Object Descr. GbeCategory.indexFromMslink(mslink as Long) Descr.indexFromMslink value = GbeCategories. GbeCategory. The GbeCategory.

The GbeCategory.mslink GbeCategory.Category Object Descr.listFeaturesByMslink command propagates array with Longs corresponding to the mslinks of all features associated to the category being referenced. GbeCategory.listMapsByMslink command propagates array with Longs corresponding to the mslinks of all maps available to the category being referenced.listMapsByMslink .fileExt Descr.mslink read-only property returns an Integer that corresponds to the category mslink.listByMslink(catList) For i = 1 to iMax MicroStation BASIC Guide 8-219 8 GbeCategory. The GbeCategory. GbeCategory. The GbeCategory.mslink Descr. Example Sub main Dim Dim Dim Dim iMax as Integer catList() as Long i as Integer taxCategory as GbeCategory iMax = GbeCategories.name Descr. GbeCategory.detachMaps command will detach all maps associated with the category being referenced. value = GbeCategory.fileExt GbeCategory.name MicroStation Extensions to BASIC GbeCategory.listMapsByMslink(array() as Long) Descr. The GbeCategory. GbeCategory.listFeaturesByMslink(array() as Long) Descr.fileExt read-only property returns a String that corresponds to the category file extension. The GbeCategory. The GbeCategory.listFeaturesByMslink value = GbeCategory.name read-only property returns a String that corresponds to the category name. Returns the number of maps detached. Returns the number of features associated with the specified category. Returns the number of maps associated with the specified category.

The index specifying the category object has exceeded the maximum number of category indexes.Category Object print "Category Name: " & GbeCategories(i).attachMaps () print "Number of maps attached: " & str$(numMaps) Set taxCategory = GbeCategories (2) print taxCategory.mslink) End Sub Category Error Codes Error Number Error Message Built-in Constant Name GBE_InvalidCategoryIndex 2530 An invalid category index has been entered. 8-220 MicroStation BASIC Guide .fileExt print Next i numMaps = GbeCategories(2).name & " category mslink is" & _ str$(taxCategory.name print " Mslink : " & str$(catList(i-1)) print " File Ext : " & GbeCategories(i).

propagate a Long array with a list of feature mslinks available in the currently open project. Properties and Methods GbeFeature. (page 8-221) GbeFeatures.maxFeatures GbeFeatures.type (page 8-223) GbeFeature.listByMslink(array() as Long) MicroStation BASIC Guide 8-221 8 MicroStation Extensions to BASIC .level (page 8-223) GbeFeature. return an individual GbeFeature object corresponding to the feature identified by index.Feature Object Feature Object Properties and Methods GbeFeatures.listByMslink (page 8-221) GbeFeatures(index) (page 8-222) GbeFeatures. retrieve the weight of the feature. return the index number of the GbeFeature object identified by mslink. turn on or off the display of the feature. retrieve the type of feature element. retrieve the name of the feature. retrieve the description of the feature. GbeFeatures. (page 8-222) GbeFeature. retrieve the mslink of the feature.name (page 8-219) GbeFeature.mslink (page 8-223) GbeCategory.maxFeatures Used to determine the maximum number of features that are available in the currently open project.color (page 8-222) GbeFeature.description (page 8-222) GbeFeature.categoryMslink Used to retrieve the category mslink of the feature. retrieve the style of the feature.maxCategories read-only property returns an Integer that is the maximum number of features which are available to the currently open project.listByMslink value = GbeFeatures.display (page 8-223) GbeFeature.maxCategories Descr.indexFromMslink (page 8-222) The properties and methods listed below in this table refer to a GbeFeature object and the feature table slot to which it refers.weight (page 8-224) GbeFeatures. retrieve the color of the feature. The GbeFeatures. retrieve the level of the feature.style (page 8-223) GbeFeature.

GbeFeatures. Example Dim iFea as Integer For iFea = 1 to GbeFeature.color read-only property returns an Integer that corresponds to the feature color.color GbeFeature. GbeFeature. GbeFeature. The GbeFeature.indexFromMslink value = GbeFeatures. The GbeFeature.maxFeatures print "Feature Names: " & GbeFeatures(iFea). GbeFeature. Returns the number of features added to array.Feature Object Descr.description 8-222 MicroStation BASIC Guide .color Descr.categoryMslink read-only property returns a Long that corresponds to the feature’s category mslink. GbeFeatures(index) retrieves the GbeFeature object associated with the index. The properties of the GbeFeature object so retrieved can be directly referenced.categoryMslink Descr. Zero is returned if GbeFeature is found.name Next iFea GbeFeatures. or a GbeFeature object can be declared and Set to GbeFeature(index).indexFromMslink(mslink as Long) Descr. GbeFeatures(index) GbeFeatures(index) Descr. The GbeFeatures.listByMslink command propagates array with Longs corresponding to the mslinks of all features available in the currently open project.indexFromMslink returns an Integer representing the index of the GbeFeature matching mslink.description GbeFeature.categoryMslink GbeFeature.

GbeFeature.description read-only property returns a String that corresponds to the feature description.8].onOff _ as [GBE_True.Feature Object Descr. GbeFeature. the changes to display will be updated.GBE_False]. The GbeFeature.mslink GbeFeature.display command will either turn on or off the display of the GbeFeature specified by view. The GbeFeature. The GbeFeature. Set apply to true if you wish to apply the changes to the specified view.level GbeFeature.name Descr. GbeFeature.mslink Descr. apply as [GBE_True. GBE_False]) Descr.display(view as Integer.display GbeFeature. OnOff specifies whether or not to turn the feature on or off.mslink read-only property returns an Integer that corresponds to the feature mslink.style Descr. Specify the view which the feature should be displayed [1 . The GbeFeature. GbeFeature. GbeFeature.level GbeFeature. The GbeFeature.level read-only property returns an Integer that corresponds to the feature level.style read-only property returns an Integer that corresponds to the feature style.type MicroStation BASIC Guide 8-223 8 MicroStation Extensions to BASIC Descr.type GbeFeature.style GbeFeature. The GbeFeature. .name read-only property returns a String that corresponds to the feature name. otherwise.name GbeFeature.

The GbeFeature.type read-only property returns an Integer that corresponds to the feature type. Feature Error Codes Error Number Error Message Built-in Constant Name GBE_InvalidFeatureIndex 2540 An invalid feature index has been entered.weight read-only property returns an Integer that corresponds to the feature weight.weight Descr. GbeFeature. The index specifying the feature object has exceeded the maximum number of feature indexes.Feature Object Descr. The GbeFeature. 8-224 MicroStation BASIC Guide .weight GbeFeature.

The GbeMaps. retrieve the category mslink of the map.listByMslink(array() as Long) MicroStation BASIC Guide 8-225 8 MicroStation Extensions to BASIC .listByMslink value = GbeMaps.maxMaps read-only property returns an Integer that is the maximum number of maps which are available to the currently open project.attachByView (page 8-226) GbeMaps(index) (page 8-226) GbeMaps.categoryMslink (page 8-227) GbeMaps.attach (page 8-227) GbeMap. retrieve the description of the map.Map Object Map Object Properties and Methods GbeMaps. GbeMaps.maxMaps Descr. return whether or not the map being referenced is currently attached. retrieve the directory of the map if not in project/dgn.name (page 8-226) GbeMap. propagate a long array with a list of map mslinks available in the currently open project.maxMaps (page 8-225) GbeMaps. attach the map being referenced. detach the map being referenced.description Used to retrieve the mslink of the map.detach (page 8-227) GbeMap. retrieve the name of the map. return an individual GbeMap object corresponding to the map identified by index. return the index number of the GbeMap object identified by mslink. (page 8-227) GbeMap. Properties and Methods GbeMap.directory (page 8-227) GbeMap.mslink (page 8-226) GbeMap.maxMaps GbeMaps.indexFromMslink (page 8-226) The properties and methods listed below in this table refer to a GbeMap object and the map table slot to which it refers. attach all maps included in a specified view. (page 8-225) GbeMaps.isAttached (page 8-227) GbeMap.listByMslink Used to determine the maximum number of maps that are available in the currently open project.

maxMaps print "Map Names: " & GbeMaps(iMap). or an GbeMap object can be declared and set to GbeMap(index).mslink GbeMap. The GbeMap. The GbeMaps. GbeMaps. Example Dim iMap as Integer For iMap = 1 to GbeMaps. GbeMaps(index) retrieves the GbeMap object associated with index. The GbeMaps. Zero is returned if no GbeMap is found.mslink read-only property returns an Integer that corresponds to the map mslink.name Next iMap GbeMaps.attachByView(view as Integer) Descr. GbeMaps(index) GbeMaps(index) Descr.indexFromMslink returns an Integer value representing the index of the GbeMap matching mslink. The number of map mslinks added to array will be returned.mslink Descr.listByMslink command propagates array with Longs corresponding to the mslinks of all maps available in the currently open project.Map Object Descr.indexFromMslink value = GbeMaps.attachByView command will attach all maps included in the view specified. Will return the number of maps attached as an Integer. GbeMaps. GbeMap. The properties of the GbeMap object so retrieved can be directly referenced. GbeMap.name GbeMap.indexFromMslink (mslink as Long) Descr.name 8-226 MicroStation BASIC Guide .attachByView value = GbeMaps.

The GbeMap.detach Descr. The GbeMap. GbeMap. GbeMap.categoryMslink GbeMap.isAttached() Descr. The GbeMap.description read-only property returns a String that corresponds to the map description.directory Descr.categoryMslink Descr.isAttached object function returns an Integer that is nonzero if the map specified is attached. GbeMap.attach .attach Descr.description Descr. GbeMap.Map Object Descr. Example Sub main Dim iMap as Integer Dim maps() as Long iMap = GbeMaps.detach object command will detach the map currently being referenced.detach GbeMap. The GbeMap.isAttached stat = GbeMap.directory GbeMap.description GbeMap. The GbeMap.name read-only property returns a String that corresponds to the map name. The GbeMap. GbeMap. The GbeMap.listByMslink (maps) MicroStation BASIC Guide 8-227 8 MicroStation Extensions to BASIC GbeMap.directory read-only property returns a String that corresponds to the map file directory if something other than project/dgn.categoryMslink read-only property returns a Long that corresponds to the category mslink of the map being referenced.attach object command will attach the map currently being referenced. GbeMap.

attachByView 8 End Sub Map Error Codes Error Number Error Message Built-in Constant Name GBE_InvalidMapIndex 2510 An invalid map index has been entered. The index specifying the map object has exceeded the maximum number of map indexes.mslink) print " Directory: " & GbeMaps(i).name print " Mslink: " & str$(GbeMaps(i).Map Object For i = 1 to iMap print "Map Name:" & GbeMaps(i).description print next i GbeMaps. 8-228 MicroStation BASIC Guide .directory print " Description: " & GbeMaps(i).

DBload write-only property will set whether or not to load the project tables from the relational database.keyMap (page 8-230) GbeProject. Set whether or not open a blank GeoGraphics Work Map. If GbeProject.close (page 8-231) GbeProject.DBconnect write-only property will set whether or not to create a connection to the relational database using the name provided with GbeProject. GbeProject. The GbeProject.open (page 8-230) GbeProject. Set whether or not to load the database.directory MicroStation BASIC Guide 8-229 8 MicroStation Extensions to BASIC (page 8-230) . Get or set the project export file. Set whether or not to load the MAPS table. GBE_False] Descr. the project database information will be loaded from the export file name specified by GbeProject.DBconnect Used to Set whether or not to connect to the database.directory GbeProject.loginName (page 8-230) GbeProject.exportFile. Get or set the project directory.DBconnect GbeProject. (page 8-229) GbeProject.DBload GbeProject. GbeProject.loginName.DBconnect [GBE_True.DBload is not. Performs a project close. The GbeProject.directory (page 8-229) GbeProject. GBE_False] Descr. Set whether or not to load the Key Map.exportFile (page 8-230) GbeProject.workMap GbeProject.DBload (page 8-229) GbeProject. Get or set the project database login name.DBload [GBE_True.mapManager (page 8-230) GbeProject. Performs a project open.Project Object Project Object Properties and Methods GbeProject.DBconnect is being used but GbeProject.

workMap GbeProject.exportFile GbeProject. GbeProject.workMap [GBE_True.loginName write-only String property sets or retrieves the login name of the project to be opened. The GbeProject.loginName GbeProject.mapManager GbeProject. The GbePorject.keyMap GbeProject.open GbeProject.mapManager [GBE_True. GBE_False] Descr. The GbeProject.Project Object Descr.mapManager write-only property will set whether or not to load the MAPS table (to make available for attachment) when GeoGraphics is started.directory write-only String property sets or retrieves the directory name of the project to be opened. GbeProject. The GbeProject.workMap write-only property will set whether or not to close the master design file and open a blank GeoGraphics Work map. GBE_False] Descr. The GbeProject. GBE_False] Descr. The GbeProject.exportFile write-only String property sets or retrieves the export filename of the project to be opened.keyMap write-only property will set whether or not to load the Key Map into the Key View window display.open 8-230 MicroStation BASIC Guide . GbeProject. GbeProject.mapManager must be set to GBE_True for this option to take affect. GbeProject. The GbeProject.loginName Descr.exportFile Descr.keyMap [GBE_True. GbeProject.

The GbeProject. GbeProject.loginName = "mytown" GbeProject.close Descr.DBconnect = GBE_True GbeProject.workMap = GBE_True GbeProject.DBload = GBE_False GbeProject. 2503 GBE_InvalidExportFile 2504 GBE_ProjectAlreadyOpen MicroStation BASIC Guide 8-231 8 2502 GBE_InvalidDBLogin MicroStation Extensions to BASIC .exportFile = "c:\projects\mytown\mytown. this error will be returned. this error will be returned. If the export file has not been specified or is an invalid file.close End Sub .open command will attempt to open a project based upon the information setup previously.directory = "c:\projects\mytown\" GbeProject. the user must provide an export file name (absolute path) for table information.Project Object Descr.open Project Error Codes Error Number Error Message Built-in Constant Name GBE_InvalidProjDir 2501 An invalid project directory name has been specified.close command will close the currently open project. An invalid database login name has been specified. A runtime error will be generated if the project cannot be opened. If the user attempts to open a project while one is currently open. Example Sub main Dim status as Integer GbeProject.Perform project functions GbeProject.close GbeProject. If DBLoad property has been set to GBE_False. The GbeProject.exp" GbeProject... Either the path is not valid or the appropriate project files/directories do not exist.

Project Object 8-232 MicroStation BASIC Guide .

use the tables in the following sections to determine the error that corresponds to the error number. the first describing errors messages compatible with “standard” BASIC. The errors are divided into runtime errors (those encountered while the macro is executing). and the second describing error messages specific to MicroStation’s implementation of and extensions to the BASIC language. and compiler errors (those encountered when the macro begins executing). as implemented by Microsoft Visual Basic.9 Error Codes “error. It is divided into two sections. Runtime Error Messages This section contains listings of all the runtime errors.pdf” When you encounter an error in your macro. MicroStation BASIC Guide 9-1 .

Runtime Error Messages Visual Basic Compatible Error Messages Error Number 3 5 6 7 9 11 13 14 19 20 28 35 51 52 53 54 55 57 58 59 61 62 63 64 67 68 70 71 74 75 76 91 93 281 Error Message Return without gosub Illegal function call Overflow Out of memory Subscript out of range Divide by zero Type mismatch Out of string space No Resume Resume without error Out of stack space Sub or Function not defined Internal error Bad file name or number File not found Bad file mode File already open Device I/O error File already exists Bad record length Disk full Input past end of file Bad record number Bad file name Too many files Device unavailable Permission denied Disk not ready Can’t rename with different drive Path/File access error Path not found Object variable not Set Invalid pattern string No more DDE channels (Windows platforms only) Built-in Constant Name MBE_IllegalFunctionCall MBE_Overflow MBE_OutOfMemory MBE_IndexOutOfBounds MBE_TypeMismatch MBE_OutOfStringSpace MBE_SubFuncNotDefined MBE_BadFileNumber MBE_FileNotFound MBE_BadFileMode MBE_DiskFull MBE_BadRecordNumber MBE_TooManyChannels MBE_AccessDenied MBE_FileAccessError MBE_ObjectVariableNotSet MBE_PatternInvalid 9-2 MicroStation BASIC Guide .

dll (Windows platforms only) Built-in Constant Name 283 285 286 287 288 289 290 291 292 295 298 MBE_NoDDEML MicroStation BASIC Guide 9-3 9 Error Codes . DDE message lost (Windows platforms only) DDE requires ddeml.Runtime Error Messages Error Number 282 Error Message No foreign application responded to a DDE initiate (Windows platforms only) Multiple applications responded to a DDE initiate (Windows platforms only) Foreign application won’t perform DDE method or operation (Windows platforms only) Timeout while waiting for DDE response (Windows platforms only) User pressed escape key during DDE operation (Windows platforms only) Destination is busy (Windows platforms only) Data not provided in DDE operation (Windows platforms only) Data in wrong format (Windows platforms only) Foreign application quit (Windows platforms only) DDE conversation closed or changed (Windows platforms only) Message queue filled.

Runtime Error Messages MicroStation Error Messages Error Number 801 806 825 826 827 1100 1101 1102 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1301 1302 1303 1304 1401 1501 1601 1602 Error Message Too many dimensions Invalid DDE Channel Can’t redimension a fixed array Can’t load and initialize extension Can’t find extension Can’t parse string Wrong input type Command received Unable to read element Invalid level Invalid color Invalid weight Invalid line style Invalid element class Wrong element type Unable to rewrite element Font not found Component not found Element off design plane Not enough points Too many points Error in array processing Component of a complex element Writing to design file inhibited No more component elements Not component of a complex element Bad element No selection set No fence Must get set from user No more elements in set String too long Invalid view number Invalid reference file number Defer saving reference file information Built-in Constant Name MBE_WrongDimension MBE_InvalidChannel MBE_RedimFixedArray MBE_CantParseString MBE_WrongInputType MBE_ReceivedCommand MBE_CantReadElemDscr MBE_InvalidLevel MBE_InvalidColor MBE_InvalidWeight MBE_InvalidStyle MBE_InvalidClass MBE_WrongElemType MBE_CantRewrite MBE_FontNotFound MBE_ComponentNotFound MBE_NotOnDesignPlane MBE_NotEnoughPoints MBE_TooManyPoints MBE_ArrayError MBE_ComplexComponent MBE_WriteInhibit MBE_NoMoreElems MBE_NotComplex MBE_BadElement MBE_NoSelectionSet MBE_NoFence MBE_MustGetFromUser MBE_NoMoreInSet MBE_StringTooLong MBE_InvalidView MBE_InvalidRefFile MBE_RefSaveDeferred 9-4 MicroStation BASIC Guide .

With some errors. Error Number 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Error Message Letter range must be in ascending order Redefinition of default type Out of memory. These placeholders are represented in this table by two single quotes (' ').' must be an object or structure Invalid string operator Can’t apply operator to array type Operator type mismatch ' ' is not a variable ' ' is not a array variable or a function Unknown ' ' ' ' MicroStation BASIC Guide 9-5 9 Error Codes . too many variables defined Type character doesn’t match defined type Expression too complex Cannot assign whole array Assignment variable and expression are different types Identifier is not an array variable Array type mismatch in parameter Array type expected for parameter Array type unexpected for parameter Integer expression expected for an array index Integer expression expected String expression expected Long expression expected Invalid dialog element Left of '.Compiler Error Messages Error Number 1701 1702 1703 1801 Error Message Data type not supported Variable not found Variable wrong type Graphics subsystem not initialized Built-in Constant Name MBE_UnsupportedDataType MBE_VariableNotFound MBE_VariableWrongType MBE_NoGraphics Compiler Error Messages The following table contains a list of all the errors generated by the built-in BASIC compiler. the compiler changes placeholders within the error to text from the script being compiled.

.Compiler Error Messages Error Number 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 Error Message Out of memory ' ': Too many parameters encountered ' ': Missing parameter(s) ' ': Type mismatch in parameter ' ' Missing label ' ' Too many nested statements Encountered newline in string Overflow in decimal value Overflow in hex value Overflow in octal value Expression is not constant Function name not explicitly typed or missing type character No type characters allowed on parameters with explicit type Missing type for variable Can’t pass an array by value ' ' is already declared as a parameter Variable name used as label name Duplicate label Not inside a function Not inside a sub Long expression expected Can’t assign to function Identifier is already a variable Unknown type Variable is not an array type Can’t redimension an array to a different type Identifier is not an string array variable 0 expected Parameter 1: string expected Parameter 2: string expected Integer expression expected for file number Unsubscripted array in expression String variable expected for parameter 1 Expecting 0 or 1 Boolean expression expected. Numeric expression expected Numeric type FOR variable expected For.Next variable mismatch 9-6 MicroStation BASIC Guide ..

' Access value can’t be used with specified mode MicroStation BASIC Guide 9-7 9 Error Codes .' must be an object or structure Operator result on variant type is ambiguous Operator cannot be used on an object ' ' is not a property or method of the object Type character on label Type character mismatch on routine ' ' Destination name is already a constant Can’t assign to constant Error in format of compiler extensions Identifier too long Expecting string or structure expression Can’t assign to expression Object types are not supported in this context Array expression not supported as parameter Objects and structures expressions are not supported as a parameter Invalid numeric operator Invalid structure element name following '.Compiler Error Messages Error Number 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 Error Message Out of string storage space Out of identifier storage space Internal error 1 Maximum line length exceeded Internal error 3 Division by zero Overflow in expression Floating point expression expected Floating point expression expected Invalid floating point operator Math error Single character expected Subroutine identifier can’t have a type declaration character Script is too large to be compiled Variable type expected Types and dialog variables can’t be passed by value Can’t assign to user type variable Maximum string length exceeded Identifier name already in use as another type Left of '.

Run-time error codes Error Number 99 100 101 102 103 104 105 106 107 108 Error Message Use the SET statement to assign objects Invalid operator for object Can’t LSet a type with a variable length string Syntax Error ' ' is not a method of the object No members defined Duplicate type member Set is for object assignments Type character mismatch on variable Identifier already defined as a different type Run-time error codes The following tables shows the defined run-time error codes: Error Number 1901 1902 1903 1904 1905 1906 Error Message Invalid block name Invalid cell name Cannot open table file Invalid font filename Invalid font number Invalid settings value Topology Error Codes The following tables shows the topology error codes: Error Number Error Message Built-in Constant Name GBE_TopologyInitFail GBE_NoLayerName GBE_NoFenceDefined 2520 2521 2522 Error when trying to initialize the topology layer. 9-8 MicroStation BASIC Guide . The topology layer name has not been defined. No fence has been placed previous to performing topology load.

Attempt to produce an overlay layer in a previously populated topology layer. Error when trying to generate an overlay. 2525 2526 GBE_ErrorGeneratingOverlay GBE_SqlNotSpecified Category Error Codes The following tables shows the category error codes: Error Number Error Message Built-in Constant Name GBE_InvalidCategoryIndex 2530 An invalid category index has been entered. The index specifying the feature object has exceeded the maximum number of feature indexes. The index specifying the category object has exceeded the maximum number of category indexes. The topology SQL statement has not been set. Feature Error Codes Error Number Error Message Built-in Constant Name GBE_InvalidFeatureIndex 2540 An invalid feature index has been entered.Category Error Codes Error Number Error Message Built-in Constant Name GBE_EmptyTopology GBE_LayerAlreadyPopulated 2523 2524 Empty topology will not be created. MicroStation BASIC Guide 9-9 9 Error Codes The following tables shows the feature error codes: .

this error will be returned. 2502 2503 GBE_InvalidDBLogin GBE_InvalidExportFile 2504 GBE_ProjectAlreadyOpen 9-10 MicroStation BASIC Guide . The index specifying the map object has exceeded the maximum number of map indexes. Either the path is not valid or the appropriate project files/directories do not exist. this error will be returned. If DBLoad property has been set to GBE_False. If the export file has not been specified or is an invalid file. If the user attempts to open a project while one is currently open. An invalid database login name has been specified. the user must provide an export file name (absolute path) for table information. Project Error Codes The following tables shows the project error codes: Error Number Error Message Built-in Constant Name GBE_InvalidProjDir 2501 An invalid project directory name has been specified.Map Error Codes Map Error Codes The following tables shows the map error codes: Error Number Error Message Built-in Constant Name GBE_InvalidMapIndex 2510 An invalid map index has been entered.

Since Visual Basic Version 3.Appendix A: OLE Automation OLE Automation is just one of many Windows OLE2 standards developed to help users make programs work together. Programs that implement the protocol to access that functionality via the exposed interface are referred to as OLE Automation Controllers. With very few exceptions. you must run either Windows 95 or Windows NT. Programs that expose their functionality are referred to as OLE Automation Servers. first familiarize yourself with the objects and techniques used in MicroStation BASIC. Visual Basic Version 4. but you can apply the same concepts to the OLE Automation Controller of your choice. just as MicroStation BASIC exposes its programming interface through the object model. Thus it should come as no surprise that MicroStation exposes the same set of objects through OLE Automation that are available through MicroStation BASIC. Furthermore. those concepts carry over directly to using OLE Automation. MicroStation BASIC Guide A-1 . The intent of this section is to provide the information you need to program MicroStation using OLE Automation once you are familiar with MicroStation BASIC. Examples of OLE Automation Controllers include Microsoft Visual Basic and various implementations of Visual Basic for Applications embedded in applications such as Microsoft Excel. Since MicroStation is an OLE Automation Server. To program MicroStation using OLE Automation. since multithreading support is required.0 is required. an OLE Automation Controller capable of passing arguments by reference is required. ✍ In order to use MicroStation’s OLE Automation features. it is possible to use a number of these OLE Automation controllers to program MicroStation. since many of MicroStation’s OLE Automation methods use read/write arguments. The intent of OLE Automation is to define and standardize a way for applications to expose their functionality to the outside world.0. The examples shown here are appropriate to Microsoft Visual Basic Version 4.0 does not provide this capability. OLE Automation Servers expose their functionality through objects that encapsulate related properties or methods of an application.

. The Application object provides access to top-level functionality of the application—that is. so all such functions and statements are instead methods of the Application object. expConfigVar = msApp. the syntax for retrieving a configuration variable expansion is: Sub Main Dim expConfigVar As String . functionality that is not related to a specific object within the application. To convert a program from MicroStation BASIC to Visual Basic. expConfigVar = MbeGetConfigVar("MS_DEF") ..MbeGetConfigVar("MS_DEF") . Such functionality in MicroStation BASIC is provided through “standalone” extension functions..Application") . whereas in MicroStation BASIC. End Sub The line creating the msApp object must be executed only once in the program.. Thus.. For example. find all the standalone extension functions and make them methods of the MicroStation Application Object.Differences Between MicroStation BASIC and OLE Automation Differences Between MicroStation BASIC and OLE Automation The Application object OLE Automation Servers must supply an “Application” object. A-2 MicroStation BASIC Guide . an extension function called MbeGetConfigVar returns the expansion of a MicroStation configuration variable. In MicroStation’s OLE Automation implementation... End Sub In Visual Basic the syntax is: ’ Note: The Application object declaration is usually in ‘ the public declarations section ’ so it can be used anywhere in the program Dim msApp As Object Sub Main Dim expConfigVar As String Set msApp = CreateObject("MicroStation.. standalone extension functions are not allowed.

so the test erroneously tests to see if element.. Dim statements In MicroStation BASIC. For example. make sure to check the code carefully to ensure that this change is made. Any other error made in converting the code from MicroStation BASIC to Visual Basic is caught as either a compile time or runtime error.type is zero.. At the time the code is compiled.MBE_Line Then . In contrast.. OLE Automation supports only late binding—an actual object is associated with a variable only at runtime. clearly not the desired result. End If while the following code is appropriate for Visual Basic: If element. Visual Basic assumes MBE_Line is an undeclared variable and initializes it to zero. etc. To test whether an element object is a line. the methods and properties of the MicroStation BASIC Guide A-3 Appendix A: OLE Automation .. so MicroStation uses the same approach as for standalone functions—all defined constants are implemented as read-only properties of the Application object. The MicroStation BASIC compiler.type = MBE_Line Then . Constants cannot be defined in the same manner by an OLE Automation Controller.type = msApp. and that it has the correct number and type of arguments. element type numbers are defined so that a Basic programmer doesn’t need to know that element type 3 is a line— he uses the MBE_Line constant instead. End If When converting a MicroStation BASIC program to run with Visual Basic. and can be used directly in a Dim statement. which is executed transparently whenever the code is modified. This compile-time checking is a form of what is called “early binding”.Differences Between MicroStation BASIC and OLE Automation MicroStation-defined constants MicroStation BASIC defines a number of constants that are available for use by any MicroStation BASIC program. If the defined constant change is not made and the code is left in MicroStation BASIC form. is responsible for checking to ensure the validity of the method or property name. the following code is appropriate for MicroStation BASIC: If element. MicroStation objects and their methods are known to the compiler.

Since the compiler doesn’t know what applications and objects are going to be in use at runtime. in MicroStation BASIC you use the following code to specify that the variable “element” represents an MbeElement object and reads the first element in a design file: Dim element As New MbeElement Dim filePos As Long filePos = element. Unfortunately. so anything is accepted. the MicroStation BASIC MbePoint UDT consists of three Double fields. For example. MicroStation implements objects having read/write properties with the same names as the field names in our pre-defined UDTs. While in Visual Basic you use the following: Dim element As Object Dim filePos As Long Set element = msApp. the field/ A-4 MicroStation BASIC Guide . there are a number of pre-defined UDTs that are used as arguments to some of the object methods. MicroStation’s Application object implements a read-only property that returns an object of the correct type for each MicroStation BASIC object type.fromFile(0) .Differences Between MicroStation BASIC and OLE Automation object are not known. MicroStation defines an object having Double read/write properties x.mbeElement filePos = element. The syntax for using an object property and a UDT field are identical in Basic—in either case. z) and is used to send points to and retrieve points from some object methods. (x.fromFile(0) MicroStation-defined “User-Defined Types” Both MicroStation BASIC and Visual Basic Version 4. and z. all objects are declared simply as “Object. y. Thus.) In MicroStation BASIC. The checks to determine if the method/property is valid and whether the arguments are correct occur at runtime. which allow a programmer to group related variables using the Type statement. (If you’re familiar with C programming. OLE Automation does not allow use of UDTs as arguments to methods or functions.. To overcome this limitation..” and the association between the declared object and an actual object happens at runtime by assigning the object variable to the return value of a function or property that returns an object. y. For OLE Automation.0 support a concept called “User-Defined Types” (UDTs). you will recognize that UDTs and C structures are essentially the same thing.

.getOrigin(origin) = msApp.MBE_Success Then distFromOrigin = Sqr(origin. Thus.. Every object method that takes a pre-defined UDT as an argument in MicroStation BASIC is implemented in OLE Automation as taking the argument as an Object instead.x * origin. “. If origin As Object element As Object element = msApp.y + origin.”. In MicroStation BASIC you use the following code: Dim Dim .x * origin.z) End If The UDT form is slightly more efficient..y + origin.y * origin. suppose you want to get the origin of an element.mbeElement origin = msApp.z) End If ✍ In MicroStation 95.getOrigin(origin) = MBE_Success Then distFromOrigin = Sqr(origin..z * origin.x + origin.z * origin. in MicroStation BASIC you have the choice of representing a point as either MbePoint or MbePointObj. MicroStation BASIC Guide A-5 Appendix A: OLE Automation ..x + origin. you use the following code instead: Dim Dim Set Set . If origin As MbePoint element As New MbeElement (get the element from the file) element.. MicroStation BASIC supports using objects in place of the predefined UDTs.mbePoint (get the element from the file) element. and is compatible with both MicroStation 95 and MicroStation PowerDraft. a point object is obtained in a manner similar to that of obtaining an MbeElement object (that is. In Visual Basic.y * origin. Objects with the same properties as the equivalent UDTs are named by adding the suffix Obj.z * origin.getOrigin(origin) = MBE_Success Then distFromOrigin = Sqr(origin.x + origin.Differences Between MicroStation BASIC and OLE Automation property names are separated from the UDT/object by the period character. so it is generally preferred. as a read-only property of the MicroStation Application object).x * origin. The MicroStation BASIC code for using the object form of point is: Dim origin as New MbePointObj Dim element as New MbeElement .z) End If With Visual Basic. (get the element from the file) If element. Putting this together in an example.y * origin.y + origin.

Use the tools provided by the native programming environment instead. y and z arguments is not supported. • The form of MbeSendTentPoint that takes separate x.MbeSetAppVariable as you would expect. use msApp.” A-6 MicroStation BASIC Guide . MbeMessageBox. consisting mostly of making the conversions listed above. MicroStation Application methods • The form of MbeSendDataPoint that takes separate x.MicroStation Application methods Special considerations Converting a program from MicroStation BASIC to a Visual Basic program is generally fairly easy. a few functions and object methods available in MicroStation BASIC that cannot be implemented in OLE Automation or require special consideration for OLE Automation. The form that takes a MbePoint object as the first argument is supported. y and z arguments is not supported. use msApp.MbeSetAppVariableReal. use MbeElement.MbeSetAppVariableInteger. There are. MbeOpenModalDialog. y and z arguments is not supported. MbeInputBox. use msApp. To use the form that takes a long as the third argument. • None of the dialog box methods are available under OLE Automation (MbeFileOpen. • MbeSetAppVariable works a little differently under OLE Automation: To use the form that takes a string argument. The form that takes a MbePoint object as the first argument is supported. so to scale an element. MbeElement methods Visual Basic reserves the “scale” method name. • The form of MbeSendDragPoints that takes separate x.scaleElem rather than “MbeElement. To use the form that takes a double as the third argument.scale. MbeMessageBox. MbeFileCreate. The form that takes two MbePoint objects as the first two argument is supported. MbeSelectBox). however.

• Name—returns the name of the MicroStation executable without the path—for example. since it returns itself. • Width—returns or sets the width of MicroStation application window (read/write property). but it is standard for all objects to implement a read-only property that returns the application object. including the following: • Application—returns the MicroStation Application object. so to scale the current transformation.scale. ustation.exe (read-only property). • FullName—returns the full path to the MicroStation executable—for example. c:\win32app\ustation\ustation.scaleTrans rather than “MbeElement. • Left—returns or sets the location of the left side of the MicroStation application window (read/write property). In addition. • ActiveDocument—returns the Document object for the current design file (read-only property). This is not very useful for the Application object. all the standalone extension functions of MicroStation BASIC are implemented as methods of the MicroStation Application object. This is not very useful for the Application object. use MbeCurrentTransform.” OLE Automation-specific methods and objects This section describes a number of extensions that are available through OLE Automation but not applicable to MicroStation BASIC. • Height—returns or sets the height of MicroStation application window (read/write property). • Top—returns or sets the location of the top of the MicroStation application window (read/write property). since the Application object’s MicroStation BASIC Guide A-7 Appendix A: OLE Automation . there are a number of properties and methods standard for Application objects. • Caption—returns or sets the caption for the MicroStation application window (read/write property).exe (read-only property). MicroStation Application object As mentioned above. • Parent—returns the Parent object of the object.MicroStation Application methods MbeCurrentTransform methods Visual Basic reserves the “scale” method name.

Other MicroStation objects The other MicroStation objects support “Application” and “Parent” properties. c:\win32app\ustation (read-only property). Return TRUE always if in “continuous save” mode (read-only property).dgn (read-only property). • Parent—returns the parent object. • Save—Saves the active design file (method). • FullName—returns the full path to the active design file—for example. It is used to access information about the current design file with OLE Automation-standard properties and methods. but it is standard for all objects to implement a read-only property that returns the Parent object. The “Application” read-only property returns the MicroStation Application object. • Visible—returns or sets whether the MicroStation application window is visible (read/write property). • Path—returns the path where the MicroStation executable resides—for example. c:\dgn\myfile. • Saved—returns whether the active design file has been saved to disk or not. in the case of MicroStation objects. (read-only property). Document object The Document object is obtained from the ActiveDocument property of the Application object. • Readonly—returns whether the active design file is opened for read-only access (read-only property). A-8 MicroStation BASIC Guide . • Name—returns the name of the active design file without the path—for example. c:\dgn.dgn (read-only property). myfile. The “Parent” read-only property returns the parent of the object to which it is applied. this is always the MicroStation Application object. • Path—returns the path where the active design file is located— for example. which is always MicroStation's application object (read-only property). • Close—Closes the active design file.Parent is always itself. • Quit—uses MicroStation to exit (method). It includes the following properties and methods: • Application—returns the application object (read-only property).

MicroStation BASIC Guide A-9 Appendix A: OLE Automation .0 project file “autodemo.vbp” shows an example of how the elemshow. scaletxt.MicroStation Application methods Examples The Visual Basic Version 4. currtrans. cellmod. and locate examples are converted to Visual Basic.

MicroStation Application methods A-10 MicroStation BASIC Guide .

Constants MBE_Success MBE_MaxViews MBE_On MBE_Off MBE_None MBE_Linestyle MBE_Color MBE_Width Value 0 8 1 0 0 1 2 1 Element Types MBE_CellLibraryHdr MBE_CellHeader MBE_Line MBE_LineString MBE_Shape MBE_TextNode MBE_Curve Value 1 2 3 4 6 7 11 MicroStation BASIC Guide B-1 .Appendix B: MicroStation BASIC Constants MbeGetInput Types MBE_CommandInput MBE_DataPointInput MBE_ResetInput MBE_KeyinInput Value 1 2 3 4 Misc.

MicroStation BASIC Constants Element Types MBE_ComplexString MBE_Conic MBE_ComplexShape MBE_Ellipse MBE_Arc MBE_Text MBE_Surface MBE_Solid MBE_BSplinePole MBE_PointString MBE_Cone MBE_BSplineSurface MBE_BSplineBoundary MBE_BSplineKnot MBE_MSplineCurve MBE_BSplineWeight MBE_Dimension MBE_SharedCellDefinition MBE_SharedCell MBE_MultiLine MBE_Tag MBE_RasterHeader MBE_RasterComponent Value 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 33 34 35 36 37 87 88 Draw Modes MBE_NormalDraw MBE_Erase MBE_Hilite Value 0 1 2 B-2 MicroStation BASIC Guide .

MicroStation BASIC Constants Element Classes MBE_PrimaryClass MBE_PatternClass MBE_ConstructionClass MBE_DimensionClass MBE_PrimaryRuleClass MBE_PatternedLineClass MBE_ConstRuleClass Value 0 1 2 3 5 6 Element Properties MBE_LockedProp MBE_NewProp MBE_ModifiedProp MBE_AttributesProp MBE_ViewIndProp MBE_PlanarProp MBE_NoSnapProp MBE_HoleProp Value 1 2 4 8 16 32 64 128 Text Justification MBE_LeftTop MBE_LeftCenter MBE_LeftBottom MBE_LeftMarginTop MBE_LeftMarginCenter MBE_LeftMarginBottom Value 0 1 2 3 4 5 MicroStation BASIC Guide B-3 MicroStation BASIC Constants 4 B .

MicroStation BASIC Constants Text Justification MBE_CenterTop MBE_CenterCenter MBE_CenterBottom MBE_RightMarginTop MBE_RightMarginCenter MBE_RightMarginBottom MBE_RightTop MBE_RightCenter MBE_RightBottom Value 6 7 8 9 10 11 12 13 14 Pen Table Constants MBE_ElemNormal MBE_ElemIgnore MBE_ElemPrioritize Value 0 1 2 Message Box Ids MBE_OKBox MBE_OKCancelBox MBE_YesNoBox MBE_YesNoCancelBox Value 1 3 12 14 Message Box Icon Ids MBE_CriticalIcon MBE_QuestionIcon MBE_InfoIcon MBE_WarningIcon Value 256 512 1024 2048 B-4 MicroStation BASIC Guide .

MicroStation BASIC Constants Button Values MBE_BUTTON_APPLY MBE_BUTTON_OK MBE_BUTTON_CANCEL MBE_BUTTON_DEFAULT MBE_BUTTON_YES MBE_BUTTON_NO MBE_BUTTON_RETRY MBE_BUTTON_STOP Value 1 3 4 5 7 8 9 Product Codes MBE_MicroStation MBE_MSReview MBE_MSPowerDraft Value 10 30 50 Database Constants MBE_QueryNotFinished MBE_QueryFinished MBE_DBChar MBE_DBNumber MBE_DBDate MBE_DBInteger MBE_DBRaw MBE_DBBinary Value 0 1 1 2 3 4 5 6 MicroStation BASIC Guide B-5 MicroStation BASIC Constants 6 B .

MicroStation BASIC Constants Input Result Codes MBE_Success MBE_ElementNotFound MBE_AcceptQuery MBE_UnknownCommand MBE_3DOnly MBE_RefFileNotFound MBE_ViewNotFound MBE_IllegalDefinition MBE_SelectView MBE_OffDesignPlane MBE_NeedChars MBE_CellLibNotFound MBE_NoCellLibrary MBE_NoOrigin MBE_NoFenceActive MBE_EmptyFence MBE_BadCellName MBE_CellExists MBE_CellNotFound MBE_NoActiveCell MBE_3DLib2DFile MBE_CellDeleted MBE_CellNestError MBE_FileReadOnly MBE_InvalidRefOp Value 0 21 68 16 39 7 18 23 196 22 27 12 54 56 57 27 47 55 44 19 50 59 43 287 481 B-6 MicroStation BASIC Guide .

MicroStation BASIC Constants Database Link Constants MBE_ORACLE_Linkage MBE_INFORMIX_Linkage MBE_RIS_Linkage MBE_DMRS_Linkage MBE_ODBC_Linkage MBE_XBASE_Linkage MBE_DBASE_Linkage MBE_SYBASE_Linkage MBE_INGRES_Linkage Value 8 1 16 2 4 4 64 32 Topology Layer Type GBE_TypePolygon GBE_TypeLine GBE_TypePoint GBE_TypeMixed Mask Value 1 2 3 4 Centroid Node Type GBE_Point GBE_TextNode Mask Value 1 2 MicroStation BASIC Guide B-7 MicroStation BASIC Constants 128 B .

MicroStation BASIC Constants Selection Criteria GBE_Inside GBE_Outside GBE_Overlap Mask Value 4 8 16 operator GBE_ADD GBE_OR GBE_XOR GBE_DIFF Mask Value 1 2 3 4 B-8 MicroStation BASIC Guide .

7-2. 7-17 _ Operator 7-2. 7-19 arrays 3-5 boundaries 3-5 fixed-length 3-6 multi-dimensional arrays 3-5 variable-length 3-7 ArraySort 7-3. 2-4 language 1-1 objects see BASIC Objects BASIC Constructs selection sets 4-9 BASIC extensions see extensions MicroStation-specific BASIC Function Groups Array Handling 7-1 Business Calculations 7-1 Character Manipulation 7-1 Constants & Special Keywords 7-1 Date commands 7-1 Dynamic Data Exchange 7-1 File Handling 7-1 Math commands 7-1 Miscellaneous commands 7-1 MicroStation BASIC Guide i-1 . 7-1. 7-2. 7-11 * Operator 3-12. 3-13. 7-2. 7-18 Access Strings 5-8 Adding 1-8 Advanced Macro Programming 1-3 Alignment Editor 5-18 And 3-14. 7-13 <= Operator 3-13. 7-1. 7-2. 7-20 assignment operator see Expressions assignment operator associationLock 4-13 Atn 7-2. 7-15 > Operator 3-13. 7-20 As 3-26 Asc 7-6.Operator 3-12. 7-12 arithmetic operators ArrayDims 7-3. 7-1. 7-13 & Operator 7-1.BA extension 5-3 . 7-12 . 7-2. 7-19 angle 4-13 angleLock 4-13 application software 6-1 arcs and ellipses primaryAxis 4-5 secondaryAxis 4-5 startAngle 4-5 sweepAngle 4-5 areaMode 4-13 arguments see parameters arithmetic operators see Expressions B Baker’s Rounding Rules 3-12 BASIC constructs see BASIC Constructs extensions 1-3. 7-12 + Operator 3-12. 7-2.Index . 7-2. 7-13 < Operator 3-13. 7-2. 7-14 <> Operator 3-13.BAS extension 2-6 / Operator 3-12. 7-15 >= Operator 3-13. 7-16 \ Operator 3-12. 7-17 ’ Operator 3-1. 7-2. 7-2. 7-21 axisAngle 4-13 axisLock 4-13 axisOrigin 4-13 A Abs 7-2. 7-1. 7-14 = Operator 3-11. 7-16 ^ Operator 3-12.

PathSeparator$ 7-4.Capability% 7-21 Basic. 7-22 Basic. 7-22 Basic. 7-24 block to cell cross reference 4-28 Boolean Operators 3-13 boresiteLock 4-13 Browse 1-5 button 1-5 built-in functions 6-1 ByVal 3-26 MbeCExpressionString 8-120 C Programming Language 6-2 CAD engine 6-2 CAD Input Operations 8-123 MbeAngleFromString 8-123 MbeFindFile 8-124 MbeGetConfigVar 8-124 MbeGetInput 8-123 MbeLocateElement 8-123 MbePoint 8-123 MbePointFromString 8-123 MbeRelocate 8-123 MbeScalarFromString 8-123 MbeSendAppMessage 8-123 MbeSendCommand 8-123 MbeSendDataPoint 8-123 MbeSendDragPoints 8-123 MbeSendKeyin 8-123 MbeSendReset 8-123 MbeSendTentPoint 8-123 MbeSetAppVariable 8-123 MbeSetScaledAppVar 8-123 MbeStartDefaultCommand 8-124 MbeStartLocate 8-123 MbeStringFromAngle 8-124 MbeStringFromPoint 8-124 MbeStringFromScalar 8-123 MbeWriteCommand 8-123 MbeWriteError 8-123 MbeWriteMessage 8-123 MbeWritePrompt 8-123 MbeWriteStatus 8-123 Call 7-4.OS 7-4.Index: C Numerical Operators Array commands 7-1 Numerical OperatorsArray commands 7-1 Operators 7-1 Program Control 7-1 String Manipulation 7-1 System commands 7-1 Time commands 7-1 Variable Control 7-1 BASIC Objects accessing object methods in 3-36 accessing object properties in 3-36 constant 3-37 creating an object instance in 3-35 declaring variables in 3-32 methods in 3-33 properties in 3-34 variable operations in 3-34 BASIC Programming Extensions 3-1.Case CDbl 7-2.Capability 7-4 Basic.FreeMemo 7-4 Basic.Eoln$ 7-4.. 4-1 MicroStation PowerDraft conventions 4-1 sequencing commands 4-1 BASIC see Macro Language Basic. 7-24 Call Statement 3-27 calling functions 3-30 calling subroutines 3-27 capMode 4-13 Case 7-5 case statement see Select.. 7-24 cell 4-13 cell to block cross reference 4-28 cellStretchLock 4-13 Change Variable Value dialog box 2-13 C C Expression Statements 8-120 MbeCExpressionDouble 8-120 MbeCExpressionLong 8-120 i-2 MicroStation BASIC Guide .FreeMemory 7-22 Basic.HomeDir$ 7-22 Basic. 7-23 Beep 7-4.

7-37 DDERequest 7-10.. 7-36.Next 3-22 GoSub 3-24 Goto 3-24 If. 7-36 DDEPoke 7-10.. 7-38. 7-29 Current Transformation Object 8-93 MbeCurrentTransform. 7-34 Day 7-9. 4-13 colorName 4-13 Column Number Field 2-8 Command$ 1-4. 7-27 Comment 3-1 complex graphics elements 4-3. 7-39 DDETerminateAll 7-10.Else 3-16 Return 3-24 Select. 7-39.Case 3-18 While.masterUnits 8-93 MbeCurrentTransform.Loop 3-19 For.. 7-38 DDETerminate 7-10.. 7-27 color 4-8.. 7-35. 7-34 DDB 7-9.Wend 3-22 contructionPlaneLock 4-13 Coordinate System distanceFromUors 4-3 distanceToUors 4-3 fromView 4-2 masterUnits 4-2 MbeCurrentTransform 4-2 moveOrigin 4-3 moveOriginWorld 4-3 rotate 4-3 scalarFromUors 4-3 scalarToUors 4-3 scale 4-3 Cos 7-3. 7-5.. 7-33 DateSerial 7-8.scalarFromUors 8-93 MbeCurrentTransform.. 7-26 Close 7-7. 7-31 DatePart 7-8. 7-40 DDEExecute 7-10. 7-38 DDESend 7-10. 7-28 CStr 7-6. 7-34 DateValue 7-9. 7-25 class 4-8.pointFromUors 8-93 MbeCurrentTransform.fromView 8-93 MbeCurrentTransform. 7-28 Create Macro dialog box 2-1 description of 2-1 CSng 7-3.. 4-5 concept 4-5 firstElement 4-6 nextComponent 4-6 nextElement 4-6 ProcessElement 4-8 complex variables see UDT variables Const 7-5.pointToUors 8-93 MbeCurrentTransform.moveOrigin 8-93 MbeCurrentTransform.moveOriginWorld 893 MbeCurrentTransform. 7-37.. 7-29 DateAdd 7-8. 7-30 DateDiff 7-8.Then. 7-28 controlling execution 3-16 Do.Index: D changeAll 4-8 Chr$ 7-6.. 7-39 DDETimeOut 7-40 MicroStation BASIC Guide i-3 .rotate 8-93 MbeCurrentTransform. 7-36 DDEInitiate 7-10. 4-13 clear 4-9 CLng 7-3. 7-25 CInt 7-3.scale 8-93 currentGraphicGroup 4-13 customizing MicroStation 6-1 D database 4-15 MbeDatabase 4-17 MbeDatabaseLink 4-17 MbeSqlda 4-15 MbeTable 4-16 Date$ 7-8.scalarToUors 8-93 MbeCurrentTransform...dgnUnits 8-93 MbeCurrentTransform.

7-48 ebReadOnly 7-7.dgnFileName 8-87 MbeDgnInfo..Loop 7-4.getGlobalOrigin 8-87 MbeDgnInfo. 7-47 ebDirectory 7-7.dgnFileReadOnly 8-87 MbeDgnInfo. 7-49 ebSystem 7-7. 7-40 Declare statement 3-32 declaring variables 3-3 arrays 3-5 double 3-5 integers 3-4 long 3-4 single 3-5 string 3-4 user-defined types 3-8 DEF… 7-5. 7-42 Dir$ 7-7. 8-145 MbeInputBox 8-145 MbeMessageBox 8-145 MbeOpenModalDialog 8-145 MbeSelectBox 8-145 Dialog Boxes Change Variable Value dialog box 2-13 Create Macro dialog box 1-6. 7-41 depthLock 4-13 Design File Information Objects 8-87 MbeDgnInfo. 7-48 ebNormal 7-7. 7-49 ebVolume 7-7. 5-19 editing 5-8 hooks 5-8 Dialog Box Statements 8-145 MbeFileCreate 5-1.masterUnitName 8-87 MbeDgnInfo.dgn3D 8-87 MbeDgnInfo.. 7-5.cell3D 8-87 MbeDgnInfo.subPerMaster 8-87 MbeDgnInfo. 7-49 Edit Menu 5-6 i-4 MicroStation BASIC Guide . 7-45 Doubles see Macro Data Types DWG export settings 4-26 DWG import settings 4-26 E ebArchive 7-7.cellFileReadOnly 8-87 MbeDgnInfo.Index: E DDETimout 7-10 Declare 7-4.graphicGroup 8-87 MbeDgnInfo. 2-1 Customize dialog box 1-6 Macros settings box 1-5 Select Macro dialog box 1-5 Start Macro dialog box 1-5 Dialogs custom 1-3 standard 1-3 utility 1-3 Dim 3-4. 7-47 ebNone 7-7.cellFileName 8-87 MbeDgnInfo.nextGraphicGroup 8-87 MbeDgnInfo. 8-145 MbeFileOpen 5-1.subUnitName 8-87 MbeDgnInfo.endOfFile 8-87 MbeDgnInfo.uorPerSub 8-87 Dialog Box attributes 5-8 builder 5-3 color picker 5-14 control see Dialog Box Control custom 5-2 group box editor 5-17 item editor 5-10 item see Dialog Box Control label editor 5-11 level map editor 5-15 option button editor 5-12 push button editor 5-13 radio button editor 5-17 save before editing 5-20 scale editor 5-15 standard 5-1 text editor 5-11 toggle button editor 5-12 Dialog Box Control 5-9. 7-44 distanceFromUors 4-3 distanceToUors 4-3 Do 7-4 Do. 7-47 ebHidden 7-7.

getTopOrigin 8-16 MbeElement.getRange 8-16 MbeElement.scale 8-17 MbeElement.fromFile 8-15 MbeElement.getNext 8-62 Else 7-5 End 7-5.font 8-15 MbeElement.getOrigin 8-16 MbeElement.lineSpacing 8-16 MbeElement.level 8-16 MbeElement.weight 8-17 Element Set Objects 8-62 MbeElementSet.charHeight 8-15 MbeElement.headerElement 8-16 MbeElement.fileNum 8-15 MbeElement.isComponent 8-16 MbeElement.getEndPoints 8-16 MbeElement.volume 8-17 MbeElement.isGraphics 8-16 MbeElement.changeAll 8-15 MbeElement.fromLocate 8-15 MbeElement.getPoints 8-16 MbeElement.cellName 8-15 MbeElement. 7-53 Err (statement) 7-4. 7-50 Eqv 3-14.getRotation 8-16 MbeElement. 7-54 Error 7-54 Error (statement) 7-4 Error handling 3-38 Error Messages 9-1 Compiler 9-5 MicroStation 9-4 Runtime 9-1 Visual Basic 9-2 Error$ 7-55 MicroStation BASIC Guide i-5 .fromFence 8-62 MbeElementSet.nextElement 8-16 MbeElement.getFirst 8-62 MbeElementSet.firstElement 8-15 MbeElement.setString 8-17 MbeElement.justification 8-16 MbeElement.getString 8-16 MbeElement.color 8-15 MbeElement.fileSize 8-15 MbeElement. 7-52 Erl 7-4.filePos 8-15 MbeElement.area 8-15 MbeElement.getCellBox 8-16 MbeElement. 7-50 Environ$ 7-5.getCentroid 8-16 MbeElement.type 8-17 MbeElement. 7-51 Erase 7-3. 7-50 Eof 7-7.bottomRadius 8-17 MbeElement.setPoints 8-17 MbeElement.startAngle 8-17 MbeElement.fromSelection 8-62 MbeElementSet.componentFilePos 8-15 MbeElement.topRadius 8-17 MbeElement.rotate 8-17 MbeElement.sweepAngle 8-17 MbeElement.secondaryAxis 8-17 MbeElement.display 8-15 MbeElement.Index: E Editing macros see Macro editor editing macros see Macro editor efficient program structure 3-25 function procedures 3-25 recursion 3-25 subroutine procedures 3-25 Element Objects 8-15 MbeElement.properties 8-17 MbeElement.isHeader 8-16 MbeElement.fontName 8-15 MbeElement.primaryAxis 8-17 MbeElement.perimeter 8-17 MbeElement.style 8-17 MbeElement.move 8-16 MbeElement.getCellLevels 8-16 MbeElement.charWidth 8-15 MbeElement.nextComponent 8-16 MbeElement.thisComponent 8-17 MbeElement.publish 8-17 MbeElement.clear 8-62 MbeElementSet.group 8-16 MbeElement. 7-2.class 8-15 MbeElement.rewrite 8-17 MbeElement.internalSize 8-16 MbeElement. 7-53 Err (function) 7-4.addToFile 8-15 MbeElement.

7-58 fenceClip 4-13 fenceOverlap 4-13 Fences see Selection Sets fenceVoid 4-13 FileAttr 7-7. 7-59 FileDateTime 7-7. 7-62 FileParse$ 7-7.name 8-219 GbeFeature. 7-57 Exp 7-3. 7-57 Exit Sub 7-5.End Function 7-5.style 8-223 F False 7-2.categoryMslink 8-222 GbeFeature. 7-73 fromFence 4-9 fromFile 4-4 fromLocate 4-4 fromSelectionSet 4-9 fromView 4-2 function procedures 3-25 Function. 7-56 Exit Function 7-5. 7-64 fillColor 4-13 fillMode 4-13 firstElement 4-6 Fix 7-3..listFeaturesByMslink 8-219 GbeCategory. 7-58 FileCopy 7-7.detachMaps 8-218 GbeCategory.listMapsByMslink 8-219 GbeCategory.display 8-223 GbeFeature.listByMslink 8-217 GbeCategories. 7-66 FreeFile 7-8.level 8-223 GbeFeature. 7-61 FileExists 7-7.indexFromMslink 8-218 GbeCategories. 7-73 Fv 7-9. 7-75 G GbeCategories(index) 8-218 GbeCategories.cellLibrary 8-218 GbeCategory.attachMaps 8-218 GbeCategory.. 7-61 FileLen 7-7. 7-56 Exit For 7-5.mslink 8-223 GbeFeature.color 8-222 GbeFeature. 7-60 FileDirs 7-7.mslink 8-219 GbeCategory. 7-65 i-6 MicroStation BASIC Guide . 7-65 Format$ 7-6..description 8-222 GbeFeature.name 8-223 GbeFeature.Next 7-5.maxCategories 8-217 GbeCategory. 7-58 exponent 3-3 Expressions 3-11 arithmetic operators 3-12 assignment operator 3-11 assignment operators 3-11 defined 3-11 logical operators 3-14 operator precedence 3-15 operator precedence in 3-15 relational operators 3-13 string concatenation operators 3-13 string concatentation operators 3-13 Extensions see MicroStation-specific extensions extensions see MicroStation-specific extensions flat subroutines 2-4 font 4-13 fontName 4-13 fonts cross reference 4-27 For 7-5 For.fileExt 8-219 GbeCategory.Index: F Error$ (function) 7-4 execution flow 3-16 Exit Do 7-5. 7-62 FileList 7-7..

linePolyOverlay 8-215 GbeTLayerMixed.name 8-226 GbeMaps(index) 8-226 GbeMaps.directory 8-229 GbeProject.workMap 8-230 GbeTLayerLine. 7-76 GetAttr 7-8.style 8-212 GbeTLayerPolygon.pointPolyOverlay 8-209 GbeTLayerPoint.level 8-210 GbeTLayerLine.weight 8-212 GbeTLayerType.maxFeatures 8-221 GbeMap.type 8-223 GbeFeature.attach 8-227 GbeMap.sqlStatement 8-205 GbeTLayerType.listByMslink 8-225 GbeMaps.DBconnect 8-229 GbeProject.type 8-205 Get 7-8.listByMslink 8-221 GbeFeatures.name 8-205 GbeTLayerType.detach 8-227 GbeMap.maxMaps 8-225 GbeProject.weight 8-210 GbeTLayerMixed.fillColor 8-213 GbeTLayerPolygon.exportFile 8-230 GbeProject.indexFromMslink 8-226 GbeMaps.open 8-230 GbeProject. 7-80 graphGroupLock 4-13 Graphics Elements complex 4-5 determining type 4-5 isHeader 4-5 location 4-11 modifying 4-8 simple 4-5 type 4-5 gridLock 4-13 gridReference 4-13 MicroStation BASIC Guide i-7 .color 8-208 GbeTLayerPoint.display 8-207 GbeTLayerType.shapesAsAreas 8-206 GbeTLayerType.loginName 8-230 GbeProject. 7-79 GoSub 7-5.directory 8-227 GbeMap. 7-78 getFirst 4-9 getNext 4-9 getPatternDelta 4-13 getScale 4-13 Global 7-5.linePolyOverlay 8-210 GbeTLayerLine.attachByView 8-226 GbeMaps.linePolyOverlay 8-214 GbeTLayerPolygon.holes 8-206 GbeTLayerType.add 8-207 GbeTLayerType.pointPolyOverlay 8-215 GbeTLayerPoint.nodeType 8-208 GbeTLayerPoint.close 8-231 GbeProject. 7-79 Goto 7-5.mapManager 8-230 GbeProject.level 8-212 GbeTLayerPolygon.indexFromMslink 8-222 GbeFeatures.load 8-206 GbeTLayerType.style 8-210 GbeTLayerLine.weight 8-224 GbeFeatures(index) 8-222 GbeFeatures.Index: G GbeFeature.keyMap 8-230 GbeProject.DBload 8-229 GbeProject.mslink 8-226 GbeMap.pointPolyOverlay 8-213 GbeTLayerPolygon.polyPolyOverlay 8-213 GbeTLayerPolygon.weight 8-208 GbeTLayerPolygon.isAttached 8-227 GbeMap.color 8-210 GbeTLayerLine.doFill 8-213 GbeTLayerPolygon.color 8-212 GbeTLayerPolygon.description 8-227 GbeMap.categoryMslink 8-227 GbeMap.level 8-208 GbeTLayerPoint.queryList 8-206 GbeTLayerType.

1-6 data type variables see Macro Data Type Variables data types in see Macro Data Types debugger see Macro Debugger debugging 2-11 defined 1-1 editing existing 2-6 editor 1-7. 7-99 Lof 7-8. 7-88 Is 7-2. 7-86 Integers see Macro Data Types intrinsic procedures see efficient structure intrinsic procedures IPmt 7-9. 4-13 levelLock 4-13 Like 7-2. 7-94 i-8 MicroStation BASIC Guide . 7-85 Int 7-3. 7-101 Log 7-3.Else 3-16. 7-98 local variables 2-12.Then..Index: H gridUnits 4-13 group 4-8 Let 7-6. 7-81 Imp 3-14. 7-102 H Hex$ 7-6. 7-80 Hour 7-9. 7-85 InStr 7-6. 7-87 IRR 7-9. 7-81 I IEEE 3-3 If 7-5 If. 7-91 program M Macro adding BASIC language constructs 1-2 comments in 3-1 creating 1-1. 7-92 LCase$ 7-6. 7-93 Len 7-6. 7-95 line continuation 3-15 Line Input # 7-8. 7-5. 7-2. 7-98 lineStyle 4-13 lineStyleName 4-13 lineTerminator 4-13 Loc 7-8. 7-96 Line Number Field 2-8 Line$ 7-6. 7-97 LineCount 7-6. 7-84 Input$ 7-8. 7-91 L LBound 7-3... 7-101 logical operators see Expressions logical operators Long Integers see Macro Data Types Loop 7-4 LSet 7-6. 3-10 Local Variables see Data Type Variables Lock 7-8. 7-90 ItemCount 7-6. 2-6 error handling in 3-38 examples 1-1 interactions with user 5-1 K Kill 7-8.. 7-90 isHeader 4-5 isometricLock 4-13 Item$ 7-6. 7-83 initialization of variables 3-11 Input # 7-8. 7-102 LTrim$ 7-6. 7-95 level 4-8. 7-93 Left$ 7-6.

7-103 Manipulating Graphics Elements see Macros mantissa 3-3 master units 4-2 masterUnits 4-2 Mbe prefix 1-1 MBE_ 4-1 Mbe_ 4-1 MBE_AccessDenied 9-2 MBE_ArrayError 9-4 MBE_BadElement 9-4 MBE_BadFileMode 9-2 MBE_BadFileNumber 9-2 MBE_BadRecordNumber 9-2 MBE_CantParseString 9-4 MBE_CantReadElemDscr 9-4 MBE_CantRewrite 9-4 MBE_CommandInput 8-124 MBE_ComplexComponent 9-4 MBE_ComponentNotFound 9-4 MBE_DataPointInput 8-124 MBE_DiskFull 9-2 MBE_FileAccessError 9-2 MicroStation BASIC Guide i-9 .Index: M language see Macro Language load 1-5 making the program more interactive 1-2 naming rules in 3-1 overview 1-1 procedures see Macro Procedures prototyping 1-1. 1-2 prototyping see Macro Prototyping recording 4-2 run 1-5 running the generator 1-2 use of BASIC 1-1 using constructs to control the execution of 3-16 Macro Data Type Variables arrays of 3-5 creating user-defined 3-8 declaring double 3-5 declaring integer 3-3 declaring long 3-4 declaring single 3-5 declaring string 3-4 fixed-length arrays 3-6 initial value 3-11 local 3-10 private 3-10 public 3-10 variable-length arrays 3-7 working with user-defined 3-9 Macro Data Types doubles 3-3 integers 3-2 long integers 3-2 singles 3-3 strings 3-2 Macro Debugger buttons 2-11 Macro Generator uses of 1-2 Macro Language 3-1 overview 3-1 Macro Language Extensions 2-4 design file information object 1-3 design view information object 1-4 element location 1-3 element object 1-3 element set object 1-3 reference file object 1-4 settings object 1-3 state object 1-3 Macro Manager 1-7 Macro Procedures 3-25 declaring 3-32 function 3-28 passing arguments to 3-30 subroutine 3-26 Macro Prototyping 2-1 example of 2-3 Macro Recording End 1-7 Pause 1-6 play 1-6 Macros coordinate system 4-2 graphics elements with 4-3 Main 7-5.

modeDelete 8-161 MbeDatabase.dAType 8-161 MbeDatabase.defineActiveEntity 8-161 MbeDatabase.pointFromUors 8-98 MbeCurrentTransform.errorText 8-161 MbeDatabase.name 8-161 MbeDatabase.fromView 8-97 MbeCurrentTransform.modeConfirm 8-161 MbeDatabase.editActiveEntity 8-161 MbeDatabase.scale 8-97 MbeDatabase 8-161 MbeDatabase.describe 8-161 MbeDatabase.moveOriginWorld 8-96 MbeCurrentTransform.modeCommit 8-161 MbeDatabase.scalarFromUors 8-98 MbeCurrentTransform.reportClose 8-161 MbeDatabase.Index: M MBE_FileNotFound 9-2 MBE_FontNotFound 9-4 MBE_IllegalFunctionCal 9-2 MBE_IndexOutOfBounds 9-2 MBE_InvalidChannel 9-4 MBE_InvalidClass 9-4 MBE_InvalidColor 9-4 MBE_InvalidLevel 9-4 MBE_InvalidRefFile 9-4 MBE_InvalidStyle 9-4 MBE_InvalidView 9-4 MBE_InvalidWeight 9-4 MBE_KeyinInput 8-124 MBE_MustGetFromUser 9-4 MBE_NoDDEML 9-3 MBE_NoFence 9-4 MBE_NoGraphics 9-5 MBE_NoMoreElems 9-4 MBE_NoMoreInSet 9-4 MBE_NoSelectionSet 9-4 MBE_NotComplex 9-4 MBE_NotEnoughPoints 9-4 MBE_NotOnDesignPlane 9-4 MBE_ObjectVariableNotSet 9-2 MBE_OutOfMemory 9-2 MBE_OutOfSTringSpace 9-2 MBE_Overflow 9-2 MBE_PatternInvalid 9-2 MBE_ReceivedCommand 9-4 MBE_RedimFixedArray 9-4 MBE_RefSaveDeferred 9-4 MBE_ResetInput 8-124 MBE_StringTooLong 9-4 MBE_SubFuncNotDefined 9-2 MBE_Success 4-1 MBE_TooManyChannels 9-2 MBE_TooManyPoints 9-4 MBE_TypeMismatch 9-2 MBE_UnsupportedDataType 9-5 MBE_VariableNotFound 9-5 MBE_VariableWrongType 9-5 MBE_WriteInhibit 9-4 MBE_WrongDimension 9-4 MBE_WrongElemType 9-4 MBE_WrongInputType 9-4 MbeAngleFromString 8-141 MbeBlockNameTable object 4-28 MbeCExpressionDouble 8-120 MbeCExpressionLong 8-120 MbeCExpressionString 8-121 MbeCurrentTransform 4-2 MbeCurrentTransform.disconnect 8-161 MbeDatabase.mslink 8-161 MbeDatabase.pointToUors 8-98 MbeCurrentTransform.activeEntity 8-161 MbeDatabase.dgnUnits 8-95 MbeCurrentTransform.masterUnits 8-93 MbeCurrentTransform.showActiveEntity 8-161 MbeDatabase.rotate 8-96 MbeCurrentTransform.modeLinkages 8-161 MbeDatabase.connect 8-161 MbeDatabase.scalarToUors 8-97 MbeCurrentTransform. errorText 8-162 i-10 MicroStation BASIC Guide .reportOpen 8-161 MbeDatabase.modeForms 8-161 MbeDatabase.moveOrigin 8-96 MbeCurrentTransform.

tableName 8-168.mslink 8-168.freeGroups 8-173 MbeDgnLevels.describe 8-163 MbeDatabase.isModified 8-169 MbeDatabaseLink.dgn3D 8-88 MbeDgnInfo.linkClass 8-168.editActiveEntity 8-164 MbeDatabase.uorPerSub 8-89 MbeDgnLevels Object 8-172 MbeDgnLevels.endOfFile 8-88 MbeDgnInfo.saveLevelsToFile 8-175 MbeDWGExportSettings 4-26 MbeDWGImportSettings 4-26 MbeElement 4-3.getGlobalOrigin 8-90 MbeDgnInfo.masterUnitName 8-88 MbeDgnInfo. 8-18 MicroStation BASIC Guide i-11 .dgnFileReadOnly 8-88 MbeDgnInfo.cellFileReadOnly 8-92 MbeDgnInfo.cell3D 8-91 MbeDgnInfo.linkType 8-168.entityNumber 8-168.isRemote 8-169 MbeDatabaseLink.dAType 8-168.reportOpen 8-167 MbeDatabase.addToFile 8-45 MbeElement.Index: M MbeDatabase. 8-170 MbeDatabaseLink.modeDelete 8-165 MbeDatabase. 8-170 MbeDatabaseLink.numNamedLevels 8-173 MbeDgnLevels.loadAllFromFile 8-175 MbeDgnLevels.modeForms 8-166 MbeDatabase.activeEntity 8-162 MbeDatabase. 4-6 MbeElement. 8-21 MbeElement.modeConfirm 8-165 MbeDatabase.area 8-46 MbeElement.showActiveEntity 8-164 MbeDatabaseLink 8-168 MbeDatabaseLink Object 8-168 MbeDatabaseLink.saveGroupsToFile 8-175 MbeDgnLevels.mslink 8-162 MbeDatabase. 8-169 MbeDatabaseLink.reportClose 8-167 MbeDatabase.freeAll 8-174 MbeDgnLevels.disconnect 8-163 MbeDatabase. 8-169 MbeDatabaseLink. 8-170 MbeDatabaseLink.subPerMaster 8-90 MbeDgnInfo.getGroup 8-173 MbeDgnLevels.defineActiveEntity 8-164 MbeDatabase.linkSize 8-168.isUserLink 8-169 MbeDatabaseLink. 8-171 MbeDatabaseLink.rootGroup 8-172 MbeDgnLevels.connect 8-163 MbeDatabase.isInformation 8-168.cellFileName 8-91 MbeDgnInfo.subUnitName 8-89 MbeDgnInfo.appendLinkage 8-60 MbeElement. 8-169 MbeDatabaseLink.loadGroupsFromFile 8-174 MbeDgnLevels. 8-171 MbeDgnInfo cell3d 4-12 cellFileName 4-12 cellFileReadOnly 4-12 dgn3d 4-12 dgnFileName 4-12 dgnFileReadOnly 4-12 endOfFile 4-12 graphicGroup 4-12 masterUnitName 4-12 nextGraphicGroup 4-12 subPerMaster 4-12 subUnitName 4-12 uorPerSub 4-12 MbeDgnInfo.attachActiveEntity 8-15.modeCommit 8-165 MbeDatabase.dgnFileName 8-87 MbeDgnInfo.saveAllToFile 8-176 MbeDgnLevels.freeLevels 8-174 MbeDgnLevels.modeLinkage 8-166 MbeDatabase.loadLevelsFromFile 8-174 MbeDgnLevels.dAType 8-167 MbeDatabase.numGroups 8-172 MbeDgnLevels.nextGraphicGroup 8-91 MbeDgnInfo.graphicGroup 8-90 MbeDgnInfo.getLevel 8-173 MbeDgnLevels.appendDBLinkage 8-15.name 8-161 MbeDatabase.

reportDBLinkages 8-19 MbeElement.componentFilePos 8-33 MbeElement.font 8-49 MbeElement.clear 8-65 MbeElementSet.weight 8-36 MbeElementSet.filePos 8-33 MbeElement. 8-20 MbeElement.secondaryAxis 8-54 MbeElement.getNumLinkages 8-59 MbeElement.getCentroid 8-47 MbeElement.extractTags 8-58 MbeElement.bottomRadius 8-55 MbeElement.thisComponent 8-27 MbeElement. 8-18 MbeElement.deleteDBLinkage 8-21 MbeElement.rewrite 8-44 MbeElement.firstElement 8-22 MbeElement.numTags 8-58 MbeElement.publish 8-56 MbeElement.changeAll 8-34 MbeElement.color 8-35 MbeElement.cellName 8-47 MbeElement.style 8-35 MbeElement.setString 8-53 MbeElement.getCellBox 8-48 MbeElement.deleteLinkage 8-61 MbeElement.deleteDBLinkages 8-15 MbeElement.Index: M MbeElement.fileNum 8-33 MbeElement.charWidth 8-50 MbeElement.perimeter 8-46 MbeElement.type 8-29 MbeElement. 8-19 MbeElement.foundDBLinkages 8-15.clas 8-36 MbeElement.primaryAxis 8-53 MbeElement.fromFile 8-31 MbeElement.getTopOrigin 8-55 MbeElement.getOrigin 8-38 MbeElement.move 8-42 MbeElement.extractDBLinkages 8-15.setPoints 8-40 MbeElement.getEndPoints 8-41 MbeElement.headerElement 8-26 MbeElement.tagId 8-57 MbeElement.getRotation 8-49 MbeElement.isTagged 8-57 MbeElement.justification 8-51 MbeElement.scale 8-43 MbeElement.isGraphics 8-29 MbeElement.isComponent 8-29 MbeElement. 8-32 MbeElement.getString 8-52 MbeElement.loadDAttributes 8-16.lineSpacing 8-51 MbeElement.properties 8-37 MbeElement.topRadius 8-55 MbeElement.attachTag 8-59 MbeElement.fromLocate 4-12.extractLinkage 8-59 MbeElement.charHeight 8-50 MbeElement.getCellLevels 8-48 MbeElement.fromSelectionSet 8-62 MbeElementSet. 8-19 MbeElement.startAngle 8-54 MbeElement.nextElement 8-22 MbeElement.group 8-57 MbeElement.isHeader 8-28 MbeElement.internalSize 8-30 MbeElement.nextComponent 8-24 MbeElement.reviewDBAttributes 8-17.volume 8-47 MbeElement.level 8-34 MbeElement.reportLinkages 8-17 MbeElement.sweepAngle 8-55 MbeElement.fontName 8-49 MbeElement.rotate 8-42 MbeElement.getPoints 8-39 MbeElement.fileSize 8-30 MbeElement.fromFence 8-63 MbeElementSet.getRange 8-41 MbeElement.display 8-45 MbeElement.getMbeTag 8-58 MbeElement.getFirst 8-64 i-12 MicroStation BASIC Guide .

display 8-110 MbeRefFile.axisAngle 8-68 MicroStation BASIC Guide i-13 .levelNumber 8-181 MbeNumberOfTagSets 8-184 MbeOpenModalDialog 5-2.msPlatform 8-117 MbeSession.locate 8-110 MbeRefFile.scaleLineStyle 8-111 MbeRefFile.msVersion 8-117 MbeSession.associationLock 8-81 MbeSettings. 8-131 MbeScalarFromString 8-141 MbeSelectBox 5-2. 8-146 MbeNamedLevel Object 8-181 MbeNamedLevel.getLevelMask 8-179 MbeLevelGroup.levelName 8-181 MbeNamedLevel.plot 8-111 MbeRefFile. 8-129 MbeSession.canSwapScreen 8-119 MbeSession.getLevelMask 8-182 MbeNamedLevel.active 8-109 MbeRefFile.msProduct 8-116 MbeSession. 8-127 MbeSendDataPoint 4-2.saveSettings 8-115 MbeRefFile.maxRefFiles 8-109 MbeRelocate 4-12. 8-145 MbeFindFile 8-143 MbeFontNameTable object 4-27 MbeGetConfigVar 8-143 MbeGetInput 4-2.getParentGroup 8-182 MbeNamedLevel.addLevel 8-180 MbeLevelGroup.suspend 8-203 MbeMessageBox 5-1.notFound 8-110 MbeRefFile. 8-147 MbeLevelGroup Object 8-177 MbeLevelGroup.description 8-113 MbeRefFile.Index: M MbeElementSet.getDescendentGroups 8-178 MbeLevelGroup.getParentGroup 8-179 MbeLevelGroup.suspend 8-203 MbeMacro.fileName 8-112 MbeRefFile.getDescendentLevels 8-178 MbeLevelGroup. 8-148 MbePoint 4-2.areaMode 8-68 MbeSettings.groupName 8-177 MbeLocateElement 8-139 MbeMacro Object 8-203 MbeMacro. 8-125 MbePointFromString 8-141 MbeRefFile.getNext 8-64 MbeFileCreate 5-1.elapsedTime 8-119 MbeSession.levelsOff 8-114 MbeRefFile.getLevels 8-177 MbeLevelGroup.deleteLevel 8-183 MbeNamedLevel. 8-147 MbeSendAppMessage 8-125 MbeSendCommand 4-1.levelComment 8-182 MbeNamedLevel. 8-129 MbeSendTentPoint 4-2.addGroup 8-180 MbeLevelGroup.levelsOn 8-114 MbeRefFile.angle 8-67 MbeSettings.attachName 8-112 MbeRefFile. 8-145 MbeFileOpen 5-1.getLevels 8-114 MbeRefFile.scale 8-113 MbeRefFile. 8-124 MbeGetTagSetNames 8-184 MbeInputBox 5-1.deleteGroup 8-180 MbeLevelGroup.snap 8-111 MbeRefFiles(index) 8-109 MbeRefFiles.logical 8-113 MbeRefFile. 4-12. 8-127 MbeSendDragPoints 8-128 MbeSendKeyin 4-1.language 8-118 MbeSession. 8-129 MbeSendReset 4-2.numScreens 8-118 MbeSetAppVariable 8-125 MbeSetMember 4-9 MbeSetScaledAppVar 8-126 MbeSettings 8-66 MbeSettings.

setPatternDelta 8-76 MbeSettings.cell 8-69 MbeSettings.patternScale 8-77 MbeSettings.snapLock 8-86 MbeSettings.getInputCommand 8-3 MbeState.class 8-69 MbeSettings.fillMode 8-71 MbeSettings.textLineSpacing 8-80 MbeSettings.precision 8-152 MbeSqlda.isNull 8-151 MbeSqlda.length 8-151 MbeSqlda.currentGraphicGroup 8-71 MbeSettings.length 8-150 MbeSqlda.fontName 8-72 MbeSettings.graphGroupLock 8-83 MbeSettings.axisLock 8-82 MbeSettings.lineTerminator 8-74 MbeSettings.gridReferences 8-72 MbeSettings.column 8-150 MbeSqlda.type 8-150 MbeSqlda.textJustification 8-80 MbeSettings.tagIncremen 8-78 MbeSettings.patternAngle1 8-75 MbeSettings.patternCell 8-76 MbeSettings.setScale 8-78 MbeSettings.point 8-77 MbeSettings.column 8-150 MbeSqlda.value 8-150 MbeStartDefaultCommand 8-144 MbeStartLocate 4-11.getLocateTypeMask 8-11 MbeState.axisOrigin 8-68 MbeSettings.value 8-150 MbeSqlda.fenceClip 8-84 MbeSettings.colorName 8-70 MbeSettings. 8-132 MbeState 4-2 MbeState.patternAngle2 8-75 MbeSettings.scale 8-150 MbeSqlda.textWidth 8-79 MbeSettings. 8-150 MbeSqlda.textLineLength 8-80 MbeSettings.constructionPlaneLock 8-83 MbeSettings.depthLock 8-83 MbeSettings.fillColor 8-71 MbeSettings.selectionSetLock 8-85 MbeSettings.nodeJustification 8-75 MbeSettings.Index: M MbeSettings.getInputKeyin 8-4 MbeState.isNull 8-150 MbeSqlda.getIndex 8-150 MbeSqlda.textNodeLock 8-86 MbeSettings.settingErr 8-86 MbeSettings.textHeight 8-79 MbeSettings.level 8-73 MbeSettings.levelLock 8-85 MbeSettings.getInputDataPoint 8-4 MbeState.font 8-72 MbeSettings.getIndex 8-152 MbeSqlda.color 8-70 MbeSettings.getLocateFileMask 8-10 MbeState.capMode 8-69 MbeSettings.terminatorScale 8-79 MbeSettings.fenceVoid 8-85 MbeSettings.getPatternDelta 8-77 MbeSettings.getScale 8-78 MbeSettings.fenceOverlap 8-84 MbeSettings.gridLock 8-84 MbeSettings.lineStyleName 8-74 MbeSettings.cmdResult 8-5 MbeState.inputType 8-3 i-14 MicroStation BASIC Guide .cellStretchLock 8-82 MbeSettings.numColumns 8-150 MbeSqlda.weight 8-81 MbeSqlda 4-15.type 8-151 MbeSqlda.errorMessages 8-6 MbeState.scale 8-152 MbeSqlda.precision 8-150 MbeSqlda.numColumns 8-150 MbeSqlda.gridUnits 8-73 MbeSettings.lineStyle 8-74 MbeSettings.boresiteLock 8-82 MbeSettings.

fenceFilter 8-155 MbeTable.drop 8-153 MbeTable.recordLast 8-153 MbeTable.getOffset 8-197 MbeTag.recordNext 8-157 MbeTable.create 8-159 MbeTable.getTaggedElement 8-202 MbeTag.setOffset 8-197 MbeTag.recordLast 8-157 MbeTable.getMbeElement 8-201 MbeTag.describe 8-153 MbeTable.fileNum 8-197 MbeTag.parseAll 8-7 MbeState.copy 8-159 MbeTable.Index: M MbeState.getTextElement 8-197 MbeTag. 8-6 MbeState.recordNext 8-153 MbeTable.locatePropVal 8-13 MbeState.getTaggedElement 8-197 MbeTag.setName 8-197 MbeTag.locateHeaderFilePos 8-10 MbeState.type 8-199 MbeTag.fileNum 8-198 MbeTag.recordFirst 8-156 MbeTable.version 8-197 MbeTag.add 8-191 MicroStation BASIC Guide i-15 .describe 8-156 MbeTable.value 8-197 MbeTag.create 8-153 MbeTable.recordDelete 8-159 MbeTable.entityNumber 8-154 MbeTable.size 8-200 MbeTag.recordUpdate 8-158 MbeTable.locateClassMask 8-14 MbeState.id 8-198 MbeTag.name 8-198 MbeTag.getTextElement 8-202 MbeTag.entityNumber 8-153 MbeTable.recordUpdate 8-153 MbeTable.criteria 8-153 MbeTable.value 8-199 MbeTag.recordFirst 8-153 MbeTable.isHidden 8-197 MbeTag.recordInsert 8-158 MbeTable.id 8-197 MbeTag.setLocateTypeMask 8-11 MbeStringFromAngle 8-143 MbeStringFromPoint 8-142 MbeStringFromScalar 8-142 MbeTable 8-153 MbeTable.recordDelete 8-153 MbeTable.size 8-197 MbeTag.activeReview 8-154 MbeTable.activeReview 8-153 MbeTable.version 8-200 MbeTagDef Object 8-191 MbeTagDef.measureResult2 8-7 MbeState.criteria 8-153 MbeTable.setOffset 8-201 MbeTag.setLocateFileMask 8-10 MbeState.drop 8-160 MbeTable.targetId 8-197 MbeTag.reportTable 8-155 MbeTag Object 8-197 MbeTag.locateFileNum 8-9 MbeState.targetId 8-199 MbeTag.name 8-197 MbeTag.messages 8-2.isHidden 8-200 MbeTag.reportTable 8-153 MbeTable.name 8-153 MbeTable.locateComponentFilePos 8-10 MbeState.locatePropMask 8-13 MbeState.copy 8-153 MbeTable.noElementDisplay 8-6 MbeState.largestMslink 8-153 MbeTable.locateTolerance 8-8 MbeState.recordInsert 8-153 MbeTable.setName 8-197 MbeTag.getOffset 8-201 MbeTag.type 8-197 MbeTag.largestMslink 8-154 MbeTable.name 8-153 MbeTable.getMbeElement 8-197 MbeTag.measureResult1 8-7 MbeState.

getTagDefNames 8-186 MbeTagSet.noText 8-101 MbeView.tagId 8-194 MbeTagDef.delete 8-188 MbeTagSet.fileNum 8-186 MbeTagSet.pattern 8-102 MbeView.add 8-186 MbeTagSet.levelsOn 8-107 MbeView.delete 8-191 MbeTagDef. 8-130 MbeWriteError 4-2.levelsOff 8-107 MbeView.enterDataField 8-103 MbeView.update 8-195 MbeTagSet Object 8-186 MbeTagSet.getTagDef 8-189 MbeTagSet.textNode 8-103 MbeView.add 8-195 MbeTagDef.slowFont 8-102 MbeView.name 8-191 MbeTagDef.fastCurve 8-101 MbeView.screenNum 8-101 MbeView.refBoundary 8-105 MbeView.reportName 8-186 MbeTagSet.reportName 8-186 MbeTagSet.generateReport 8-189 MbeTagSet.update 8-186 MbeTagSet.grid 8-103 MbeView.isConstant 8-194 MbeTagDef.isHidden 8-191 MbeTagDef.dimension 8-104 MbeView.name 8-186 MbeTagSet.fastRefClip 8-105 MbeView.tagType 8-193 MbeTagDef. 8-131 MbeWriteStatus 4-2.construction 8-104 MbeView.update 8-191 MbeTagDef.generateReport 8-186 MbeTagSet.style 8-192 MbeTagDef.tagType 8-191 MbeTagDef.isHidden 8-194 MbeTagDef.name 8-191 MbeTagDef.tagId 8-191 MbeTagDef.delete 8-196 MbeTagDef. 8-131 MbeWritePrompt 4-2.numTagDefs 8-186 MbeTagSet.levelSymbology 8-103 MbeView.name 8-186 MbeTagSet.isConstant 8-191 MbeTagDef.add 8-188 MbeTagSet.delete 8-186 MbeTagSet.getTagDefNames 8-187 MbeTagSet.update 8-188 MbeView.deleteInstances 8-190 MbeTagSet.getTagDef 8-186 MbeTagSet.deleteInstances 8-186 MbeTagSet.style 8-191 MbeTagDef.areaFill 8-105 MbeView.fileNum 8-187 MbeTagSet. 8-131 MDE 6-1 MDL 6-2 advantages over BASIC 6-3 Built-in Functions 6-2 MicroCSL 6-3 MicroStation accessing accessing accessing accessing database features 4-15 design file view information 4-14 reference file information 4-14 session information 4-15 i-16 MicroStation BASIC Guide .setName 8-191 MbeTagDef.Index: M MbeTagDef.getLevels 8-106 MbeView.prompt 8-191 MbeTagDef.deferApply 8-105 MbeView.active 8-100 MbeView.lineWeight 8-102 MbeView.defaultValue 8-193 MbeTagDef.numTagDefs 8-187 MbeTagSet.prompt 8-192 MbeTagDef.update 8-106 MbeViews(index) 8-99 MbeWriteCommand 4-2.defaultValue 8-191 MbeTagDef. 8-130 MbeWriteMessage 4-2.setName 8-192 MbeTagDef.

Index: N accessing settings 4-13 accessing state information 4-13 MicroStation Development Environment 6-1 tools provided 6-1 MicroStation Development Language 6-2 MicroStation Error Message MBE_ArrayError 9-4 MBE_BadElement 9-4 MBE_CantParseString 9-4 MBE_CantReadElemDscr 9-4 MBE_CantRewrite 9-4 MBE_ComplexComponent 9-4 MBE_ComponentNotFound 9-4 MBE_FontNotFound 9-4 MBE_InvalidChannel 9-4 MBE_InvalidClass 9-4 MBE_InvalidLevel 9-4 MBE_InvalidRefFile 9-4 MBE_InvalidStyle 9-4 MBE_InvalidView 9-4 MBE_InvalidWeight 9-4 MBE_MustGetFromUser 9-4 MBE_NoFence 9-4 MBE_NoGraphics 9-5 MBE_NoMoreElems 9-4 MBE_NoMoreInSet 9-4 MBE_NoSelectionSet 9-4 MBE_NotComplex 9-4 MBE_NotEnoughPoints 9-4 MBE_NotOnDesignPlane 9-4 MBE_ReceivedCommand 9-4 MBE_RedimFixedArray 9-4 MBE_RefSaveDeferred 9-4 MBE_StringTooLong 9-4 MBE_TooManyPoints 9-4 MBE_UnsupportedDataType 9-5 MBE_VariableNotFound 9-5 MBE_VariableWrongType 9-5 MBE_WriteInhibit 9-4 MBE_WrongDimension 9-4 MBE_WrongElemType 9-4 MBE_WrongInputType 9-4 MicroStation Error Messages 9-4 MicroStation Settings 4-13 MicroStation-specific extension reasons for 2-4 MicroStation-specific extensions 4-1 collections 4-1 data types 4-1 differences from other BASIC features 4-1 functions 4-1 objects 4-1 overloading 2-4 predefined constants 4-1 prefixes 4-1 Mid$ 7-6. 7-111 O object collections 3-37 declaring 3-33 methods 3-33 properties 3-33 Object Extensions Design File Information 1-3 Design View Information 1-4 MicroStation BASIC Guide i-17 . 7-106 moveOriginWorld 4-3 multi-dimensional arrays see arrays multi-dimensional arrays N Name 7-8. 7-107 Now 7-9. 7-104 MkDir 7-8. 7-108 NPer 7-9. 7-105 Mod 7-2. 7-2. 7-103 Minute 7-9. 7-106 Mod Operator 3-12 Month 7-9. 7-107 Next 7-5 nextComponent 4-6 nextElement 4-6 nodeJustification 4-13 Not 3-14. 7-110 Null 7-6. 7-104 MIRR 7-9. 7-108 Npv 7-9.

7-125 Pv 7-9. 7-111 On Error 7-5. 7-127 P parameters 3-30 ByVal 3-26 parenthesis 3-15 patternAngle1 4-13 patternAngle2 4-13 patternCell 4-13 patternScale 4-13 pen table entry points 4-22 pen tables 4-18 creating 4-19 PI 7-2. 7-117 overloaded extensions 2-4 Print # 7-8. 7-118 Pmt 7-9. 7-122 Print (statement) 7-4 Private 7-6. 3-10 Put 7-8. 3-36 properties 3-32. 7-119 precedence 3-15 Print 7-121 Q Querying Graphics Elements see Macros R Random 7-3. 7-2. 7-114 operator precedence 3-15 Option Base 7-3. 7-116 Option Compare 7-6. 7-123 private variables 2-12. 7-116 Option Menu 5-8 Or 3-14. 7-118 point 4-13 PPmt 7-9. 3-10 Private Variables see Macro Data Type Variables procedures 3-25 ProcessElement 4-8 program entry points Pen Table Plot Element Hook 4-24 Plot Finished Hook 4-25 Post-Plot Hook 4-24 Pre-Plot Hook 4-24 program structure see efficient program structure properties class 4-5 color 4-5 getEndPoints 4-5 getOrigin 4-5 getPoints 4-5 getRange 4-5 level 4-5 style 4-5 weight 4-5 prototyping see Macro Prototyping Public 7-6. 7-128 Rate 7-9. 3-36 Oct$ 7-6. 7-130 Reference File Objects 8-108 MbeRefFile. 7-112 Open 7-8. 7-128 Randomize 7-3. 7-124 public variables 2-12. 7-129 recursion see efficient program structure recursion ReDim 7-3.Index: P MbeDgnInfo 1-3 MbeRefFile 1-4 MbeSettings 1-3 MbeState 1-3 MbeView 1-4 Reference File 1-4 Settings 1-3 State 1-3 object methods 4-13 Objects in BASIC 3-32 defined 3-32 methods 3-32.active 8-108 i-18 MicroStation BASIC Guide .

locate 8-108 MbeRefFile. 7-135 Seek (function) 7-8.snap 8-108 MbeRefFiles(index) 8-108 MbeRefFiles. 7-2. 7-135 Seek (statement) 7-8.elapsedTime 8-116 MbeSession.fileName 8-108 MbeRefFile.logical 8-108 MbeRefFile.Case 3-18. 7-5.levelsOn 8-108 MbeRefFile.display 8-108 MbeRefFile. 7-131 Resource Files 5-4 Resume 7-5..maxRefFiles 8-108 relational operators see Expressions relational operators REM 3-1.canSwapScreen 8-116 MbeSession. 7-133 return values 4-1 Right$ 7-6.. 7-135 run-time error codes 4-30 Runtime Error Messages bad filename 9-2 bad record length 9-2 can’t rename with different drive 9-2 data in wrong format 9-3 data not provided in DDE operation 9-3 DDE conversation closed or changed 9-3 DDE requires ddeml.scaleLineStyle 8-108 MbeRefFile. 7-137 Selection Sets 4-9 clear 4-9 fromFence 4-9 fromSelectionSet 4-9 getFirst 4-9 getNext 4-9 MbeElementSet 4-9 MbeSetMember 4-9 selectionSetLock 4-13 Session Object 8-116 MbeSession.plot 8-108 MbeRefFile.saveSettings 8-108 MbeRefFile. 7-133 RmDir 7-8. 7-131 Return 7-5. 7-133 Rnd 7-3.msPlatform 8-116 MicroStation BASIC Guide i-19 .notFound 8-108 MbeRefFile.attachName 8-108 MbeRefFile.language 8-116 MbeSession. 7-134 RTrim$ 7-7. DDE msg lost 9-3 multiple apps responded to DDE initiate 9-3 no foreign app responded to DDE initiate 9-3 no more DDE channels 9-2 no resumes 9-2 out of stack space 9-2 path not found 9-2 resume without error 9-2 timeout waiting for DDE response 9-3 user pressed ESC during DDE operation 9-3 S scalarFromUors 4-3 scalarToUors 4-3 scale 4-3 scaleLock 4-13 scope 3-9 Second 7-9.Index: S MbeRefFile. 7-136 Select 7-5 Select. 7-131 Reset 7-8. 7-134 rotate 4-3 Rounding 3-12 RSet 7-6.dll 9-3 destination is busy 9-3 device I/O error 9-2 device unavailable 9-2 disk not ready 9-2 division by zero 9-2 file already exists 9-2 file already open 9-2 foreign app won’t perform DDE method 9-3 foreign application quit 9-3 input past end of file 9-2 internal errors 9-2 message queue filled.levelsOff 8-108 MbeRefFile.getLevels 8-108 MbeRefFile.scale 8-108 MbeRefFile.description 8-108 MbeRefFile.

getPatternDelta 8-66 MbeSettings.capMode 8-66 MbeSettings.weight 8-67 Sgn 7-3.color 8-66 MbeSettings.setPatternDelta 8-66 MbeSettings.terminatorScale 8-66 MbeSettings.fenceClip 8-67 MbeSettings.cmdResult 8-2 MbeState.textLineSpacing 8-67 MbeSettings.textNodeLock 8-67 MbeSettings.patternCell 8-66 MbeSettings.point 8-66 MbeSettings.boresiteLock 8-67 MbeSettings. 7-139 SetAttr 7-8.fontName 8-66 MbeSettings.level 8-66 MbeSettings.graphGroupLock 8-67 MbeSettings.textJustification 8-67 MbeSettings.axisOrigin 8-66 MbeSettings.gridUnits 8-66 MbeSettings.constructionPlaneLock 8-67 MbeSettings.settingErr 8-67 MbeSettings.cellStretchLock 8-67 MbeSettings.lineTerminator 8-66 MbeSettings.patternAngle2 8-66 MbeSettings.currentGraphicGroup 8-66 MbeSettings.Index: S MbeSession. 7-141 Sln 7-9.lineStyleName 8-66 MbeSettings.angle 8-66 MbeSettings. 7-143 State information cmdResult 4-13 errorMessages 4-14 locateClassMask 4-14 locateComponentFilePos 4-13 locateFileNum 4-13 locateHeaderFilePos 4-13 locatePropMask 4-14 locatePropVal 4-14 locateTolerance 4-14 measureResult1 4-14 measureResult2 4-14 messages 4-14 noElementDisplay 4-14 setLocateFileMask 4-14 setLocateTypeMask 4-14 State Object 8-2 MbeState.patternScale 8-66 MbeSettings.font 8-66 MbeSettings.patternAngle1 8-66 MbeSettings.textWidth 8-67 MbeSettings.class 8-66 MbeSettings. 7-142 snapLock 4-13 Space$ 7-7.textHeight 8-67 MbeSettings.getScale 8-66 MbeSettings. 7-141 Singles see Macro Data Types Sleep 7-4.fillMode 8-66 MbeSettings.gridReferences 8-66 MbeSettings. 7-142 Spc 7-4.errorMessages 8-2 i-20 MicroStation BASIC Guide .snapLock 8-67 MbeSettings.gridLock 8-67 MbeSettings. 7-143 Sqr 7-3.colorName 8-66 MbeSettings.cell 8-66 MbeSettings.depthLock 8-67 MbeSettings.msVersion 8-116 MbeSession.axisLock 8-67 MbeSettings.selectionSetLock 8-67 MbeSettings.fenceVoid 8-67 MbeSettings.fenceOverlap 8-67 MbeSettings.fillColor 8-66 MbeSettings.axisAngle 8-66 MbeSettings.textLineLength 8-67 MbeSettings.msProduct 8-116 MbeSession.setScale 8-66 MbeSettings.tagIncrement 8-66 MbeSettings. 7-140 setPatternDelta 4-13 setScale 4-13 Settings Object 8-66 MbeSettings.nodeJustification 8-66 MbeSettings.lineStyle 8-66 MbeSettings. 7-141 simple graphics elements 4-3 attributes 4-5 properties 4-5 Sin 7-3.associationLock 8-67 MbeSettings.levelLock 8-67 MbeSettings.numScreens 8-116 Set 7-6.

7-151 type 4-5.locateComponentFilePos 8-2 MbeState.End Sub 7-5. 7-153 User input MbeGetInput 4-2 MbeSendCommand 4-1 MbeSendDataPoint 4-2 MbeSendKeyin 4-1 MbeSendReset 4-2 MbeSendTentPoint 4-2 MbeState 4-2 T Tab 7-4.getLocateFileMask 8-2 MbeState.setLocateFileMask 8-2 MbeState. 7-149 TimeSerial 7-9.inputType 8-2 MbeState. 7-144 Str$ 7-7.locateTolerance 8-2 MbeState. 7-152 UCase$ 7-7. 7-146 Strings see Macro Data Types style 4-8 Sub.Index: T MbeState. 7-145 string concatenation operators see Expressions string concatenation operators String$ 7-7. 7-150 TimeValue 7-9.getLocateTypeMask 8-2 MbeState. 7-150 Topology Objects 8-204 GbeTLayerLine 8-204 GbeTLayerMixed 8-204 GbeTLayerPoint 8-204 GbeTLayerPolygon 8-204 translation settings 4-26 Trim$ 7-7.locatePropVal 8-3 MbeState.getInputCommand 8-2 MbeState.locatePropMask 8-3 MbeState. 7-147 Symbolic Constants 3-11 charWidth 4-5 font 4-5 getString 4-5 justification 4-5 textHeight 4-13 textJustification 4-13 textLineLength 4-13 textLineSpacing 4-13 textNodeLock 4-13 textWidth 4-13 Then 7-5 Time$ 7-9.locateClassMask 8-3 MbeState.getInputKeyin 8-2 MbeState. 7-144 StrComp 7-7.parseAll 8-2 MbeState.. 7-151 truncation 3-12 Type 7-6.locateFileNum 8-2 MbeState.getInputDataPoint 8-2 MbeState. 4-8 U UBound 7-3.noElementDisplay 8-2 MbeState. 7-148 Tag BASIC Extensions 8-184 MbeGetTagSetNames 8-184 MbeNumberOfTagSets 8-184 tagIncrement 4-13 Tan 7-3. 7-149 Timer 7-9. 7-148 terminatorScale 4-13 text attributes charHeight 4-5 MicroStation BASIC Guide i-21 .. 7-153 UDT (User Defined Type) variables 2-13 creating 3-8 UnLock 7-8.measureResult2 8-2 MbeState. 7-146 Subroutine procedures 3-25 SYD 7-9.measureResult1 8-2 MbeState.locateHeaderFilePos 8-2 MbeState. 7-151 True 7-2.setLocateTypeMask 8-2 Status Message Field 2-8 Stop 7-5.

. 7-2.Wend 7-5. 2-12 changing values 2-12 Variables dialog box 2-12 viewing values 2-12 View Objects 8-99 MbeView.noText 8-99 MbeView. 2-2 Macros 1-5 weight 4-8.getLevels 8-99 MbeView. 4-13 Wend 7-5 While 7-5.levelsOn 8-99 MbeView.active 8-99 MbeView. 7-158 V Val 7-7.areaFill 8-99 MbeView.textNode 8-99 MbeView.enterDataField 8-99 MbeView.levelsOff 8-99 MbeView. 7-156 Word$ 7-7. 7-159 W Weekday 7-9. 7-154 variable scope 3-9 Variable see Macro Data Type Variables variables 1-2.fastCurve 8-99 MbeView.deferApply 8-99 MbeView.pattern 8-99 MbeView..lineWeight 8-99 MbeView.slowFont 8-99 MbeView.Index: V MbeWriteCommand 4-2 MbeWriteError 4-2 MbeWriteMessage 4-2 MbeWritePrompt 4-2 MbeWriteStatus 4-2 Utilities Menu Create Macro… 1-6. 7-157 WordCount 7-7.screenNum 8-99 MbeView.fastRefClip 8-99 MbeView. 7-158 Y Year 7-9.dimension 8-99 MbeView. 7-156 While.construction 8-99 MbeView.grid 8-99 MbeView.update 8-99 Visual Basic 9-2 X Xor 3-14. 7-155 i-22 MicroStation BASIC Guide .levelSymbology 8-99 MbeView. 7-156 Width# 7-8.refBoundary 8-99 MbeView. 2-1 End Macro 1-7. 7-157 Write # 7-8.