Loading ...
Sorry, an error occurred while loading the content.

Printing to file

Expand Messages
  • carlottagp
    I am getting syntax error when I try to print two expressions to a file; the Help menu seems to have nothing on this subject. I m trying to print two
    Message 1 of 4 , May 31, 2007
    • 0 Attachment
      I am getting "syntax error" when I try to
      print two expressions to a file; the Help
      menu seems to have nothing on this subject.

      I'm trying to print two variables to a file, thus:

      print #1 using("###.## ###.##"),G(N),H(N)

      I've tried semicolons,commas, etc. after the
      "print", with no success.

      Can someone advise me?

      Thanks,

      Michael
    • Bill Lopez
      It s not necessary that you actually assign variables as I ve done here, you could be getting the values from any where in your program. The reason you are
      Message 2 of 4 , May 31, 2007
      • 0 Attachment
        It's not necessary that you actually assign variables as I've done here, you could be getting the values from any where in your program. The reason you are having a syntax error is you are trying to print two values with a single function. I separated them with a double-space here, but you could use any method you like.

        [code]
        G(N)=123.45
        H(N)=345.67

        PRINT USING("###.##", G(N));" "; USING("###.##", H(N))

        END
        [/code]

        It's sort of a "roll your own" formatting.

        [Non-text portions of this message have been removed]
      • gordo999@isp.com
        I m not aware that LB accepts two variables in the same format expression. Here are a couple of functions I use all the time that really help automate things.
        Message 3 of 4 , May 31, 2007
        • 0 Attachment
          I'm not aware that LB accepts two variables in the same format expression.
          Here are a couple of functions I use all the time that really help
          automate things. The first performs accurate rounding of a number to a
          specified number of decimal spaces. It is:

          Function Roundnumb(x,decimaldigits,y)
          xabs=abs(x)
          xabsint=int(xabs)
          xabsfract=xabs-xabsint
          xfk=xabsfract*(10^decimaldigits)+0.5
          xfk=int(xfk)/(10^decimaldigits)
          y=xabsint+xfk
          if x<=0 then y=y*(-1)
          Roundnumb=y
          end function

          The second function automatically makes a template string to accomodate
          the actual digits in a number that have been specified to display. It is:

          Function Template$(decimaldigits,ttt$) 'This function sets the number of
          decimal places to display even if they are zero(s) at the end
          Template$="##########"
          if decimaldigits>0 then Template$=Template$+"."
          for k=1 to decimaldigits
          Template$=Template$+"#"
          next
          end function

          Maybe these will help.




          > I am getting "syntax error" when I try to
          > print two expressions to a file; the Help
          > menu seems to have nothing on this subject.
          >
          > I'm trying to print two variables to a file, thus:
          >
          > print #1 using("###.## ###.##"),G(N),H(N)
          >
          > I've tried semicolons,commas, etc. after the
          > "print", with no success.
          >
          > Can someone advise me?
          >
          > Thanks,
          >
          > Michael
          >
          >
          >
          >



          -----------------------------------------
          Join ISP.COM today - $8.95 internet , less than 1/2 the cost of AOL
          Try us out, http://www.isp.com/
        • Stefan Pendl
          ... You must use a comma after the handle, if you use PRINT. The correct form is: print #1, using( ###.## ,G(N)); ;using( ###.## ,H(N)) You can use USING()
          Message 4 of 4 , Jun 4 4:43 PM
          • 0 Attachment
            >
            > I am getting "syntax error" when I try to print two
            > expressions to a file; the Help menu seems to have nothing on
            > this subject.
            >
            > I'm trying to print two variables to a file, thus:
            >
            > print #1 using("###.## ###.##"),G(N),H(N)
            >
            > I've tried semicolons,commas, etc. after the "print", with no success.
            >

            You must use a comma after the handle, if you use PRINT.

            The correct form is:
            print #1, using("###.##",G(N));" ";using("###.##",H(N))

            You can use USING() only for one numerical expression.

            ---
            Stefan Pendl
          Your message has been successfully submitted and would be delivered to recipients shortly.