TweetFollow Us on Twitter

Printing Techniques 2
Volume Number:1
Issue Number:11
Column Tag:Basic School

Printing Techniques for Basic

By Dave Kelly, Hybrids Engineer, MacTutor Editorial Board

Managing BASIC Font Printing

Sometimes when talking about the Macintosh, people have asked "How many columns does the Macintosh have?". My answer to them is that it depends. Many of you like myself started out on other computers such as the Apple //. Many of the early computers had only 40 columns of text display. This severely limited the usefulness of word processing software until the introduction of 80-col display plug in boards. Back in those days it was very important to ask how many columns there were because of the limitations that are imposed by the lack of 80 column display. The Macintosh is an entirely different animal though. Because of the ability of the Macintosh to display proportional spaced fonts on the screen just as it will look when printed, it is not applicable to refer to the Macintosh screen as an 80-col display. It is important in development of applications for the Macintosh that we realize the difference between the Macintosh and other computers when it comes to displaying and printing data. Some may have experienced some frustration in trying to format text when using proportional fonts. I'll try to discuss a few items to keep in mind when using proportional spacing. There are some advantages and disadvantages to be aware of. This month we will explore some of the ins and outs of printing in different size fonts.

First, lets take a look at the difference between proportional and monospaced fonts. The unit of measurement for the spacing is the size of the character "0" in the current font. For monospaced fonts the character "0" happens to be the same width as the rest of the characters in the font. For the proportional spaced font, the "0" is an average width but not necessarily the same width as the other characters. Notice that the spacing of all the uppercase characters for a monospaced font is the same as for the lower case characters. Also note that the proportional spaced "A" is wider than the "a".

The advantage of using the monspaced type of font is that you can always be sure of just where each character will be printed or displayed. In the proportional font each of the letters are a different width depending on how much spacing each character requires. Now that we have a feel for proportional characters, try the following lines of BASIC and compare the results of printing with monospacing and proportional spacing:

' Sample program #1 
' Dave Kelly 
' MACTUTOR ©1985 

l1$="Name #1":r1$="Name #2" 
l2$="123 Main St.":r2$="456 Central Ave." 
l3$="Anyplace, USA":R3$="Anywhere, USA" 

FOR i=1 TO 40     

WIDTH 40,20 
GOSUB printit 
GOSUB printit 

PRINT  l1$,r1$ 
PRINT  l2$,r2$ 
PRINT  l3$,R3$ 
PRINT  zero$

PRINT  l1$;TAB(21);r1$ 
PRINT  l2$;TAB(21);r2$ 
PRINT  l3$;TAB(21);R3$ 
PRINT  zero$

In the sample program it is clear that the spacing of "0" is different for the 2 fonts, which explains why the second column does not line up. RULE 1: Remember that when mixing fonts you can't expect them to line up. This program demonstrates the use of the BASIC WIDTH command. The syntax of the WIDTH command is defined on page 264 of the MSBASIC manual. In general the syntax is: WIDTH [size ] [,print-zone ] . The size is the number of standard characters that a line may contain. In other words, BASIC will force a carriage return after the line size is full. If the size is 255 then BASIC will not force any carriage returns. The print-zone assigns the width of the print zone. The print zones are similar to tab stops, and they are forced by comma delimiters in the PRINT or LPRINT statements. In the sample program you can see that by using TAB or by using WIDTH the same result can be achieved. Using WIDTH the position of the 2nd column is determined by the print-zone. By using TAB(I), print position moves to the position indicated by I. An understanding of how these commands may be used is helpful when you are trying to format your printed output. An example would be the printing of a multiple column roster or newsletter where different fields might be combined together to create an entire line. The traditional way to do this would be to combine the fields together as one string variable and then to print the variable. The spacing of each field is filled to the size of the print-zone before combining all the fields, so that the total width of all the fields will fit. This works fine with monospaced fonts but it quite difficult to accomplish with proportional spaced fonts. An alternative solution is to use TAB or WIDTH functions to specify where each field will be printed. It is still important to check the length of each field before printing to make sure that each field will fit into the specified print zone. If it won't fit then either the field must be truncated or the print-zone should be adjusted. If not, then the field will print past the assigned print-zone and into the next print-zone. The next field to be printed will be pushed over to the next available print-zone.

