51
UsingLogicalOperatorsinExpressions
"And","or",and"not"arelogicaloperators.YouusethemtocombineexpressionsinSelectandthe
WhereConditionclauseofSQLSelect.MapInfoProfessionaltreatseachsuchanexpressionasatest,
whichitappliestoeachrecordinthetable.Foreachtestitgetsayes/no(true/false)answer.MapInfo
Professionalusesthelogicaloperatorstotellithowtocombinetheindividualyes/noanswersintoan
overallyes/noanswer:Doesthecurrentrecordmeettheselectioncondition?
Description
Operator
is"true"if(andonlyif)bothofitsarguments(theexpressionsitjoins
together)aretrue.Arecordmustsatisfybothoftheseconditionsif
itistobeselected.
and
is"true"ifeitherone,orboth,ofitsarguments(theexpressionsit
joinstogether)aretrue.Arecordneedsatisfyonlyoneofthese
or
conditionsifitistobeselected.Itisalsoselectedifbothofits
conditionsaresatisfied.
is"true"ifitsargument(theexpressionitappliesto)isfalse.Arecord
isselectedifitdoesnotmeetthestatedcondition.
not
Supposeyouwanttoselectallpropertiesthatareworth$250,000ormoreandareinColumbiacounty.
Eachrecordhastomeettwocriteria,eachofwhichcanbeformulatedasasimpleexpression:
1. VALUE>=250000
2. COUNTY="Columbia"
Youcouldperformoneselectionforallpropertiesworth$250,000ormore.Thenyoucouldperform
anotherselectiononthatresult,lookingforallpropertiesinColumbiacounty.However,itiseasierto
combinethetwooperationsintooneusingthelogicaloperator"and".
1. COUNTY="Columbia"andVALUE>=250000
WhenMapInfoProfessionalexaminesarecordtoseewhetherornotitmeetstheconditionsetbythis
expression,itmakesthetwotests:DoesCOUNTYequalColumbia?IstheVALUEequaltoorgreater
than250000?Whentheanswertobothofthesequestionsistrue(oryes),thentherecordisaccepted
intothecurrentselection.Whentheanswertooneorbothofthequestionsisno(orfalse),thenthe
recordisnotacceptedintothecurrentselection.
Now,whatifyouwantallpropertiesworth$250,000ormoreandnotinColumbiacounty?Youcanuse
"not"tonegatethefirstclauseofexpression33,yieldingexpression34:
1. not(COUNTY="Columbia")andVALUE>=250000
OnlyrecordswherethecountyisnotColumbiasatisfythefirstclauseofexpression34.Nowconsider
expression35:
1. not(COUNTY="Columbia"andVALUE>=250000)
Expression35issimplythenegationofexpression33.Anyrecordthatwouldsatisfy33doesnotsatisfy
35.Anyrecordthatdoesnotsatisfy33satisfies35.
Youcanuse"or"whenyouwanttospecifyalternativeconditions,suchas:
1. COUNTY="Columbia"orCOUNTY="Greene"
Anyrecordevaluatedagainstthisconditionisacceptedifitscountyisanyoneofthetwospecified
counties.Onecould,ofcourse,usenumericaltestsaswell.Forexample:
1. TOTAL_AREA>40orVALUE>250000
Thisteststoseewhethertheareaisgreaterthan40orthevalueisgreaterthan250000.Wheneither
oneistrueofarecord,thenthatrecordisacceptedintotheselection.
MapInfoProfessional12.5
444
CreatingExpressions
C# Word - Word Conversion in C#.NET Word documents in .NET class applications independently, without using other external third-party dependencies like Adobe Acrobat. Word to PDF Conversion.
erase text from pdf; how to delete text in pdf preview
48
Informulatingexpressionsusinglogicaloperatorsyouhavetobecarefulhowyouusethem.Thefollowing
expression,whileitseemsOK,doesnotwork:
1. COUNTY="Columbia"or"Greene"
JudgingfromitsEnglishtranslation-COUNTYequalsColumbiaorGreene-thisexpressionshouldoperate
justlikeexpression36andgiveusanyrecordcontainingColumbiaCountyorGreeneCounty.Butthe
rulesofcomputationallogicandtherulesofEnglishareabitdifferent.
WhenMapInfoProfessionalreadsexpressionsitreadsthemfromlefttoright.Oneofthethingsithas
todoistodeterminehowtheitemsintheexpressionaregrouped.Thinkofthisoperationasinserting
parenthesesintotheexpression.MapInfoProfessionalreadsexpression35asthoughitweregrouped
likeexpression39,whichiswhatweintend.
Itreadsexpression38asthoughitweregroupedlike40,whichisnotatallwhatwewant.
1. (COUNTY="Columbia")or(COUNTY="Greene")
2. (COUNTY="Columbia")or("Greene")
Both39and40havethesamefirstclause.Buttheirsecondclauses(afterthe"or")arequitedifferent.
Thesecondclauseof40issimplyaliteralstring,"Greene."Byconvention,MapInfoProfessionalevaluates
arecordagainstaliteralstringasbeingtrueifthatrecordisnotblank.WhenMapInfoProfessional
evaluatesrecordsagainstexpression40,allnon-blankrecordsareevaluatedastrueandbeaccepted
intotheselection.Itdoesnotmakeanydifferencehowarecordevaluatesonthefirstclause.Any
non-blankrecordevaluatesastrueonthesecondclause,andone"true"isallittakestoevaluatethe
entireexpressionastrue.
Letusconsideronefinalexample,whichisthenegationofexpression36:
1. not(COUNTY="Greene"orCOUNTY="Columbia")
Expression39issatisfiedifthecountyisGreeneorifitisColumbia,butnotifitisMontgomeryorWarren.
Expression41issatisfiedbyanycountyotherthanGreeneorColumbia,includingMontgomeryand
Warren.
TheHelpSystemcontainstheserelatedtopics:
• NumericClauses
• StringClauses
• DateClauses
• KeywordClauses
UnderstandingOperatorPrecedence
WhenMapInfoProfessionalevaluatesexpressionsitneedstoknowwhichcomponentsofanexpression
toevaluatefirst.Thisiscalledprecedence.Byconvention,certainoperatorsareassigneddifferentlevels
ofprecedence.Thosewiththehighestlevelareevaluatedfirst.ThefollowingtablelistsMapInfo
Professional'soperatorsintheorderinwhichtheyareevaluated.Exponentiationevaluatesfromthe
right.Thisaffectsexpressionswithmultipleexponents:2^-3^-4=2^(-(3^(-4)))
Operatorsatthesamelevelofprecedenceareevaluatedfromlefttoright.
Parenthesis
HighestPriority:
Exponentiation
Negation
Multiplication,Division
Addition,Subtraction
Geographicoperators,Comparisonoperators
Not
445
MapInfoProfessionalUserGuide
Chapter17:SpecializedTopicsinMapInfoProfessional
44
And
Or
LowestPriority:
Forexample,theexpression3+4*2producesaresultof11.Thatisbecausemultiplicationhasahigher
precedencethanadditionandisperformedfirst,ineffect:
3+4*2=
3+8=
11
WecanaddparenthesistoforceMapInfoProfessionaltodotheadditionfirst:
(3+4)*2=
7*2=
14
Nowconsiderexpression60,whichisintendedtoselectallrecordsJulyorSeptemberof1989.
1. year(RECEIVED)=89andmonth(RECEIVED)=7ormonth(RECEIVED)=9
Because"and"hashigherprecedencethan"or",MapInfoProfessionaltreatsthisexpressionasthough
"year(RECEIVED)=89andmonth(RECEIVED)=7"wasenclosedinparentheses.
1. (year(RECEIVED)=89andmonth(RECEIVED)=7)ormonth(RECEIVED)=9
Inthiscase,anyrecordforJulyof89orforSeptemberofanyyearwouldbeselected.Thatisprobably
notwhatyouwant.However,byaddingparenthesestothesecondexpression,youcangetthis:
1. year(RECEIVED)=89and(month(RECEIVED)=7ormonth(RECEIVED)=9)
Inthisexpression,theparenthesestellMapInfoProfessionalthat"month(RECEIVED)=7"and
"month(RECEIVED)=9"arealternativesinthesecondclauseoftheexpression.MapInfoProfessional
treatsthisthesameasittreatsnumber53above.
WhenyouarenotsurehowMapInfoProfessionalevaluatesanexpressionwithseveraloperators,
youshoulduseparenthesestogroupelementsasyouwantthem.
Note:
UsingFunctionsinExpressions
Functionstakedatavaluesandperformsomeoperationonthemtoproduceanewvalue.Functions
havethefollowingform:
SomeFunction(parameters)
MostofMapInfoProfessional'sfunctionstakeoneortwoparameters.Aparametercanbeacolumnor
anotherexpression.MapInfoProfessionalusesthekeyword"obj"or"object"withthegeographicfunctions:
Area,CentroidX,CentroidY,ObjectLen,andPerimeter.ThiskeywordtellsMapInfoProfessionalthatit
hastogetvaluesbasedongraphicalobjectsinthetableratherthantabulardata.
• Formoreinformationaboutspecificfunctions,seetheHelpSystem.
Working with the MapBasic Window
ThissectionallowsadvancedMapInfoProfessionaluserstogobehindthescenesandtakeadvantage
offunctionsthatenhancetheuseofMapInfoProfessionalthroughtheMapBasicwindow.MapBasicis
MapInfoProfessional'sprogramminglanguagethatallowsyoutocustomizeandautomateMapInfo
Professionalfunctionality.WhenMapBasicwascreated,theMapBasicWindowfeaturewasaddedto
MapInfoProfessionalasameansoftestinganddebuggingcodeforanapplication.Itbecameapparent
MapInfoProfessional12.5
446
WorkingwiththeMapBasicWindow
48
thattheMapBasicwindowisalsoausefultooltoMapInfoProfessionalusersfordoingcertaintasks
suchascomplexselectionsandqueriesbasedonobjectinformation.
TheMapBasicwindowislimitedtoselectedcommandsfromtheMapBasicprogramminglanguage.The
MapBasicwindowcantakecommandslinebyline.Itdoesnotincludethecapabilityforlooping,
interapplicationcommunication,andothermorecomplexcommands.Ifyoufindyourselfusingthe
MapBasicwindowoften,youmaywanttoconsidertransferringyourcodetoaMapBasicapplicationthat
willautomatetheprocess.
AccessingtheMapBasicWindow
ToaccesstheMapBasicwindow,ontheOptionsmenu,clickShowMapBasicWindow.TheMapBasic
windowdisplaysonyourscreen.Aswithanyotherwindow,youmayresizeitormoveittoanewlocation.
ThewindowallowsyoutoenterMapBasiccodeortoviewMapBasiccodeasitisgeneratedbyMapInfo
Professional.
ToseehowMapInfoProfessionalcarriesoutaselectstatement:
1. OpentheMapBasicwindowandthenopentheWORLDtable.
2. OntheQuerymenu,clickSelect.
3. TypeintheexpressionPop_1994>1000000.MakesurethattheBrowseResultsboxischecked.
4. ClickOK.ThesyntaxforthesecommandsappearsintheMapBasicwindowasfollows:
Open Table "C:\MAPINFO\DATA\WORLD\WORLD.tab" Interactive
Map From World
select * from World where Pop_1994 > 1000000 into Selection
browse * from Selection
ThefirstlineisaresultofopeningtheWORLDtable.Thesecondlineofcodeiswrittenautomatically
becausetheWORLDtabledisplaysinaMapwindowbydefault.Thethirdlineisthesyntaxfortheselect
statement.ThefourthlineistheresultofcheckingtheBrowseresultsbox.
YoucanalsoenterMapBasiccommandsintotheMapBasicwindow.Positionyourcursorunderthe
browsefromSelectionline.Typethefollowing:
Map from Selection
PressEnteraftertheline,andthecommandexecutes.Youshouldseeyourselectiondisplayedina
Mapwindow.
Asstatedbefore,theMapBasicwindowwasprimarilydesignedtoassistMapBasicprogrammers.You
canstatementsandfunctionsintheMapBasicwindowsuchasBuffer()functionorInsertstatement.
RefertotheMapBasicReference,whichislocatedintheDocumentationsubfolderofyourinstallation
directorytofindtheappropriateusageandsyntaxforthesestatementsandfunctions.Itprovidesa
comprehensiveguidetoMapBasicprogrammingstatementsandfunctionsalongwithexamples.
RunningaMapBasicProgram
UseRunintheToolsmenutorunaMapBasicprogram.MapBasicisaprogramminglanguagethatyou
canusetocustomizeorautomateMaplnfoProfessional.TocreateMapBasicapplications,youneed
theMapBasiccompiler,whichisaseparateproduct.However,youdonotneedtheMapBasiccompiler
torunacompletedMapBasicapplication.
MapInfoProfessionalcomeswithanassortmentofcompletedMapBasicapplications.Someexamples
include:
• Symbolapplication(SYMBOL.MBX).Createscustomsymbolshapes.
• ScaleBarapplication(SCALEBAR.MBX).Annotatesamapwithadistancescale.
• NamedViewsapplication(NVIEWS.MBX).Assignsanametothecurrentmapviewandusethatname
toreturntothatviewlater.
447
MapInfoProfessionalUserGuide
Chapter17:SpecializedTopicsinMapInfoProfessional
31
• Overviewapplication(OVERVIEW.MBX).OpensasecondMapwindowthatdisplaysanoverviewof
thecurrentmap(alsoreferredtoasanareadetailmap).
TorunaMapBasicapplication:
1. ChooseTools>RunMapBasicProgram.TheRunMapBasicProgramdialogboxdisplays.
2. Chooseadirectory.
3. Chooseanapplicationfromthelist(MapBasicapplicationshavean.mbxextension).
4. ClickOK.
MapInfoProfessionalthenrunstheMapBasicapplication.
RunningaMapBasicProgramUsingaStartupWorkspace
YoucanuseastartupworkspacetorunaMapBasicapplication.However,youcannotcreatethiskind
ofworkspaceusingSaveWorkspaceAs.WhenyouwanttorunaMapBasicapplicationinyourstartup
workspace,youneedtocreatetheworkspacewithatexteditor.
1. PlacethefollowingintoanASCIIfile:
!workspace
!version 700
run application "someprog.mbx"
2. Replace"Someprog.app"withthenameoftheMapBasicapplicationyouwanttolaunchfromthe
startupworkspace.
3. NamethisfileSTARTUP.WOR.
4. PlacethisfileinyourMapInfoProfessionalprogramdirectoryorinyourhomedirectory.
TheHelpSystemcontainstheseandotherrelatedtopics:
• CopyingtheContentsoftheMapBasicMessagewindow
• IssuingCommandsthroughtheMapBasicwindow
• ExamplesofMapBasicPrograms
• CreatingCirclesaroundPointsusingtheMapBasicwindow
ThereisacomprehensivelistofMapBasicfunctionsandstatementsyoucanusefromthe
MapBasicwindowintheHelpSystem.
Note:
MapInfoProfessional12.5
448
WorkingwiththeMapBasicWindow
23
A
Keyboard Shortcuts
ThissectioncontainsacomprehensivelistoftheshortcutsavailableintheMapInfo
Professionalapplication.Youcancreatecustomshortcutsbyeditingthe
MAPINFOW.MNUfileusingatexteditor.
MakingchangestotheMAPINFOW.MNUfilemaycausethedefault
shortcutsyouchangetostopworking.Makethesechangescarefully
andrecordyourchangessoyoucanchangethemback,ifnecessary.
Caution:
Inthissection:
• ShortcutsforFileMenuItems . . . . . . . . . . . . . . . . . . . . .450
• ShortcutsforEditMenuItems . . . . . . . . . . . . . . . . . . . . .450
• ShortcuttoToolsMenuItems . . . . . . . . . . . . . . . . . . . . .450
• ShortcutstoObjectsMenuItems . . . . . . . . . . . . . . . . . .451
• ShortcutsforQueryMenuItems . . . . . . . . . . . . . . . . . . .451
• ShortcutsforOptionsMenuItems . . . . . . . . . . . . . . . . .451
• Shortcutsfor Map Menu Items . . . . . . . . . . . . . . . . . . . .451
• ShortcutsforWindowMenuItems . . . . . . . . . . . . . . . . .452
• ShortcutsbyKeystroke . . . . . . . . . . . . . . . . . . . . . . . . . .452
• ShortcutsfortheMaporLayoutWindow . . . . . . . . . . . .454
• ShortcutsfortheBrowserWindow . . . . . . . . . . . . . . . . .456
• ShortcutsfortheLegendDesignerWindow . . . . . . . . .459
• Shortcutsfor MapInfoProfessional . . . . . . . . . . . . . . . .461
42
Shortcuts for File Menu Items
Keystrokes
MenuItem
Ctrl+N
File>NewTable
Ctrl+O
File>Open
Ctrl+S
File>SaveTable
Ctrl+K
File>SaveWorkspace
Ctrl+P
File>Print
Alt+F4
File>Exit
Shortcuts for Edit Menu Items
Keystrokes
MenuItem
Ctrl+Z
Edit>Undo
Ctrl+X
Edit>Cut
Ctrl+C
Edit>Copy
Ctrl+V
Edit>Paste
Del
Edit>Clear
Ctrl+R
Edit>Reshape
Ctrl+E
Edit>NewRow
F7
Edit>GetInfo
Shortcut to Tools Menu Items
Keystrokes
MenuItem
Ctrl+U
Tools>RunMapBasicProgram
MapInfoProfessional12.5
450
ShortcutsforFileMenuItems
Documents you may be interested
Documents you may be interested