ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How do you define a constant that contains a single quote???

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do you define a constant that contains a single quote???

    ]I'm pullin' my freekin hair out here... writing an RPG pgm to run a command.
    The command parms have single quotes around literal values.
    I need to have the same single quotes around a variable.
    I'm trying to define the constant "doclist" to contain the single quotes necssary
    when executing the command. I need to do the same for the character variable "pfldr".

    Why is this so difficult??

    Also as an aside, if someone could tell me what i'm doing wrong with the procedure interface....
    i would like to have the "plfdr" parameter be a variable length field instead of fixed.

    Here is my code:
    PHP Code:
    Fifs_list  if   e             disk    rename(ifs_list:ifs_lstr)             
     *                                                                          
     * 
    PARAMETER LIST                                                           
     *                                                                          
    D EntryParms      pr                  extpgm('IFS001')                      
    D  pfldr                        80a   Const                                 
    D  pfile                        10a   Const                                 
    D EntryParms      pi                                                        
    D  pfldr                        80a   
    Const                                 
    D  pfile                        10a   Const                                 
     *                                                                          
    D doclist         c                   const('/qsys.lib/hhpifsrc.lib/ifs_+     
    D                                     list.file/ifs_list.mbr'
    )                
     *                                                                            
    D qcmdexc         pr                  extpgm('QCMDEXC')                       
    D  cmd                        3000a   const options(*varsize)                 
    D  cmdlen                       15p 5 const                                   
     *                                                                            
    D cmdstring       s            512a                                           
     
    *                                                                            
     *---------------------------------------------                               
     **                 
    M A I N                                                   
     
    *---------------------------------------------                               
                                                                                  
     /
    free                                                                        
                                                                                  
      cmdstring 
    'cfghttpsch option(*crtdocl) doclist(' doclist ') ' +             
             
    'strdir(' + %trim(pfldr) + ') subtree(*none) pattern(''*'')';  
                                                                            
      
    qcmdexc(cmdstring:%len(cmdstring));                                                                           
    -------------------------------------------------------------------- 

  • #2
    Re: How do you define a constant that contains a single quote???

    PHP Code:
    d Q               s              1    inz('''')   

         
    //                                                      
         // STRPCCCMD PCCMD('START www.midrangecomputing.com')   
         //                                                      
             
    cmdstring 'STRPCCMD PCCMD(' +                 
                         
    'START http://'   +                     
                         %
    trim(C2WEBPAGE) +                      
                         
    '/' +                               
                         
    ') PAUSE(*NO) ';                        
                                                                 
             
    cmdlength = %len(%trim(cmdstring));                 
             
    monitor;                                            
              
    $command(cmdstring:cmdlength);                     
             
    on-error;                                           
             
    endmon
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: How do you define a constant that contains a single quote???

      You're kidding right? I saw that in someone else's code... I can't believe the compiler doesn't account for that situation.

      Also - why is the code window in my post so narrow (your reply is as well)... makes it unreadable.

      Comment


      • #4
        Re: How do you define a constant that contains a single quote???

        Im working on it.
        All my answers were extracted from the "Big Dummy's Guide to the As400"
        and I take no responsibility for any of them.

        www.code400.com

        Comment


        • #5
          Re: How do you define a constant that contains a single quote???

          Originally posted by gwilburn View Post
          You're kidding right? I saw that in someone else's code... I can't believe the compiler doesn't account for that situation..
          Yea, its been that way since maybe the S38 days. I wish there was a more elegant way to do it. I hit it a lot dealing with HTML code. It can make you go blind and lose your mind.
          Michael Catalani
          IS Director, eCommerce & Web Development
          Acceptance Insurance Corporation
          www.AcceptanceInsurance.com
          www.ProvatoSys.com

          Comment


          • #6
            Re: How do you define a constant that contains a single quote???

            maybe i'm a glutton for punishment but i just embed the quotes when buildling the string vs using a named constant
            I'm not anti-social, I just don't like people -Tommy Holden

            Comment


            • #7
              Re: How do you define a constant that contains a single quote???

              Originally posted by MichaelCatalani View Post
              I hit it a lot dealing with HTML code.
              HTML code uses double quotes rather than singles which you don't need to escape.
              Ben

              Comment


              • #8
                Re: How do you define a constant that contains a single quote???

                Thanks Jamie - i have it working now. If you start new lines at the right place in /free it isn't so bad.

                Comment


                • #9
                  Re: How do you define a constant that contains a single quote???

                  Originally posted by BenThurley View Post
                  HTML code uses double quotes rather than singles which you don't need to escape.
                  Unfortunately, it can use both. And really unfortunate that single quotes are usually parked near a double quote at that.
                  Michael Catalani
                  IS Director, eCommerce & Web Development
                  Acceptance Insurance Corporation
                  www.AcceptanceInsurance.com
                  www.ProvatoSys.com

                  Comment


                  • #10
                    Re: How do you define a constant that contains a single quote???

                    Ok, so most browsers will let you get away with using single quotes. However, if you are using an XHTML doctype then your code won't validate unless you use double quotes. XHTML code should validate as plain XML against an XHTML schema. XML of course requires double quotes for attributes. You can try for yourself using the online validator.

                    W3C's easy-to-use markup validation service, based on SGML and XML parsers.


                    Most browsers will actually let you off the hook but that doesn't mean they won't get stricter in the future. It leaves you open to bugs because the code is technically wrong and could be misinterpreted. If you're still using an old HTML doctype, or worse still no doctype, then perhaps you should take a look at XHTML. It's been a standard for ten years now!
                    Ben

                    Comment


                    • #11
                      Re: How do you define a constant that contains a single quote???

                      Most browsers will actually let you off the hook but that doesn't mean they won't get stricter in the future. It leaves you open to bugs because the code is technically wrong and could be misinterpreted. If you're still using an old HTML doctype, or worse still no doctype, then perhaps you should take a look at XHTML. It's been a standard for ten years now!
                      Yes, I know. The problem is the type of browsers that hit a web site, which was out of my control when a lot of this was first written. You can either tell someone browsing a site that their browser is incompatible, or you can make it work for them. I simply chose the latter. This isn't new development. This is existing stuff that I make changes to. It should be going the way of the DoDo bird really soon. (I hope)
                      Michael Catalani
                      IS Director, eCommerce & Web Development
                      Acceptance Insurance Corporation
                      www.AcceptanceInsurance.com
                      www.ProvatoSys.com

                      Comment

                      Working...
                      X