This can be demonstated by changing the sample program. In the program the print-zone is set at 20 characters wide. If fewer than 20 characters are printed then the next print field will begin 20 characters after the start of the first print field. Try changing the line: l1$="Name #1":r1$="Name #2" to a field that has more than 20 characters, for example: l1$="Name #1 is too long now":r1$="Name #2" to demonstate the problem. To fix the line change it to:

l1$=LEFT$("Name #1 is too long now",20):r1$="Name #2" or adjust the WIDTH statement to: WIDTH 40,25.

Another consideration when using fonts of different sizes and widths is that each font will use a different number of lines to print the same thing. Because there are so many different fonts and sizes available it is difficult to examine the effect of each one. So, before using any set of fonts you should test each one out to see how many lines will fit on a page and adjust your program to count the lines as they are printed. If you are printing in a 10 pt. font it is probable that you will have more lines than for a 12 pt. font. The Disk Labeler program is a quick sample of what might be done with the WIDTH statement. Keep in mind that this is just a sample and may or may not be a useful application, however it may be modified to meet your needs.

Disk Labeler Program Sample

The program will read filenames one at a time from the disk and place them in an array called filename$(i). I have limited the size to 10 files to simplify the program. Choose Add/Remove from the files menu to add or remove a file. The selected files are printed in window 1. The second menu lets you select the font info. This illustrates a method of changing the fonts and sizes that will be used. This could be expanded to select various attributes such as Bold or Italics. Keep in mind that the different attributes will also change the width of each character. The printlabel routine demonstrates printing different fonts to the printer. If you have had trouble changing fonts when printing to the printer you may want to take a closer look at this routine. The key is the WINDOW OUTPUT #1 statement. This statement is necessary to direct all graphics commands, including those which change the fonts, to the printer. The Set Disk Label item of the files menu will let you set the number of lines and the number of columns that will be printed. The columns are formatted with the WIDTH statement. Disk labels may be printed in any desired font by adding additional fonts to the menu. I recommend printing labels in a small font (9 point) in order to fit more on a label. Have any useful printing tips? Send your best suggestions to me care of MacTutor!

' Disk Labeler 
' By Dave Kelly 
' MACTUTOR ©1985
' Watch line breaks. A few Basic lines are longer than 
' this Journals column width, but the breaks are
' obviously placed so that it is clear the Basic line
' continues from the previous line. 

number.of.files=0:DEFINT i-m:maxfiles=10 number.of.lines=5:number.of.col=2 

DIM filename$(maxfiles)
chicago=0: Appl=1: Newyork=2: Geneva=3: Monaco=4 
activefont=Geneva: activesize=12
WINDOW 1,"",(200,50)-(400,275),2 
'menu clear 
FOR i=1 TO 5:MENU i,0,0,"":NEXT i 

'set new menus 

MENU 1,0,1,"File" 
MENU 1,1,1,"Add/Remove a file" 
MENU 1,2,1,"Clear all files" 
MENU 1,3,0,"-" 
MENU 1,4,1,"Print Disk Label" 
MENU 1,5,1,"Set Disk Label" 
MENU 1,6,1,"Quit"
MENU 2,0,1,"Font Info" 
MENU 2,1,0,"Fonts" 
MENU 2,2,1,"NewYork" 
MENU 2,3,2,"Geneva" 
MENU 2,4,1,"Monaco" 
MENU 2,5,0,"-" 
MENU 2,6,1,"9 point" 
MENU 2,7,1,"10 point" 
MENU 2,8,2,"12 point"
idle: GOTO idle
Menunumber=MENU(0): Menuitem=MENU(1)     
ON Menunumber GOSUB Filemenu, Fontmenu     

ON Menuitem GOSUB Add, Clearfiles,Blank,Printlabel,      Setlabel, Quit 

IF x$="" THEN GOSUB display:RETURN     'x$=MID$(x$,INSTR(x$,":")+1) 
'optional line:use to strip volume name     

