Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch.nt    |    Fun with Windows NT batch files    |    68,980 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 66,980 of 68,980    |
|    probyn@berkeley.edu to Tom Del Rosso    |
|    Re: Poison characters in substring subst    |
|    16 Jul 17 22:30:08    |
      On Sunday, July 16, 2017 at 12:02:07 PM UTC-7, Tom Del Rosso wrote:       > probyn@berkeley.edu wrote:       > > On Sunday, July 16, 2017 at 9:50:11 AM UTC-7, Tom Del Rosso wrote:       > >> Trying to change "%20" in a url into a space.       > >>       > >> Tried various forms including these, and none work.       > >>       > >> set "url=%url:%20= %"       > >>       > >> ...or...       > >>       > >> call set "url=%url:%%20= %"       > >>       > >> ...or other forms.       > >>       > >> I though delayed expansion would work as a last resort, but that       > >> fails too.       > >>       > >>       > >> --       > >       > > Delayed expansion works for me:       > >       > >> set url=xxx%20yyy       > >       > >> set url       > > url=xxx%20yyy       > >       > >> set url=!url:%20= !       > >       > >> set url       > > url=xxx yyy       >       > I'm guessing that you tested that at the command line, because of the >       > prompts and because in a batch you need to double %% in places. I still       > can't find a form that works in a batch. I prefer not to use delayed       > expansion, if possible, because then ! is a poison character too. There       > should be a way to do it with CALL.              Yes, my example consisted of some commands typed at the CMD prompt. In this       case, the '%' in '%20' is just another character and doesn't need to be       'doubled because it is in a batch file'.              Long ago I got so annoyed by the 'poison' chars that I created a Wylbur-like       environment in which anything that might involve those pesky 'poison' chars       is simply done in hex. So I can do the following:               end,xxx%20yyy        change "%20" to " " in 1        read string url using 1                     In this example,               the 'end' command writes whatever follows the ',' to the end of the        active file (if there is no file, then it writes to line 1)               the 'change' command first converts line 1 to hex and its arguments        to hex; then it changes the hex equivalents of its arguments;        then it converts the changed line 1 back to ascii               the 'read' command reads ascii line 1 and assigns its value to 'url'                     In a batch file, these commands can each be called, like this:               call end,xxx%20yyy        call change ...        call read string ...                     But this is overkill for the simple thing you are attempting to do. It works       for me because I'm doing all kinds of things where the 'poison' chars just kept       causing too many headaches (Wylbur doesn't have 'poison' chars).              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca