Spaces & Quotes in Commands

Cool tips, tricks, FAQs, scripts, binds, etc.
Post Reply
Renegade
HLDJ Developer
HLDJ Developer
Posts: 1500
Joined: Sat Mar 01, 2008 2:02 pm
Contact:

Spaces & Quotes in Commands

Post by Renegade »

You may have noticed that in order to use spaces in Half-Life commands and scripting, you require quotes around them. This can be troublesome in the case that multiple quotes are needed because HL does not recognize quotes-within-quotes. Fortunately, with the release of HLDJ v1.2.6 this problem can be circumvented by using the "*' character instead of spaces. Here's an example:
Normally, you might use the following commands to select an audio file name containing spaces:

Code: Select all

bind:"my file name";hldjsf
To make life easier, you may want to bind this to a key or alias:

Code: Select all

bind k "bind:"my file name"; hldjsf"
However, this will not work because HL will not recognize the inner pair of quotes within the outer pair. The solution is to eliminate having to use quotes by replacing the spaces in the file name with the "*" character instead:

Code: Select all

bind k "bind:my*file*name; hldjsf"
This can help out tremendously when making script files that automatically bind keys to your favourite audio files.
Post Reply