home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 10
/
Fresh_Fish_10_2352.bin
/
useful
/
util
/
edit
/
mg
/
rexx
/
slashquote
< prev
next >
Wrap
Text File
|
1990-06-02
|
888b
|
35 lines
/*
* slashquote - Take the first char of the second arg (it should be a single
* char anyway, but we be paranoid), and put's that character in front of
* any double-quotes or occurenses of that charater in the string that is
* the first arg, and returns the result with double quotes around it.
*
* Usefull in mg for quoting things to be inserted when called as:
*
* slashquote(string_to_insert, '\')
*
* and for things to issue to a shell if called as:
*
* slashquote(command_argument_to_fix, '*')
*
* There are probably other uses for the silly thing.
*
*/
parse arg in, char
char = left(char, 1)
i = index(in, char)
do while i > 0
in = substr(in, 1, i - 1) || char || char || substr(in, i + 1)
i = index(in, char, i + 2)
end
i = index(in, '"')
do while i > 0
in = substr(in, 1, i - 1) || char'"'substr(in, i + 1)
i = index(in, '"', i + 2)
end
return '"'in'"'