Liberty BASIC Community Forum
« Printing listings problem »

Welcome Guest. Please Login or Register.
Sep 21st, 2017, 7:56pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Printing listings problem  (Read 321 times)
tenochtitlanuk
Board Moderator

member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1162
xx Printing listings problem
« Thread started on: Oct 23rd, 2015, 04:41am »

I long ago gave up printing listings direct, since I get solid black boxes rather than letters, whatever printer font I select. I assumed it was just my Linux set-up, and cut/paste to gedit or similar, which works fine, but you don't get the colour coding.
I know this has been mentioned before, but couldn't find it.
Does anyone know where the problem lies? I've been asked by a novice LB programmer and am embarrased to offer no solution!
User IP Logged

tenochtitlanuk
Board Moderator

member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1162
xx Re: Printing listings problem
« Reply #1 on: Oct 23rd, 2015, 2:46pm »

Suspect it's the same problem as Stefan Pendl commented on in Sep 7, 2010.
As far as I know drivers are up-to-date, so that's not the answer. Away from any MS machines at present ( so only Linux available) so don't know if that is relevant- but I'm sure it also applies on my XP machine to various printers.
User IP Logged

Stefan Pendl
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Computers are like babies, you must teach them what you like them to do ...


Homepage PM

Gender: Male
Posts: 5295
xx Re: Printing listings problem
« Reply #2 on: Oct 23rd, 2015, 4:00pm »

Since LB doesn't print listings in color, you can just open the BAS file in any text editor and print it with that.
User IP Logged

Stefan

Make sure to read and follow the Forum Guidelines

Liberty BASIC Pro 4.04, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
tenochtitlanuk
Board Moderator

member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1162
xx Re: Printing listings problem
« Reply #3 on: Oct 23rd, 2015, 4:13pm »

It's so long since I used LB on XP that I couldn't remember if the display colours did or did not print!
I'll carry on as you say- open in ( or paste into) a more versatile editor.
Thanks Stefan..
User IP Logged

tenochtitlanuk
Board Moderator

member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1162
xx Re: Printing listings problem
« Reply #4 on: Oct 23rd, 2015, 5:01pm »

I also tried Alyce's CodeAChrome, which worked on-screen but crashed on trying to print. ( Sorry Alyce- a great creation but apparently not under Linux??) And I think Scintilla is beyond me.
Actually I find 'prettyprinting' all programming structures with indents and using camelCase variables with self-explanatory names, a mono-spaced font and judicious use of spaces makes a program more 'readable' than colouring. But it's a personal choice.
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5526
xx Re: Printing listings problem
« Reply #5 on: Oct 24th, 2015, 02:59am »

You could resort to graphicbox printing. This is nowhere near complete but it will show you one thing, printing in color isn't that useful. You need to point it at a short program because I have not implemented paging, nor indentation, but I'll get there.

Code:
nomainwin
' find how much whitespace the windows scheme is taking
' Anatoly's tip
WindowWidth = 200
WindowHeight = 200
menu #1, "&File", "E&xit", [quit]
open "Ajusting..." for graphics_nsb as #1
#1 "home ; down ; posxy x y"
ThemeWidth=200-2*x : ThemeHeight=200-2*y
Border=2
close #1
gosub [syntaxcolor]


WindowWidth  = 1200+ThemeWidth-4
WindowHeight = 600+ThemeHeight
UpperLeftX   = (DisplayWidth-WindowWidth)/2
UpperLeftY   = (DisplayHeight-WindowHeight)/2
graphicbox #1.structure, 0,0,200,600+Border
graphicbox #1.code, 199,0,700,600+Border
graphicbox #1.help, 898,0,300,600+Border
menu #1, "&File", "E&xit", [quit]
menu #1, "edit"
menu #1, "&Help", "&About", [about]
open "Full graphic view" for window as #1
#1 "trapclose [quit]"

chrWidth=7
chrHeight=15

dim code$(5000)

#1.structure "down ; color black ; fill white ; font courier_new 9"
#1.structure "vertscrollbar on"
#1.structure "place ";chrWidth;" ";chrHeight;" ;\hello"
#1.code "down ; color black ; fill white ; font courier_new 9"
#1.code "vertscrollbar on ; horizscrollbar on"
#1.help "down ; color black ; fill white ; font courier_new 9"
#1.help "place ";chrWidth;" ";chrHeight;" ;\hello"
open "SyntaxColor.bas" for input as #2

