John.Wiley.and.Sons.Rapid.Mobile.Enterprise.Development.for.Symbian.OS.An.Introduction.to.OPL.Application.Design.and.Programming.May.2005.eBook-LinG (779881), страница 39
Текст из файла (страница 39)
Shortcut values mustbe alphabetic character codes or numbers between thevalues of 1 and 32. Any other values will raise an‘Invalid arguments’ error.If any menu item fails to be added successfully, amenu is discarded. It is therefore incorrect to ignoremCARD errors by having an ONERR label around anmCARD call. If you do, the menu is discarded and a‘Structure fault’ will be raised on using mCARD withoutfirst using mINIT again.
See MENU for an exampleof this.See also mCARDX.mCARDXDefines a menu card with graphicUsage: mCARDX BitmapID&, BitmapMaskID&, Item1$,Item1key%, Item2$, Item2Key%The mCARDX keyword is essentially the same asmCARD but with the difference that instead of supplying a string caption for the menu card, you supply abitmap and bitmap mask instead.This above example will add a pane to the menuwith the images in BitmapID& and BitmapMaskID&as its caption. Note that for Series 80 (where thiscommand is normally used), the recommended size forthese bitmaps is 25×20 pixels in 256 colors (i.e.
specifythe/c8 flag when using the BMCONV tool provided onall Symbian OS v6.0 SDKs).See also mCARD.mCASCDefines a menu cascadeOPL COMMAND LIST229Usage: mCASC title$,item1$,hotkey1%,item2$,hotkey2%Creates a cascade for a menu, on which less importantmenu items can be displayed. The cascade must bedefined before use in a menu card. For example, a‘Bitmap’ cascade under the File menu of a possibleOPL drawing application could be defined like this:mCASC "Bitmap","Load",%L,"Merge",%MmCARD "File","New",%n,"Open",%o,"Save",%s,"Bitmap>",16,"Exit",%eThe trailing > character specifies that a previouslydefined cascade item is to be used in the menu at thispoint: it is not displayed in the menu item.
A cascadehas a filled arrow head displayed along side it in themenu. The cascade title in mCASC is also used onlyfor identification purposes and is not displayed in thecascade itself. This title needs to be identical to themenu item text apart from the >. For efficiency, OPLdoesn’t check that a defined cascade has been used ina menu and an unused cascade will simply be ignored.To display a > in a cascaded menu item, you can use .Shortcut keys used in cascades may be added tothe appropriate constant values as for mCARD toenable checkboxes, option buttons, and dimming ofcascade items.As is typical for cascade titles, a shortcut value of16 is used in the example above. This prevents thedisplay or specification of any shortcut key.
However,it is possible to define a shortcut key for a cascade titleif required, for example to cycle through the optionsavailable in a cascade.If more menu items are displayed in a menu card orcascade than are displayable on the screen, the menuwill be drawn with a scroll bar. It is recommended thatprogrammers do not define menus that scroll to keepthe pen actions the user has to make to use the programto a minimum: see Defining the menus.See also mCARD, mCARDX, MENU, mINIT.MEANCalculates a mean valueUsage: m=MEAN(list)orm=MEAN(array(),element)230OPL COMMAND LISTReturns the arithmetic mean (average) of a list ofnumeric items. The list can be either:A list of variables, values, and expressions, separatedby commasorThe elements of a floating point array.When operating on an array, the first argument mustbe the array name followed by ().
The second argument,separated from the first by a comma, is the number ofarray elements you wish to operate on. For example,m=MEAN(arr(),3) would return the average of elementsarr(1), arr(2), and arr(3).This example displays 15.0:a(1)=10a(2)=15a(3)=20PRINT MEAN(a(),3)MENUDisplays a menuUsage: val%=MENUorval%=MENU(var init%)Displays the menus defined by mINIT, mCARD, andmCASC, and waits for you to select an item. Returns theshortcut key keycode of the item selected, as definedin mCARD, in lowercase.If you cancel the menu by pressing Esc, MENUreturns 0.If the name of a variable is passed, it sets the initialmenu pane and item to be highlighted. init% shouldbe 256*(menu%)+item%; for both menu% and item%,0 specifies the first, 1 the second, and so on. If init%is 517 (=256*2+5), for example, this specifies the sixthitem on the third menu.If init% was passed, MENU writes back to init%the value for the item that was last highlighted on themenu.
You can then use this value when calling themenu again.It is necessary to use MENU(init%), passing back thesame variable each time the menu is opened if youwish the menu to reopen with the highlight set on thelast selected item.OPL COMMAND LIST231It is incorrect to ignore mCARD and mCASC errors byhaving an ONERR label around an mCARD or mCASCcall. If you do, the menu is discarded and a ‘Structurefault’ will be raised on using mCARD, mCASC, orMENU without first using mINIT again.The following bad code will not display the menu:REM ** example of bad code **mINITONERR errIgnore1mCARD "Xxx","ItemA",0 REM bad shortcuterrIgnore1::ONERR errIgnore2mCARD "Yyy",""REM ‘Structure fault’ error (mINIT discarded)errIgnore2::ONERR OFFMENUREM ‘Structure fault’ againSee also mCARD, mCASC, mINIT.MID$Gets the middle part of a stringUsage: m$=MID$(a$,x%,y%)Returns a string comprising y% characters of a$, startingat the character at position x%.E.g.
if name$="McConnell" then MID$(name$,3,4)would return the string Conn.MINMinimum valueUsage: m=MIN(list)orm=MIN(array(),element)Returns the smallest of a list of numeric items. The listcan be either:A list of variables, values, and expressions, separatedby commasorThe elements of a floating point array.When operating on an array, the first argument mustbe the array name followed by (). The second argument,separated from the first by a comma, is the number ofarray elements you wish to operate on. For example,232OPL COMMAND LISTm=MIN(arr(),3) would return the minimum of elementsarr(1), arr(2), and arr(3).mINITInitializes menusUsage: mINITPrepares for definition of menus, cancelling any existingmenus.
Use mCARD and mCASC to define each menu,then MENU to display them.It is incorrect to ignore mCARD or mCASC errors byhaving an ONERR label around an mCARD or mCASCcall. If you do, the menu is discarded and a ‘Structurefault’ will be raised if there is an occurrence of mCARD,mCASC, or MENU without first using mINIT again. SeeMENU for an example of this.See also mCARD, mCARDX, mCASC and Menus.MIMEAssociates an OPL application with a MIME typeUsage: MIME pri%, dtype$Associates an OPL application with the Internet MIMEcontent type dtype$, using priority pri%. This commandcan only be used in the scope of an APP...ENDA construct. The priority value specifies how proficient theapplication is at handling the named data type. dtype%is the name of the data type this app is declaring that itcan handle, e.g.
text/html, image/png, or text/plain.Declaring a MIME association indicates to the system that the application allows the user to view ormanipulate files and data of the named type.pri% can take any of the following values:KDataTypePriorityUserSpecified%KDataTypePriorityHigh%KMaxInt%10000reserved for future usethis app is superblycapable of handlinghis data typeKDataTypePriorityNormal%0typical priority. App isproficient at handlingthis data typeKDataTypePriorityLow%−10000app is merely capableof handling thisdocument typeOPL COMMAND LISTKDataTypePriorityLastResort%−20000KDataTypePriorityNotSupported%KMinInt%233app should onlyhandle this data typeif there are no otherapps available thatcan use it–These constants are supplied in Const.oph. Note thatKDataTypePriorityUserSpecified% is reserved for futureuse.The .aif file (application information file) for the appis used to store this information once the app has beentranslated. Only one MIME association is allowed perapplication, so only one MIME statement can be madein an OPL application’s APP...ENDA declaration.There are recognizers in the ROM for the followingMIME types:text/plaintext/htmlimage/jpegimage/giftext/X-vCardtext/X-vCalendarMINUTEGets the current minuteUsage: m%=MINUTEReturns the current minute number from the systemclock (0 to 59).E.g.
at 8.54 a.m. MINUTE returns 54.MKDIRCreates a new folderUsage: MKDIR name$Creates a new folder/directory. For example, MKDIR"C:\MINE\TEMP" creates a C:\MINE\TEMP folder, alsocreating C:\MINE if it is not already there.MODIFYChanges a record without moving itUsage: MODIFYAllows the current record of a view to be modifiedwithout moving the record. The fields can then beassigned to before using PUT or CANCEL.234MONTHOPL COMMAND LISTGets the current monthUsage: m%=MONTHReturns the current month from the system clock as aninteger between 1 and 12.E.g. on 12th March 1992 m%=MONTH returns 3(KMarch%) to m%.MONTH$Converts a numeric month to a stringUsage: m$=MONTH$(x%)Converts x%, a number from 1 to 12, to the monthname, expressed as a three-letter mixed case string.E.g. MONTH$(KJanuary%) returns the string Jan.See MONTH for the month number constants.mPOPUPPresents a popup menuUsage: mPOPUP(x%,y%,posType%,item1$,key1%,item2$,key2%,...)Presents a popup menu.
mPOPUP returns the value ofthe key press used to exit the popup menu, this being 0if Esc is pressed.Note that mPOPUP defines and presents the menuitself, and should not and need not be called frominside the mINIT...MENU structure.posType% is the position type controlling whichcorner of the popup menu x%,y% specifies and cantake the values:KMPopupPosTopLeft%KMPopupPosTopRight%KMPopupPosBottomLeft%KMPopupPosBottomRight%0123top lefttop rightbottom leftbottom rightThese constants are supplied in Const.oph.item$ and key% can take the same values as formCARD, with key% taking the same constant values tospecify checkboxes, option buttons, and dimmed items.However, cascades in popup menus are not supported.For example:mPOPUP (0,0,0,"Continue",%c,"Exit",%e)OPL COMMAND LIST235specifies a popup menu with 0,0 as its top left-handcorner, with the items ‘Continue’ and ‘Exit’, with theshortcut keys Ctrl+C and Ctrl+E, respectively.See also mCARD.NEXTPositions to the next recordUsage: NEXTPositions to the next record in the current data file.If NEXT is used after the end of a file has beenreached, no error is reported but the current record isnull and the EOF function returns true.NUM$Converts a floating point number to a stringUsage: n$=NUM$(x,y%)Returns a string representation of the integer part ofthe floating point number x, rounded to the nearestwhole number.