Results 1 to 4 of 4
  1. #1
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Ampersand Issues (2000)

    Not sure if this is the appropriate forum for this query, but here goes anyway. Perusing the lounge, I found numerous messages regarding problems using the "&" ampersand character in various contexts - folder names, dialog labels,...

    I'm hoping somebody can detail the issues/ contexts associated with these problems, and the "workarounds" that can be implemented to overcome them. And are there any other "problem" characters?

    thanks

    Alan

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Ampersand Issues (2000)

    Actually I don't think there's a master list on this. Your message made me think of the following unrelated issues:

    File names: depends on the operating system -- and the application (in URLs it could be a big issue even if the OS doesn't care what you name the file).

    Dialog labels: if &x is used to mean that x should appear underlined and operate as the "accelerator" (Alt+x shortcut) key for that control, then the & will not appear and you must using something like && to make it appear.

    Another one came to mind later: The character often is used to identify a special code, so where you want a character rather than a special code, in those contexts, you double it (). Examples include Word field codes, wildcard find & replace, and I think some parts of JavaScript (I forget which ones).

  3. #3
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Ampersand Issues (2000)

    In BATch files there are a number of characters which can cause problems to the unwary:
    & separates two commands on the same line
    " is used for filenames and other strings containing spaces
    ^ carat (or occasionally in TechNet "carrot"!!!) is used as an escape character (as, for example, in PKZIP -ex^& A:ZIPPED *.* for spanning diskettes)
    / sometimes needs to be doubled, as a target in the FIND utility
    % is used as a variable prefix, as in %0, %1, %2 ... %9, and %*, or %%a, %%b, etc
    | is used as the 'pipe' character
    < is used to indicate an input file follows in a command
    > is used to indicate that an output file follows

    And when you start going into double characters, well, there are &&, ||, >>, %% (as above), and so on. There are many pairs of special characters (+=, -=, etc) used in SET /A (arithmetic processing, see SET /? for more information).

    Basically, there is a whole raft of ways to come unstuck!
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  4. #4
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Ampersand Issues (2000)

    Thanks to both Jefferson & John... or should I say Jefferson && John? <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    This seems to cover most of what I've heard about. That use of the carat in an escaped character sequence is a new one on me. The one to remember for VBA etc. seems to be the double ampersand trick.

    thanks chaps

    Alan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •