home *** CD-ROM | disk | FTP | other *** search
/ PSION CD 2 / PsionCDVol2.iso / Programs / 377 / BACKLITE.SIS / macShortcut.opl (.txt) < prev    next >
Encoding:
EPOC OPL Source  |  1998-10-28  |  2.3 KB  |  89 lines

  1.  
  2.  
  3. rem // Backlite+Plus Macro - macShortcut V1.0 by J.Kneen 30/1/98
  4. rem // This macro replaces a typed code with a long text string based on a database file.
  5. rem // The file is a standard EPOC data file and can be edited using Data, or through
  6. rem // the settings dialog (which launches data and waits until finished)
  7.  
  8. rem // With a little work, this macro could form the basis of an address book for the
  9. rem // messaging software.
  10. rem // by linking to an existing database, and only accessing the fields required, you
  11. rem // could type an abbreviation code, and it would be replaced by the email address.
  12.  
  13. PROC macShortcut:
  14.     Local c$(255),l%,a$(255),strfile$(255), d$(255)
  15.  
  16.     rem // Highlight the last word typed.//
  17.     BLSwitchtoCurrent:
  18.     BLKeycommand:("CTRL+LEFT")
  19.     BLKeycommand:("SHIFT+CTRL+RIGHT")
  20.  
  21.     rem // Get the settings for the datafile and copy the selected //
  22.     rem // text into c$ //
  23.     strFile$=BLLoadSetting$:("ShortcutFile")
  24.      c$=BLCopy$:
  25.       
  26.      WHILE RIGHT$(c$,1)=" "
  27.          c$=LEFT$(c$,LEN(c$)-1)
  28.      ENDWH
  29.     
  30.     d$=c$
  31.     
  32.     
  33.     rem // Check for empty file //
  34.         IF strFile$=""
  35.             RETURN
  36.         ENDIF
  37.         
  38.     rem // Open the file and find the code //
  39.     OPEN """"+strfile$+"""",A,field1$,field2$
  40.     FIRST
  41.         WHILE NOT EOF
  42.             IF A.field1$=c$
  43.                 c$=A.field2$
  44.                 BREAK
  45.             ELSE
  46.                 NEXT
  47.             ENDIF
  48.         ENDWH
  49.     CLOSE
  50.  
  51.     rem // Paste the result if it has changed.
  52.     IF d$<>c$
  53.         BLPasteText:(c$)
  54.      ENDIF
  55.      
  56. ENDP
  57.  
  58.  
  59. PROC macShortcutSettings:
  60.     LOCAL d%,strfile$(255)
  61.     
  62.     strFile$=BLLoadSetting$:("ShortcutFile")
  63.         
  64.     rem // Main settings dialog //
  65.     dINIT "Shortcut Macro Settings",16
  66.     dBUTTONS "Data File",%f,"Add/Edit entries",%e,"Close",13
  67.     d%=DIALOG
  68.  
  69.     rem // If Edit, switch to the Database and wait for the user to finish //
  70.  
  71.         IF d%=%e
  72.             BLSwitchto:(strFile$)
  73.             BLWaitforFileExit:("Waiting to exit Shortcut database...")
  74.             BLBacklitetoFront:
  75.     rem // If File,  display a config dialog to select a database.
  76.  
  77.         ELSEIF d%=%f
  78.             dINIT "Database file"
  79.                 dFILE strfile$,"File,Folder,Disk",2
  80.                 dBUTTONS "Cancel",27,"OK",13
  81.                     IF DIALOG=13
  82.                         BLSaveSetting:("ShortcutFile",strfile$)
  83.                     ENDIF
  84.         ENDIF
  85. ENDP
  86.  
  87.  
  88.  
  89.