home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epm603b.zip / EPMMAC2.ZIP / JOT.E < prev    next >
Text File  |  1994-06-21  |  6KB  |  134 lines

  1. ; This is a Toolbar Actions file.  You add a line to your ACTIONS.LST:
  2. ;    jot
  3. ; to indicate that this should be invoked to build the list of defined
  4. ; actions when the user asks for a list (by selecting Create or Edit
  5. ; from the toolbar pop-up menu and clicking on the drop-down arrow
  6. ; on the Actions page).  EPM loads this .ex file and executes the
  7. ; command JOT_ACTIONLIST (it appends "_ACTIONLIST" to the name of the
  8. ; .ex file).  This command must be defined by the actions file to add
  9. ; a line to a file for each toolbar-definable action defined in the .ex
  10. ; file.  (This file only defines a single action.)
  11.  
  12. ; The line consists of the command to be executed, a description of the
  13. ; action, and the name of the .ex file, each separated by a delimiter
  14. ; (which is the first character on the line, and can be any character
  15. ; otherwise unused on that line; below, a period is used throughout).
  16.  
  17. ; The action command (below, "jot_a_note") may be called with a parameter
  18. ; of "I" to indicate that the menu has been initialized (the user pressed
  19. ; MB1 down over the toolbar item, or pressed MB1 down over another toolbar
  20. ; item and dragged the mouse over this item, or pressed F10 to go to the
  21. ; action bar and scrolled to this toolbar item), "E" for a menu-end message,
  22. ; "H" for Help (user pressed F1), or "S" to indicate that the toolbar item
  23. ; has been selected.  The parameter might be followed by command parameters
  24. ; if the user entered any in the Parameters field of the Actions page.
  25.  
  26. ; Now, the executable portions of the file.  First, include some files to
  27. ; define constants that will be needed:
  28.  
  29. include 'stdconst.e'
  30. include 'english.e'
  31.  
  32. ; Next, define some additional text constants (defined as separate constants
  33. ; instead of using the strings where needed in order to allow for easier NLS
  34. ; translation).
  35.  
  36. const
  37.    JOT__MSG = 'Jot'
  38.    JOT_PROMPT = 'Jot a line of text to a note file.'
  39.    JOT_PROMPT__MSG = 'Enter text to jot, or filename for Change File'
  40.    CHANGE_FILE__MSG = 'Change file'
  41.    EDIT_FILE__MSG = 'Edit file'
  42.  
  43. ; Here is the <file_name>_ACTIONLIST command that adds the action command
  44. ; to the list.
  45.  
  46. defc jot_actionlist
  47. universal ActionsList_FileID  -- This is the fileid that gets the line(s)
  48.  
  49. insertline '|jot_a_note|'JOT_PROMPT'|jot|', ActionsList_FileID.last+1, ActionsList_FileID
  50.  
  51. ; This is the command that will be called for the above action.  It
  52. ; doesn't expect parameters, so the argument is not parsed.
  53.  
  54. defc jot_a_note
  55.    if arg(1) = 'S' then       -- button Selected
  56.       sayerror 0
  57.       'jot'
  58.    elseif arg(1) = 'I' then   -- button Initialized
  59.       display -8
  60.       sayerror JOT_PROMPT
  61.       display 8
  62.    elseif arg(1) = 'H' then   -- button Help
  63. ;     'compiler_help_add jot.hlp'      -- Sample code; no .hlp file is
  64. ;     'helpmenu 32100'                 -- provided for JOT.
  65.                                        -- Instead, we'll just pop a messagebox containing the prompt.
  66.       call winmessagebox(JOT__MSG, JOT_PROMPT, MB_OK + MB_INFORMATION + MB_MOVEABLE)
  67.    elseif arg(1) = 'E' then   -- button End
  68. ;;    sayerror 0
  69.    endif
  70.  
  71. ; the Jot command is defined separately, but it could have been included
  72. ; under the 'S' case in the actions command.
  73.  
  74. defc jot
  75.    universal appname, app_hini
  76.    jotfile = queryprofile(app_hini, appname, 'JotFile')
  77.    if jotfile='' then
  78.       inifile = queryprofile(0, appname, 'EPMIniPath')
  79.       jotfile = leftstr(inifile, lastpos('\', inifile)) || 'jot.not'
  80.       if leftstr(jotfile,1)='\' then  -- relative to boot drive
  81. compile if EVERSION >= 6
  82.          drivenum = 1234
  83.          call dynalink32('DOSCALLS',          -- dynamic link library name
  84.                          '#348',              -- ordinal for DOS32QuerySysInfo
  85.                          atol(5)          ||  -- Start index (QSV_BOOT_DRIVE)
  86.                          atol(5)          ||  -- End index (QSV_BOOT_DRIVE)
  87.                          address(drivenum)||  -- buffer
  88.                          atol(4),2)           -- Buffer length
  89.          jotfile = chr(96+ltoa(drivenum, 10))':'jotfile
  90. compile else
  91.          globalseg = 12
  92.          localseg = 12
  93.  
  94.          call dynalink('DOSCALLS',             -- dynamic link library name
  95.                        '#8',                   -- ordinal value for DosGetInfoSeg
  96.                        selector(globalseg) ||  -- string selector
  97.                        offset(globalseg)   ||  -- string offset
  98.                        selector(localseg)  ||  -- string selector
  99.                        offset(localseg) )      -- string offset
  100.  
  101.          globalseg=itoa(globalseg,10)
  102.          jotfile = chr(96+itoa(peek(globalseg,36,2), 10))':'jotfile
  103. compile endif
  104.       endif
  105.    endif
  106.  
  107.    parse value entrybox(JOT__MSG '-' jotfile,'/'OK__MSG'/'CHANGE_FILE__MSG'/'EDIT_FILE__MSG'/'Cancel__MSG'/'Help__MSG'/',\0,'',1590,
  108.           atoi(1) || atoi(0) || atol(0) ||
  109.           JOT_PROMPT__MSG) with button 2 rest \0
  110.    if button = \1 then       -- OK; write note to file
  111.       jotfile = jotfile\0
  112.       rest = rest\13\10\0
  113.       call windowmessage(1,  getpminfo(EPMINFO_EDITCLIENT),
  114. compile if EVERSION >= 5.60
  115.                          5495,               -- EPM_EDIT_LOGERROR
  116. compile else
  117.                          5452,               -- EPM_EDIT_LOGERROR
  118. compile endif
  119.                          ltoa(offset(jotfile) || selector(jotfile), 10),
  120.                          ltoa(offset(rest) || selector(rest), 10) )
  121.    elseif button = \2 then   -- Change file
  122.       if rest='' then
  123.          sayerror 'New name not entered, nothing changed.'
  124.       else
  125.          call setprofile(app_hini, appname, 'JotFile', rest)
  126.          sayerror 'Jot file changed to "'rest'"'
  127.       endif
  128.    elseif button = \3 then   -- Edit file
  129.       'e' jotfile
  130.    endif
  131.  
  132.  
  133. EA_comment 'This defines the JOT command; it can be linked, or can be executed directly.  This is also a toolbar "actions" file.'
  134.