Call Items from the Top Level Menu

Popular in previous forums place your programming snippets here
Post Reply
User avatar
Martin
Global Admin
Posts: 250
Joined: Mon Jan 02, 2023 5:18 pm

Call Items from the Top Level Menu

Post by Martin »

This snippet adapted from Organized Solutions Ltd TRAVEL Pack - TIMERTN.OPL. Examines the Top Level Menu Cell for the 'function' NOTES and if found calls it. When you ON/CLEAR out of Notes you are returned to the OPL Programming line after the 'call'. Try it with CHK: to check it works.

It works just as it would if Notes was selected from the Top Level Menu even with password projected Notepads.

The Technical Reference Manual suggests you 'do not search the main menu for "NOTES" and its address, as its name changes in multi-lingual versions.' With this in mind the routine looks for 'NOTES' English, French and Italian, 'NOTIZ' German, 'NOTAS' Spanish and 'NOTER' Danish.

You can easily adapt this routine to launch any MENU Item by changing IF CH%= to the number of characters in the menu item you are searching for and changing the IF L4$="NOTES" OR L4$="NOTIZ" OR L4$="NOTAS" OR L4$="NOTER" to the different language options of the item you are looking for.

I've call it OpnNotes: you can call it what suits you best.

Code: Select all

OPNNOTES:
LOCAL CH%,AD%,LP%,L4$(5)

REM Modified from Organized Solutions TIMERTN.OPL
REM Martin Reid - January 2024
REM Examines Top Level Menu for NOTES than calls it

REM CH%=Number of Characters in Menu Item
REM AD%=PEEKS Menu Address
REM LP%=LOOP 1 to 6
REM L4$=Stores Menu Item for comparison (5 Characters)

AD%=PEEKW(8194)       :REM (9869) $2002 Top Level Menu

CURSOR OFF

DO
 CH%=PEEKB(AD%)       :REM 9869=4 ETC..
 IF CH%=0
  RETURN 1            :REM IF 1 then not found
 ENDIF
 IF CH%=5             :REM 5 letter menu items
  L4$=""
  LP%=1
  DO
   L4$=L4$+CHR$(PEEKB(AD%+LP%))
   LP%=LP%+1
  UNTIL LP%=6
  IF L4$="NOTES" OR L4$="NOTIZ" OR L4$="NOTAS" OR L4$="NOTER"
   USR(PEEKW(AD%+CH%+1),0)
   CLS
   RETURN
  ENDIF
 ENDIF
 AD%=AD%+CH%+3        :REM eg.. 9869+4+3 = 9876
UNTIL 0               :REM Careful infinate loop
CHK: is a simple menu option to help check OpnNotes works as expected before you integrate it into your programs

Code: Select all

CHK:
LOCAL M%
DO
PRINT "Test menu call"
 M%=MENUN(2,"QUIT,NOTES,DIARY")
     IF M%=1 :PRINT "QUIT"
 ELSEIF M%=2 :OpnNotes:
 ELSEIF M%=3 :REM another item
 ENDIF
UNTIL M%<=1
Why bother
Without exiting your program which might mean closing files ext; It might useful to be able to use Notes, Diary, Utils (Dir, Info etc..) even xFiles as long as you remember to close any files before you go there to work on them.

Sincerely
Martin

PS I'd be interested to hear from anyone that tries it..
User avatar
Martin
Global Admin
Posts: 250
Joined: Mon Jan 02, 2023 5:18 pm

Call Items from the Top Level Menu - SOLVED

Post by Martin »

I've included a 'routine' like this... works a treat... thanks to those that contributed

Code: Select all

 M%=MENUN(2,"Back,Diary,Notes,xFiles,Save,Utils,Find,Quit,Off")
     IF M%<2 :RETURN :REM ON/CLEAR & Back 
 ELSEIF M%=2 :GOTO MNDiary::
 ELSEIF M%=3 :GOTO MNNotes::
 ELSEIF M%=4 :GOTO MNxFiles::
 ELSEIF M%=5 :GOTO MNSave::
 ELSEIF M%=6 :GOTO MNUtils::
 ELSEIF M%=7 :GOTO MNFind::
 ELSEIF M%=8 :MNEND:
 ELSEIF M%=9 :OFF
 ENDIF
UNTIL M%=-1

MNDiary::
A%(1)=$C601 :REM 1=Week, 3=Month
A%(2)=$3FA7
A%(3)=$3901
USR(ADDR(A%()),0)
CLS
GOTO TOP::

MNNotes::
A%(1)=$C601
A%(2)=$3F9F
A%(3)=$3901
USR(ADDR(A%()),0)
CLS
GOTO TOP::

MNxFiles::
A%(1)=$C601 :REM 1=xFiles, 4=Find, 5=Save
A%(2)=$3FA8
A%(3)=$3901
USR(ADDR(A%()),0)
CLS
GOTO TOP::

MNSave::
A%(1)=$C605 :REM 1=xFiles, 4=Find, 5=Save
A%(2)=$3FA8
A%(3)=$3901
USR(ADDR(A%()),0)
CLS
GOTO TOP::

MNUtils::
A%(1)=$C601 :REM 1=Utils, 3=Info, 9=Dir
A%(2)=$3FA1
A%(3)=$3901
USR(ADDR(A%()),0)
CLS
GOTO TOP::
Post Reply