FOR i= 1 TO number.of.files         
IF x$=filename$(i) THEN filename$(i)="zzzzz":      i=number.of.files+2: 
CALL Sort(filename$(),  number.of.files): number.of.files= number.of.files-1 
NEXT i     

IF number.of.files>=maxfiles THEN GOSUB display:   RETURN     
IF i=number.of.files+1 THEN filename$(i)=x$:       number.of.files=i 
CALL Sort (filename$(),number.of.files )     
GOSUB display     

GOSUB display     

CLS:PRINT number.of.files;"files have been selected."     TEXTFONT(activefont):TEXTSIZE(activesize) 
FOR i=1 TO number.of.files    
 IF activesize<=10 THEN maxlength=40     
 PRINT LEFT$(filename$(i),maxlength)     
IF number.of.files=maxfiles THEN 
 PRINT"Max.";maxfiles;"files allowed"     

IF number.of.files=0 THEN RETURN    
WINDOW OUTPUT #1     TEXTFONT(activefont):TEXTSIZE(activesize)     
colwid=30:IF number.of.col=2 THEN colwid=20     
WIDTH "LPT1:",(colwid+1)*2,colwid+1     
PRINT: items=number.of.files     
ON ERROR GOTO Error.handle 'check for printing abort     
IF number.of.col=1 THEN onecol    
IF number.of.lines<number.of.files/2 THEN    items=number.of.lines*2 
 FOR i= 1 TO items STEP 2         
PRINT #1,LEFT$(filename$(i),colwid), LEFT$(filename$(i+1),colwid)    


GOSUB display     

IF number.of.lines<number.of.files THEN      items=number.of.lines 
FOR i= 1 TO items         
 PRINT #1,LEFT$(filename$(i),colwid)     
CLOSE #1     
GOTO Exit.printing     

Error.handle: RESET:RESUME

LOCATE 1,1:PRINT"Lines per label:"     
LOCATE 3,1:PRINT "# of columns:"     lines$=STR$(number.of.lines)    
EDIT FIELD 2,cwid$,(125,31)-(155,46),1,2
 EDIT FIELD 1,lines$,(125,1)-(145,16),1,2     
BUTTON 1,1,"OK",(25,70)-(75,88)    


IF d=1 THEN Done ' got OK button         
IF d=2 THEN i=DIALOG(2):EDIT FIELD i 'got field 
IF d=6 THEN Done 'got return key         
IF d=7 THEN i=(i MOD 2)+1:EDIT FIELD i 'got TAB key         GOTO loop 

IF number.of.lines<1 OR  number.of.lines>9 THEN loop         cwid$=EDIT$(2) 
IF number.of.col<1 OR number.of.col>2 THEN loop        
BUTTON CLOSE 1         
GOSUB display 

WINDOW 1,"Disk Labeler",(2,40)-(510,250),1     

ON Menuitem GOSUB Blank,NY,Geneva,Monaco,          Blank,Pt09,Pt10,Pt12 
GOSUB display     

NY:     activefont=Newyork     
MENU 2,2,2: MENU 2,3,1:  MENU 2,4,1     

Geneva:     activefont=Geneva     
MENU 2,2,1: MENU 2,3,2:  MENU 2,4,1     

Monaco:     activefont=Monaco     
MENU 2,2,1: MENU 2,3,1: MENU 2,4,2     

 Pt09:     activesize=9     
MENU 2,6,2: MENU 2,7,1: MENU 2,8,1     

Pt10:     activesize=10     
MENU 2,6,1:  MENU 2,7,2: MENU 2,8,1     

Pt12:     activesize=12     
MENU 2,6,1: MENU 2,7,1: MENU 2,8,2     

SUB  Sort (item$(maxfiles),N) STATIC      
FOR i=1 TO  N-1        
 FOR j=i+1 TO  N             
IF  item$(i)> item$(j) THEN SWAP item$(i),item$(j)         
NEXT  j     

Community Search:
MacTech Search:

Software Updates via MacUpdate

