home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / PDXOS2-1.ZIP / SAMPLE / KEYBIND.SC < prev    next >
Encoding:
Text File  |  1988-12-29  |  2.6 KB  |  80 lines

  1. ; PAL Program to Prompt User for Key Macro and Append It to His or Her
  2. ; INIT.SC File
  3.  
  4. Reset                           ; Normalize the system
  5. Clear                           ; Clear the screen
  6. @2,33
  7. Style intense
  8. ?? "Keybind Program"
  9. Style
  10. Text
  11.  
  12.  
  13. This program attaches a script to a keystroke.   It also modifies your INIT.SC
  14. script  (or creates INIT.SC if it does not already exist),  so that the script
  15. will  automatically  be  bound  to  the  key  each  time  you  enter  Paradox.
  16.  
  17. Scripts can be bound to Ctrl-[F1 thru F10],  Shift-[F1 thru F10], Alt-[anykey]
  18. (excluding function keys), and many Ctrl-keys.
  19.  
  20. NOTE:  You must currently be connected to your default startup
  21.        directory.   If you are not,  please hit `Esc' to exit.
  22. Endtext
  23.  
  24. ; Get name of script to be bound
  25. goodscript=false
  26. While not goodscript
  27.    @16,3 ?? "Type name of script and press [Enter]: "
  28.    Accept "a70"
  29.       required
  30.    to name
  31.    @22,52 clear eol
  32.    If retval=false                        ; User hit Esc to exit Accept
  33.       then quit "Keybind cancelled"
  34.    Endif
  35.    If search(".sc",name)=0                ; Turn isfile() into isscript()
  36.       then name=name+".sc"
  37.    Endif
  38.    If isfile(name)                        ; Check to make sure script exists
  39.       then goodscript=true
  40.            If isfile(directory()+name)    ; Add directory name in case key is
  41.               then name=directory()+name  ; hit while in a different directory
  42.            Endif
  43.       else message "This script does not exist"
  44.    Endif
  45. Endwhile
  46.  
  47. ; Now strip .sc extension from script name
  48. name = substr(name,1,len(name) - 3);
  49.  
  50. ; Get key to bind script to
  51. goodkey=false
  52. While not goodkey
  53.    @18,3 ?? "Press key to which you want to bind script: "
  54.    key = getchar()
  55.    @22,32 clear eol
  56.    If key=27 or key=0                ; Did the user hit Esc or CTRL-Break?
  57.       then quit "Keybind cancelled"
  58.    Endif
  59.    ; Check for keys which already mean something to Paradox
  60.    If (key>=4 and key<=10) or (key>=16 and key<=19) or (key>=32 and key<=127)
  61.       or (key<=-59 and key>=-83) or (key<=-104 and key>=-119) or key=-15
  62.       or key=12 or key=13 or key=14 or key=22 or key=23 or key=25
  63.       then message "You cannot bind the specified key with Keybind"
  64.       else goodkey=true
  65.    Endif
  66. Endwhile
  67. setline = "Setkey " + strval(key) + " Play " + "\"" + name +"\""
  68.  
  69. ; Transform backslashes
  70. cmdset="" s_end=setline
  71. While match(setline,"..\\..",s_begin,s_end)
  72.    cmdset=cmdset+s_begin+"\\\\"
  73.    setline=s_end
  74. Endwhile
  75. cmdset=cmdset+s_end
  76.  
  77. Print file "INIT.SC" "\n\n"+cmdset
  78. Execute cmdset
  79. Quit "Keybind has been recorded"
  80.