Announcement

Collapse
No announcement yet.

Quote marks in PRINT statements

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

  • Quote marks in PRINT statements

    Hi
    Is there some way to put quote marks in PRINT statements. When I
    programmed in PLI or FORTRAN by putting "" in a PRINT statement
    would put quote marks in the OUTPUT statement. ei:
    PRINT "I said, ""I Love you"", would produce: I said, "I Love you".


    ------------------

  • #2
    Originally posted by Fred Katzel:
    Hi
    Is there some way to put quote marks in PRINT statements.
    What about CHR$(34)?
    Code:
    PRINT CHR$(34);"I love you";CHR$(34)
    Another option maybe to use WRITE instead of PRINT.



    ------------------
    mailto:[email protected][email protected]</A>
    http://zijlema.basicguru.com

    Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
    http://zijlema.basicguru.eu
    *** Opinions expressed here are not necessarily untrue ***

    Comment


    • #3
      Fred, your code works fine in the Windows compilers, although there
      should be three quotes on the end. PB/DOS, hmmm...

      ------------------
      Tom Hanlin
      PowerBASIC Staff

      Comment


      • #4
        Originally posted by Fred Katzel:
        Hi
        Is there some way to put quote marks in PRINT statements. When I
        programmed in PLI or FORTRAN by putting "" in a PRINT statement
        would put quote marks in the OUTPUT statement. ei:
        PRINT "I said, ""I Love you"", would produce: I said, "I Love you".


        Hi Fred,

        After using CHR$(34) for a long time (PBDOS) for imbedding quotes
        I opted to Dimension the variable "Q" as a string and list it as
        a global variable in a PUBLIC starement (so units/libs can use).

        Then PRINT Q;"Hello there";Q

        An even greater benefit is that if I want to shell to DOS and use
        long file names, I can concatenate the Q variable with my path:

        DIM Q AS STRING 'give it a name
        PUBLIC Q 'for units/libs
        Q = CHR$(34) 'set the string

        Qpath$ = Q + "C:\My directory\afile.txt" + Q 'embed quotes
        SHELL "if exist " + Qpath$ + " echo it's there" 'use in command

        This allows you to create LFN files and directories from PBDOS.
        Only real advantage over CHR$(34) is brevity & readability.

        ------------------


        [This message has been edited by Leon Stennett (edited August 04, 2002).]

        Comment


        • #5
          Code:
          FUNCTION quote$(inString$)
            FUNCTION=chr$(34)+inString$+chr$(34)
          END FUNCTION
          ------------------
          Amos
          mailto:a.m.o[email protected][email protected]</A>

          Comment


          • #6
            Here's a good area for a request for future versions.
            How about C style escape sequences, such as:

            print "The lady said, \"How's it going?\"\n"


            ------------------

            Comment


            • #7
              It would be much more likely we'd use the same method supported by PB/CC and PB/Win:
              Code:
              A$ = "Clearing his throat, he muttered a sharp ""Hello!"", then scuttled back into his cave."
              ------------------
              Lance
              PowerBASIC Support
              mailto:[email protected][email protected]</A>
              Lance
              mailto:[email protected]

              Comment

              Working...
              X