VirtualBox 5.1.14 - x86 virtualization s...
VirtualBox is a family of powerful x86 virtualization products for enterprise as well as home use. Not only is VirtualBox an extremely feature rich, high performance product for enterprise customers... Read more
FileZilla 3.24.0 - Fast and reliable FTP...
FileZilla (ported from Windows) is a fast and reliable FTP client and server with lots of useful features and an intuitive interface. Version 3.24.0: New The context menu for remote file search... Read more
BusyContacts 1.1.6 - Fast, efficient con...
BusyContacts is a contact manager for OS X that makes creating, finding, and managing contacts faster and more efficient. It brings to contact management the same power, flexibility, and sharing... Read more
BusyCal 3.1.4 - Powerful calendar app wi...
BusyCal is an award-winning desktop calendar that combines personal productivity features for individuals with powerful calendar sharing capabilities for families and workgroups. Its unique features... Read more
Duplicate Annihilator 5.8.3 - Find and d...
Duplicate Annihilator takes on the time-consuming task of comparing the images in your iPhoto library using effective algorithms to make sure that no duplicate escapes. Duplicate Annihilator detects... Read more
MarsEdit 3.7.10 - Quick and convenient b...
MarsEdit is a blog editor for OS X that makes editing your blog like writing email, with spell-checking, drafts, multiple windows, and even AppleScript support. It works with with most blog services... Read more
WALTR 2 2.0.9 - $39.95
WALTR 2 helps you wirelessly drag-and-drop any music, ringtones, videos, PDF, and ePub files onto your iPhone, iPad, or iPod without iTunes. It is the second major version of Softorino's critically-... Read more
Paperless 2.3.9 - $49.95
Paperless is a digital documents manager. Remember when everyone talked about how we would soon be a paperless society? Now it seems like we use paper more than ever. Let's face it - we need and we... Read more
Adobe After Effects CC 2017 14.1 - Creat...
After Effects CC 2017 is available as part of Adobe Creative Cloud for as little as $19.99/month (or $9.99/month if you're a previous After Effects customer). The new, more connected After Effects CC... Read more
Adobe Premiere Pro CC 2017 11.0.2 - Digi...
Premiere Pro CC 2017 is available as part of Adobe Creative Cloud for as little as $19.99/month (or $9.99/month if you're a previous Premiere Pro customer). Adobe Premiere Pro CC 2017 lets you edit... Read more

Super Mario Run dashes onto Android in M...
Super Mario Run was one of the biggest mobile launches in 2016 before it was met with a lukewarm response by many. While the game itself plays a treat, it's pretty hard to swallow the steep price for the full game. With that said, Android users... | Read more »
WarFriends Beginner's Guide: How to...
Chillingo's new game, WarFriends, is finally available world wide, and so far it's a refreshing change from common mobile game trends. The game's a mix of tower defense, third person shooter, and collectible card game. There's a lot to unpack here... | Read more »
Super Gridland (Entertainment)
Super Gridland 1.0 Device: iOS Universal Category: Entertainment Price: $1.99, Version: 1.0 (iTunes) Description: Match. Build. Survive. "exquisitely tuned" - Rock Paper Shotgun No in-app purches, and no ads! | Read more »
Red's Kingdom (Games)
Red's Kingdom 1.0 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0 (iTunes) Description: Mad King Mac has kidnapped your father and stolen your golden nut! Solve puzzles and battle goons as you explore and battle your... | Read more »
Turbo League Guide: How to tame the cont...
| Read more »
Fire Emblem: Heroes coming to Google Pla...
Nintendo gave us our first look at Fire Emblem: Heroes, the upcoming mobile Fire Emblem game the company hinted at last year. Revealed at the Fire Emblem Direct event held today, the game will condense the series' tactical RPG combat into bite-... | Read more »
ReSlice (Music)
ReSlice 1.0 Device: iOS Universal Category: Music Price: $9.99, Version: 1.0 (iTunes) Description: Audio Slice Machine Slice your audio samples with ReSlice and create flexible musical atoms which can be triggered by MIDI notes or... | Read more »
Stickman Surfer rides in with the tide t...
Stickson is back and this time he's taken up yet another extreme sport - surfing. Stickman Surfer is out this Thursday on both iOS and Android, so if you've been following the other Stickman adventures, you might be interested in picking this one... | Read more »
Z-Exemplar (Games)
Z-Exemplar 1.4 Device: iOS Universal Category: Games Price: $3.99, Version: 1.4 (iTunes) Description: | Read more »
5 dastardly difficult roguelikes like th...
Edmund McMillen's popular roguelike creation The Binding of Isaac: Rebirth has finally crawled onto mobile devices. It's a grotesque dual-stick shooter that tosses you into an endless, procedurally generated basement as you, the pitiable Isaac,... | Read more »

Price Scanner via

Twelve South Releases RelaxedLeather Cases fo...
Inspired by the laid-back luxury of burnished leather boots and crafted in rich tones of taupe, herb and marsala, RelaxedLeather cases deliver smart, easy protection for the iPhone 7. Each genuine... Read more
Week’s Best Deal: New 2016 13-inch 2.0GHz Mac...
Amazon has the new 2016 13″ 2.0GHz non-Touch Bar MacBook Pros on sale for a limited time for $225 off MSRP including free shipping: - 13″ 2.0GHz MacBook Pro, Space Gray (MLL42LL/A): $1274.99 $225 off... Read more
Back in stock: Apple refurbished Mac minis fr...
Apple has Certified Refurbished Mac minis available starting at $419. Apple’s one-year warranty is included with each mini, and shipping is free: - 1.4GHz Mac mini: $419 $80 off MSRP - 2.6GHz Mac... Read more
Apple Ranked ‘Most Intimate Brand’
The top ranked ‘”intimate” brands continued to outperform the S&P and Fortune 500 indices in revenue and profit over the past 10 years, according to MBLM’s Brand Intimacy 2017 Report, the largest... Read more
B-Eng introduces SSD Health Check for Mac OS
Fehraltorf, Switzerland based independant Swiss company- B-Eng has announced the release and immediate availability of SSD Health Check 1.0, the company’s new hard drive utility for Mac OS X. As the... Read more
Apple’s Education discount saves up to $300 o...
Purchase a new Mac or iPad using Apple’s Education Store and take up to $300 off MSRP. All teachers, students, and staff of any educational institution qualify for the discount. Shipping is free: -... Read more
4-core 3.7GHz Mac Pro on sale for $2290, save...
Guitar Center has the 3.7GHz 4-core Mac Pro (MD253LL/A) on sale for $2289.97 including free shipping or free local store pickup (if available). Their price is a $710 savings over standard MSRP for... Read more
128GB Apple iPad Air 2, refurbished, availabl...
Apple has Certified Refurbished 128GB iPad Air 2s WiFis available for $419 including free shipping. That’s an $80 savings over standard MSRP for this model. A standard Apple one-year warranty is... Read more
13-inch 2.7GHz Retina MacBook Pro on sale for...
B&H Photo has the 2015 13″ 2.7GHz/128GB Retina Apple MacBook Pro on sale for $100 off MSRP. Shipping is free, and B&H charges NY tax only: - 13″ 2.7GHz/128GB Retina MacBook Pro (MF839LL/A): $... Read more
Laptop Market – Flight To Quality? – The ‘Boo...
Preliminary quarterly PC shipments data released by Gartner Inc. last week reveal an interesting disparity between sales performance of major name PC vendors as opposed to that of less well-known... Read more

Jobs Board

*Apple* & PC Desktop Support Technician...
Apple & PC Desktop Support Technician job in Manhattan, NY Introduction: We have immediate job openings for several Desktop Support Technicians with one of our most Read more
Senior Workstation Administrator - *Apple*...
…with extraordinary HR. QualificationsJOB SUMMARY/OVERVIEWThe Senior Workstation Administrator - Apple supports the mission of TriNet by providing advanced level Read more
Intermediate *Apple* macOS Systems Integrat...
**Position Summary:** SC3 is actively seeking an Intermediate Apple macOS systems integration administrator that will be responsible for providing Apple Mac Read more
*Apple* & PC Desktop Support Technician...
Apple & PC Desktop Support Technician job in Los Angeles, CA Introduction: We have immediate job openings for several Desktop Support Technicians with one of our Read more
*Apple* Retail - Multiple Positions - Apple,...
SalesSpecialist - Retail Customer Service and SalesTransform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.