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

print from texteditor

Expand Messages
  • sharpdj5927
    Thanks to a suggestion from Bill Lopez I have made a general purpose routine to simulate print (tab() or lprint tab() to a texteditor window to avoid having
    Message 1 of 3 , Jan 30, 2011
    • 0 Attachment
      Thanks to a suggestion from Bill Lopez I have made a general purpose routine to simulate print (tab() or lprint tab() to a texteditor window to avoid having mainwin open all the time for printing and lprinting using tab().

      So far its all on screen. I want to print to hard copy as an option. I could either repeat all the code over again with lprint instead of print, or copy and paste the contents of texteditor into Notepad. I have included a "Print" button below the texteditor window as I am hoping to figure a way to cut out the copy and paste into Notepad.

      Any suggestions for the code to run from the print button?

      working example of code below.... (sorry its a bit old school but its a very long time ago I started on Qbasic).

      Thanks & regards, Derek Sharp


      dim d$(100),t(100),proom(100),w$(100),t$(100)

      nomainwin


      WindowWidth = 800
      WindowHeight = 600


      TexteditorColor$ = "white"
      texteditor #main.textbox1, 50, 50, 700, 400
      button #main.button2,"PRINT",[goPrint], UL, 280, 480, 90, 35
      button #main.button3,"EXIT",[quit],UL, 420,480,90,35

      open "untitled" for window as #main
      print #main, "font arial_bold 12"
      print #main.textbox1,"!font courier_new 9"
      print #main, "trapclose [quit]"

      [headerLine1]
      data "SUMMER SHOW","Prizes","Prize","Points","Flowers"
      data "Flowers Veg","Veg &","Total"
      tabdata$="4,23,32,41,50,61,77,87"
      restore [headerLine1]
      for x=1 to 8:read d$:d$(x)=d$:next
      gosub [printTab]

      [headerLine2]
      data "RESULTS"," ","ADULTS","Money","Bethel",
      data " & Fruit","Fruit","Prize"
      tabdata$="1,9,14,32,50,62,77,87,"
      restore [headerLine2]
      for x=1 to 8 :read d$:d$(x)=d$:next
      d$(2)="2011" 'year$ in full program
      gosub [printTab]

      [headerline3]
      data "Mason",Clayton,"Money"
      tabdata$="64,76,87"
      restore [headerline3]
      for x=1 to 3 :read d$:d$(x)=d$:next
      gosub [printTab]

      sname$="Fred Davidson" ' simulates a gettrim,rec from #file handle
      snoprizes$="6"
      sprizemoney$="6.70"
      snopoints$="12"
      bethel$="4"
      mason$=""
      clayton$="7"

      d$(1)=sname$ ' put the data into an array
      d$(2)=snoprizes$
      d$(3)="£"+using("##.##",val(sprizemoney$))
      d$(4)=snopoints$
      d$(5)=bethel$
      d$(6)=mason$
      d$(7)=clayton$
      tabdata$="1,26,32,44,53,65,80" ' put the tab() data in a string
      gosub [printTab]

      wait

      [quit]
      close #main
      end


      [printTab]'------------------------- gosub routine
      ' subroutine to simulate print tab()

      'entry parameters: stuff to print in array d$(), tab data in tabdata$
      ' tabs in tabdata£() seperated by commas the first item to print
      ' must be givem a tab() even if it is at the start of
      ' the line in which case its is tab value 1

      stringToPrint$=""

      for x=1 to 100 'zero out t$() in case of previous use
      t$(x)=""
      next x

      for x= 1 to len(tabdata$) 'chop up tabdata$
      w$(x)=mid$(tabdata$,x,1)
      next x

      z=1
      for x=1 to len(tabdata$) 'get tab values seperated by commas
      if w$(x)<>"," then t$(z)=t$(z)+w$(x) ' and place in array t$()
      if w$(x)="," then z=z+1
      next x

      arraysize=z

      for x=1 to arraysize ' make tab date in t$() numeric in t()
      t(x)=val(t$(x))
      next x

      for x=1 to arraysize ' work out how much room for each data item to print
      if x=arraysize then ' by subtracting tab() values
      proom(x)=len(d$(x)) ' adjust for last tab as no later tab to else ' subtract from
      proom(x)=t(x+1)-t(x)
      end if
      next x

      for x= 1 to arraysize 'pad each data item to fill "proom()"
      while len(d$(x))<proom(x)
      d$(x)=d$(x)+" "
      wend
      next x

      for x=1 to arraysize 'concatenate
      stringToPrint$=stringToPrint$+d$(x)
      next x

      stringToPrint$=space$(t(1)-1)+stringToPrint$ 'adjust for first tab
      'as no earlier tab to subtract from
      print #main.textbox1, stringToPrint$

      return
    • Stefan Pendl
      ... You can send the contents of the text editor to the printer as follows. ---code start (watch for line wraps) [goPrint] #main.textbox1 !contents?
      Message 2 of 3 , Jan 30, 2011
      • 0 Attachment
        >
        > Thanks to a suggestion from Bill Lopez I have made a general
        > purpose routine to simulate print (tab() or lprint tab() to a
        > texteditor window to avoid having mainwin open all the time
        > for printing and lprinting using tab().
        >
        > So far its all on screen. I want to print to hard copy as an
        > option. I could either repeat all the code over again with
        > lprint instead of print, or copy and paste the contents of
        > texteditor into Notepad. I have included a "Print" button
        > below the texteditor window as I am hoping to figure a way to
        > cut out the copy and paste into Notepad.
        >
        > Any suggestions for the code to run from the print button?
        >
        > working example of code below.... (sorry its a bit old school
        > but its a very long time ago I started on Qbasic).
        >

        You can send the contents of the text editor to the printer as follows.

        '---code start (watch for line wraps)

        [goPrint]
        #main.textbox1 "!contents? PrintMe$"
        LPRINT PrintMe$
        DUMP
        WAIT

        '---code end

        ---
        Stefan Pendl
        http://stefanpendl.runbasichosting.com/

        Liberty BASIC 4.04 Pro ... http://www.libertybasic.com/assist.html
        Liberty BASIC 4.04 ....... http://www.libertybasic.com/lb404setup.exe

        Liberty BASIC Bug Tracker ... http://libertybasicbugs.wikispaces.com/

        Books at http://www.lulu.com/ and http://www.amazon.com/
        Alyce Watson ... APIs for Liberty BASIC
        Carl Gundel .... Beginning Programming with Liberty BASIC

        Windows 7 Home Premium 64-bit RTM
        AMD Turion X2 RM-70 2GHz, 4GB RAM
      • sharpdj5927
        Hi Stefan, I knew there had to be a way, just couldn t see it. Obvious now of course. Thanks Derek Sharp
        Message 3 of 3 , Jan 30, 2011
        • 0 Attachment
          Hi Stefan, I knew there had to be a way, just couldn't see it. Obvious now of course. Thanks Derek Sharp

          --- In libertybasic@yahoogroups.com, "Stefan Pendl" <pendl2megabit@...> wrote:
          >
          > >
          > > Thanks to a suggestion from Bill Lopez I have made a general
          > > purpose routine to simulate print (tab() or lprint tab() to a
          > > texteditor window to avoid having mainwin open all the time
          > > for printing and lprinting using tab().
          > >
          > > So far its all on screen. I want to print to hard copy as an
          > > option. I could either repeat all the code over again with
          > > lprint instead of print, or copy and paste the contents of
          > > texteditor into Notepad. I have included a "Print" button
          > > below the texteditor window as I am hoping to figure a way to
          > > cut out the copy and paste into Notepad.
          > >
          > > Any suggestions for the code to run from the print button?
          > >
          > > working example of code below.... (sorry its a bit old school
          > > but its a very long time ago I started on Qbasic).
          > >
          >
          > You can send the contents of the text editor to the printer as follows.
          >
          > '---code start (watch for line wraps)
          >
          > [goPrint]
          > #main.textbox1 "!contents? PrintMe$"
          > LPRINT PrintMe$
          > DUMP
          > WAIT
          >
          > '---code end
          >
          > ---
          > Stefan Pendl
          > http://stefanpendl.runbasichosting.com/
          >
          > Liberty BASIC 4.04 Pro ... http://www.libertybasic.com/assist.html
          > Liberty BASIC 4.04 ....... http://www.libertybasic.com/lb404setup.exe
          >
          > Liberty BASIC Bug Tracker ... http://libertybasicbugs.wikispaces.com/
          >
          > Books at http://www.lulu.com/ and http://www.amazon.com/
          > Alyce Watson ... APIs for Liberty BASIC
          > Carl Gundel .... Beginning Programming with Liberty BASIC
          >
          > Windows 7 Home Premium 64-bit RTM
          > AMD Turion X2 RM-70 2GHz, 4GB RAM
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.