home *** CD-ROM | disk | FTP | other *** search
- ; PAL Program to Prompt User for Key Macro and Append It to His or Her
- ; INIT.SC File
-
- Reset ; Normalize the system
- Clear ; Clear the screen
- @2,33
- Style intense
- ?? "Keybind Program"
- Style
- Text
-
-
- This program attaches a script to a keystroke. It also modifies your INIT.SC
- script (or creates INIT.SC if it does not already exist), so that the script
- will automatically be bound to the key each time you enter Paradox.
-
- Scripts can be bound to Ctrl-[F1 thru F10], Shift-[F1 thru F10], Alt-[anykey]
- (excluding function keys), and many Ctrl-keys.
-
- NOTE: You must currently be connected to your default startup
- directory. If you are not, please hit `Esc' to exit.
- Endtext
-
- ; Get name of script to be bound
- goodscript=false
- While not goodscript
- @16,3 ?? "Type name of script and press [Enter]: "
- Accept "a70"
- required
- to name
- @22,52 clear eol
- If retval=false ; User hit Esc to exit Accept
- then quit "Keybind cancelled"
- Endif
- If search(".sc",name)=0 ; Turn isfile() into isscript()
- then name=name+".sc"
- Endif
- If isfile(name) ; Check to make sure script exists
- then goodscript=true
- If isfile(directory()+name) ; Add directory name in case key is
- then name=directory()+name ; hit while in a different directory
- Endif
- else message "This script does not exist"
- Endif
- Endwhile
-
- ; Now strip .sc extension from script name
- name = substr(name,1,len(name) - 3);
-
- ; Get key to bind script to
- goodkey=false
- While not goodkey
- @18,3 ?? "Press key to which you want to bind script: "
- key = getchar()
- @22,32 clear eol
- If key=27 or key=0 ; Did the user hit Esc or CTRL-Break?
- then quit "Keybind cancelled"
- Endif
- ; Check for keys which already mean something to Paradox
- If (key>=4 and key<=10) or (key>=16 and key<=19) or (key>=32 and key<=127)
- or (key<=-59 and key>=-83) or (key<=-104 and key>=-119) or key=-15
- or key=12 or key=13 or key=14 or key=22 or key=23 or key=25
- then message "You cannot bind the specified key with Keybind"
- else goodkey=true
- Endif
- Endwhile
- setline = "Setkey " + strval(key) + " Play " + "\"" + name +"\""
-
- ; Transform backslashes
- cmdset="" s_end=setline
- While match(setline,"..\\..",s_begin,s_end)
- cmdset=cmdset+s_begin+"\\\\"
- setline=s_end
- Endwhile
- cmdset=cmdset+s_end
-
- Print file "INIT.SC" "\n\n"+cmdset
- Execute cmdset
- Quit "Keybind has been recorded"