Ln=1
while eof(#2)=0
    line input #2 , code$(Ln)
    Ln=Ln+1
wend
close #2

LLn=Ln
Ln=1
#1.code "place ";chrWidth;" ";chrHeight
for L=Ln to LLn
    '#1.code "\";code$(L)
next

for L=Ln to LLn
    gosub [printline]
next


#1.code "flush"
#1.code "print 700"
wait



[printline]
'get the line in its raw state
line$=code$(L)

'pad in spaces round operators
newline$=""
thischr$=""
for n = 1 to len(line$)
    thischr$=mid$(line$,n,1)
    if instr(opslist$,thischr$)>0 then
        newline$=newline$+" "+thischr$+" "
    else
        newline$=newline$+thischr$
    end if
next
newline$=trim$(newline$)
'pull out words and single space
chrX=chrWidth
chrY=L*chrHeight
line$=""
w=1
w$=word$(newline$,w," ")
while w$<>""
    #1.code "color darkgray"
    w$=trim$(w$)
    if w$="'" then remon=1
    if w$<>"" then line$=line$+w$+" "
    if remon then
        #1.code "color 255 128 0"
    else
        select case
            case instr(opslist$,w$,1)>0
                #1.code "color black"
            case instr(comlist$," "+lower$(w$)+" ",1)>0
                #1.code "color blue"
            case instr(w$,"(",1)>0
                if instr(funlist$," "+lower$(left$(w$,instr(w$,"(",1))),1)>0 then #1.code "color darkpink"
            case instr(varlist$," "+w$+" ",1)>0
                #1.code "color darkgreen"
            case instr(opelist$," "+lower$(w$)+" ",1)>0
                #1.code "color darkgreen"
            case instr(typlist$," "+lower$(w$)+" ",1)>0
                #1.code "color brown"
            case instr(ctrlist$," "+lower$(w$)+" ",1)>0
                #1.code "color green"
            case instr(ctrlist$," "+right$(lower$(w$),len(w$)-1)+" ",1)>0
                #1.code "color green"
            case instr(ctrlist$," "+left$(lower$(w$),len(w$)-1)+" ",1)>0
                #1.code "color green"
        end select
        if left$(w$,1)="[" and right$(w$,1)="]" then #1.code "color black"
        if w$="0" or val(w$)>0 then #1.code "color red"
    end if
    if w$<>"" then
        #1.code "place ";chrX;" ";chrY
        #1.code "|";w$;" "
        chrX=chrX+chrWidth*(len(w$)+1)
    end if
    w=w+1
    w$=word$(newline$,w," ")
wend
remon=0
return



[syntaxcolor]
opslist$="'=<>:,+-*/^;" 'perhaps not " it adds in a space
comlist$=" xor while wend wait until unloadbmp trace to titlebar timer then texteditor "
comlist$=comlist$+"textbox sub stylebits struct stopmidi stop step statictext sort select seek "
comlist$=comlist$+"scan run return resume restore rem redim readjoystick read randomize "
comlist$=comlist$+"radiobutton put prompt printerdialog print popupmenu playwave playmidi "
comlist$=comlist$+"password out or open oncomerror on notice nomainwin next name mod menu "
comlist$=comlist$+"maphandle mainwin lprint loop loadbmp listbox line let kill input if "
comlist$=comlist$+"groupbox graphicbox goto gosub global gettrim get function for fontdialog "
comlist$=comlist$+"files filedialog field exit error end else dump do dim data cursor confirm "
comlist$=comlist$+"combobox colordialog cls close checkbox case callfn calldll callback call "
comlist$=comlist$+"button bmpsave bmpbutton beep as and "
funlist$=" word$( winstring( val( using(  upper$( txcount( trim$( time$( tan( tab( str$( sqr( "
funlist$=funlist$+"space$( sin( rnd( rmdir( right$( not( mkdir( min( midipos( mid$( max( lower$( log( "
funlist$=funlist$+"lof( loc( len( left$( int( instr( inputto$( input$( inp( hwnd( hexdec( hbmp( exp( "
funlist$=funlist$+"eval( eval$( eof( dechex$( date$( cos( chr$( atn( asn( asc( acs( abs( "
varlist$=" WindowWidth WindowHeight Version$ UpperLeftY UpperLeftX TexteditorColor$ "
varlist$=varlist$+"TextboxColor$ PrinterName$ PrinterFont$ PrintCopies PrintCollate Platform$ "
varlist$=varlist$+"ListboxColor$ Joy2z Joy2y Joy2x Joy2button2 Joy2button1 Joy1z Joy1y Joy1x "
varlist$=varlist$+"Joy1button2 Joy1button1 ForegroundColor$ Err$ Err Drives$ DisplayWidth "
varlist$=varlist$+"DisplayHeight DefaultDir$ CommandLine$ ComboboxColor$ BackgroundColor$ "
typlist$=" word void ushort ulong short ptr none long dword double boolean "
opelist$=" window text random output graphics dll dialog byref binary append "
opelist$=opelist$+"window_nf window_popup graphics_fs graphics_nsb graphics_fs_nsb graphics_nf_nsb "
opelist$=opelist$+"text_fs text_nsb text_nsb_ins dialog_modal dialog_nf dialog_nf_modal dialog_fs dialog_nf_fs dialog_popup "
opelist$=opelist$+"yellow brown red darkred pink darkpink blue darkblue green darkgreen "
opelist$=opelist$+"cyan darkcyan white black lightgray darkgray buttonface "
ctrlist$=" addsprite !autoresize autoresize backcolor background backgroundxy box "
ctrlist$=ctrlist$+"boxfilled centersprite circle circlefilled !cls color !contents !contents? "
ctrlist$=ctrlist$+"!copy !cut cyclesprite delsegment discard down drawbmp drawsprites ellipse "
ctrlist$=ctrlist$+"ellipsefilled fill font getbmp go goto home !insert line !line !lines? "
ctrlist$=ctrlist$+"locate !modified? north !origin !origin? !paste pie piefilled place "
ctrlist$=ctrlist$+"posxy print redraw refresh removesprite resizehandler rule segment "
ctrlist$=ctrlist$+"!select !selectall !selection? set setfocus size spritecollides "
ctrlist$=ctrlist$+"spriteimage spritemovexy spriteoffset spriteorient spriteround flush "
ctrlist$=ctrlist$+"spritescale spritetoback spritetofront spritetravelxy spritevisible "
ctrlist$=ctrlist$+"spritexy spritexy? stringwidth? !trapclose trapclose turn up when \ "

return

[quit]
close #1
end


 
User IP Logged

tenochtitlanuk
Board Moderator

member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1162
xx Re: Printing listings problem
« Reply #6 on: Oct 24th, 2015, 04:09am »

It's an idea I'd thought of, and wondered if you ( or others) would try building on the work on parsing, etc.
I'd also thought of LB Workshop, but Alyce describes it as having problems on MS beyond XP.

Like you I don't find colour all that helpful in listings. I find indented properly structured code easier to follow/create.

( Coding/debugging in Python, which I seem to be using more these days, FORCES indentation, which is great. BUT it took me 20 minutes to realise that I had one indented line in a program indented by one more space than it's neighbours, and the error wasn't flagged on that line but on another.!)
User IP Logged

Stefan Pendl
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Computers are like babies, you must teach them what you like them to do ...


Homepage PM

Gender: Male
Posts: 5295
xx Re: Printing listings problem
« Reply #7 on: Oct 24th, 2015, 05:28am »

I think there was a colored listing program written in Run BASIC, which creates a HTML page that can be easily printed without taking care of paging and such.
User IP Logged

Stefan

Make sure to read and follow the Forum Guidelines

Liberty BASIC Pro 4.04, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
RNBW
Junior Member
ImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 63
xx Re: Printing listings problem
« Reply #8 on: Oct 25th, 2015, 06:01am »

I disagree with Rod about the usefulness of printout of coloured listings. In the same way as listings on screen, coloured keywords, comments, etc help you to find your way around much easier than uncoloured listings. In addition to colouring, I also like to use capitals for keywords (as old fashioned Basic- which probably shows my age!).

There are ways around it, some of which Stefan has identified.

I have just tried another method that works. Using Liberty Basic Workshop (why wouldn't you?) and printing to a PDF writer (I used Cute PDF Writer) this printers a PDF file which is in glorious colour. The downside is that it produces a PDF file, but this can always be deleted when you've finished with it.
« Last Edit: Oct 25th, 2015, 08:02am by Alyce Watson » User IP Logged

RNBW
Junior Member
ImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 63
xx Re: Printing listings problem
« Reply #9 on: Oct 25th, 2015, 06:41am »

Having printed in colour to a pdf file using LB Workshop, I've now tested it out direct to a printer, missing out the generated pdf file. It works.

So there is the solution! Use LB Workshop obtainable from Alyce Watson's website.

Ignore the website warning. It is easily installed. I have used it on Windows 7, 8.1 and 10 without any problems. It is superior to LB's IDE in most areas and I hardly ever use anything else.
User IP Logged

tenochtitlanuk
Board Moderator

member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1162
xx Re: Printing listings problem
« Reply #10 on: Oct 25th, 2015, 12:52pm »

Just to confirm that LB Workshop printed listings in colour on my Ubuntu/Wine/LB set-up.
It is only printing direct from the LB editor which fails for me with the black squares ( which it also does if I print to pdf)

I can only plead that I've grown old using a simple editor not an IDE- LBW is a fantastic piece of work and Alyce deserves many gold stars and a sainthood. Yesterday!
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls