TweetFollow Us on Twitter

CLR ToolLib
Volume Number:2
Issue Number:6
Column Tag:Basic School

Add Three New Libraries to your CLR ToolLib

By Dave Kelly, Editorial Board

Hello!! This month MacTutor features three new MS BASIC libraries to add to your CLR ToolLib collection. These routines were written by Clear Lake Research for use on future versions of BASIC library disks. To make it easy to add them to your ToolLib Libraries, we are providing a statement adder program to write the hex codes directly to your disk. It will require that you already have CLR ToolLib in order to run the Statement Adder program as the resource routines are used to save the new libraries.

The new libraries are: RealFont, KbEquiv and setItemStyle. RealFont is a Macintosh Font Manager function that returns TRUE if the font having the font number fontNum is available in the given size in a resource file, or returns FALSE if the font has to be scaled to that size. The syntax to call the CLR Realfont library is:

Realfont fontNum%,size%,boolean%

The following example shows the use of RealFont:

LIBRARY"NewLibraries"
fontNum%=4    'Monaco font
size%=18
boolean%=0
RealFont fontNum%,size%,boolean%
PRINT boolean%

Each font type is represented by a different font number, in this case a four represents the Monaco font. The size we are checking is 18. If size 18 exists in the Monaco font the the variable boolean% returns a TRUE, otherwise if the font does not exist in size 18 then a FALSE is returned. This routine is useful to create menus which include the size of fonts to be used by your program. Some font numbers can be found on page 290 of your MS BASIC manual.

KbEquiv may be used to add keyboard equivalents to your menus. MS BASIC menus do no provide a way to add keyboard equivalents to your menus. An alternative is to trap all keyboard input and branch to the appropriate subroutine, but that is would require a separate routine which is not associated with the menu error trapping. Usually, calls to the menu manager would indicate which keys are to be used as keyboard equivalents to the menus. However, MS BASIC did not provide a way to use equivalent keys. The syntax for the KbEquiv statement is:

KbEquiv Menunumber%,itemnumber%,key$

where Menunumber% is the menu and itemnumber% is the menu item where the key will be added. The variable key$ is the one character key which will be used as the equivalent key. The routine implementation is shown in the Menu Styles Demo later in this article.

A warning: The KbEquiv routine does not yet check if the menu indicated actually exists. Therefore be sure that you know your menu has already been created before calling this routine. Unpredictable results will occur. The future released version of this routine from CLR will check for the menu before setting up the keyboard equivalent.

The third routine, setItemStyle, is also a member of the Menu Manager routines. SetItemStyle changes the character style of the given menu item to the indicated character style. The syntax is:

setItemStyle Menunumber%,itemnumber%,style%

where menunumber% is the number of the menu and itemnumber% is the number of the item in that menu. Style% is an integer number representing the style of the menu item. Style% is the same as the values used to represent the attributes of the TEXTFACE statement. The bit for each attribute is listed on page 291 of your MS BASIC manual. (Example: bold, shadow has a value of 17; Italic and underlined has a value of 12). The Menu Styles Demo demonstrates how to set up your own style menu.

To install your new libraries run the statement adder program listed below. The KbEquiv, Real Font and setItemStyle routines will be added to a new file named NewLibraries. This newly created file will be a CLR library file but without the LibInit function; just the three new statements we've added this month. Next you will need to run the Statement Mover program which is provided with the CLR Libraries disk. Statement Mover is a handy BASIC program which will copy libraries from one file to another. In fact, I recommend that you copy the libraries that you are using to your BASIC program file (i. e. add the library resource to your BASIC program). The BASIC program is stored in the data fork of the file, and the resource fork will then contain the libraries used by the program. Use Satement Mover to copy the LibInit routine to the NewLibraries file! LibInit is needed by BASIC to be sure that the Library file is a MS BASIC Library. LibInit must be in the same file as each of the libraries that you use. Of course if you choose to move the NewLibaries file into your already existing ToolLib file, then you don't need the extra LibInit function. In fact, if you can spare the space, you might want to merge all the library routines into a single ToolLib file using the Statement Mover program. Here is a review list of everything CLR has published:

CLR LIBRARIES

ToolLib Original CLR ROM Interface

SpeechLib Speech stuff for MacinTalk

MathStatLib Math and Statistics routines

NewLibraries Output of this month's program

The ToolLib and MathStatLib are available on the CLR Utilities Disk from the MacTutor Mail Order Store for $50. The SpeechLib is available seperately on the CLR Speech disk for $20. We tried to encourage CLR to combine the two products to avoid customer confusion, but they were unable to do so.

The Menu Styles Demo will try to open the NewLibraries file, so you should be sure that LibInit is moved to the New Libraries file or that the program calls the name of the Library containing the setItemStyle and KbEquiv routines (RealFont is not used in the demo).


'Statement Adder 
' for RealFont, KbEquiv, and setItemStyle libraries
'By Clear Lake Research and David Kelly
'© Clear Lake Research, Inc.
'used with permission
'NOTE: The hex codes for RealFont, KbEquiv, setItemStyle
'are copyrighted by Clear Lake Research. 
'By using Statement Adder you may create these libraries
'then add them to your ToolLib Libraries using 
'Statement Mover (provided with CLR ToolLib).
'This program requires ToolLib and MS Basic 2.0 or 2.1
'Run this program only once.

LIBRARY"ToolLib"
DIM p%(120)
DEFINT i,j
FOR j=1 TO 3
    ERASE p%
    REM  read hex code
    READ nm$
    READ id%
    READ numofbytes%
    DIM p%(numofbytes%)
    FOR i%= 1 TO numofbytes%
        READ p%(i%)
   NEXT i%
 
fileRefNum%=0:H!=0
openResFile"NewLibraries",fileRefNum%        'openResFile
saveArray fileRefNum%,p%(1),numofbytes%*2,id%,nm$    
                                   'save as type GNRL'
GetNamedRes fileRefNum%,"GNRL",nm$,H!   'get resource
detachRes H!                                   'Now it is not a resource
AddRes fileRefNum%,H!,"CODE",id%,nm$       'type CODE
releaseRes H!                                               
GetNamedRes fileRefNum%,"GNRL",nm$,H!     'Not needed
removeRes fileRefNum%,H!                                    'so remove 
it
REM early printings of the manual had the syntax of
REM removeRes wrong. The first argument was left off.

CloseResFile fileRefNum%

REM make sure libinit is in the file before running it!

NEXT j  'do next of three functions
PRINT"Done" 'end of program.

'setItemStyle Library 
DATA "setItemStyle" :REM name of resource nm$
DATA 5001: REM id number id%
DATA 33: REM number of bytes
DATA &H8,&H0,&H4EAD,&H2A,&HC00
DATA &H3,&H662C,&H3A12,&H5245,&H4EAD
DATA &H2A,&HC00,&H3,&H661E,&H3612
DATA &H4EAD,&H2A,&HC00,&H3,&H6612
DATA &H3812,&H42A7,&H3F05,&HA949,&H3F03
DATA &H3F04,&HA942,&H7000,&H4E75,&H740D
DATA &H7000,&H4EAD,&H42

'RealFont Library  
DATA "RealFont": REM name of resource nm$
DATA 703: REM id number id%
DATA 37: REM number of bytes
DATA &H8,&H0,&H4EAD,&H2A,&HC00
DATA &H3,&H6632,&H3812,&H4EAD,&H2A
DATA &HC00,&H3,&H6626,&H3A12,&H4EAD
DATA &H2A,&HC40,&H3,&H661A,&H4267
DATA &H3F04,&H3F05,&HA902,&H301F,&H6708
DATA &H34BC,&HFFFF,&H7000,&H4E75,&H4252
DATA &H7000,&H4E75,&H7000,&H303C,&HD
DATA &H4EAD,&H42

'KbEquiv Library 
DATA "KbEquiv":REM name of resource nm$
DATA 191:REM id number id%
DATA 58: REM number of bytes
DATA &H0,&H1,&H4EAD,&H2A,&HC00
DATA &H3,&H665E,&H3812,&H5244,&H4EAD
DATA &H2A,&HC00,&H3,&H6650,&H3A12
DATA &H4EAD,&H2A,&HC00,&H2,&H6644
DATA &H264A,&H4EAD,&H82,&H4EAD,&H8A
DATA &H1613,&H42A7,&H3F04,&HA949,&H2657
DATA &H2653,&H303C,&HE,&H1233,&H0
DATA &H5241,&HD041,&H5345,&H6008,&H1233
DATA &H0,&H5A41,&HD041,&H51CD,&HFFF6
DATA &H1233,&H0,&H5441,&HD041,&H1783
DATA &H0,&HA948,&H7000,&H4E75,&H740D
DATA &H7000,&H4EAD,&H42
=========================================

'Menu Styles Demo
'©MacTutor 1986
'by Dave Kelly
'With special thanks to Clear Lake Research
'for allowing use of KbEquiv, RealFont,
'and setItemStyle Libraries

LIBRARY"NewLibraries"
TEXTMODE 1
DIM st%(10)

MENU 6,0,1,"Style"
MENU 6,1,1,"Plain"
MENU 6,2,1,"Bold"
MENU 6,3,1,"Italic"
MENU 6,4,1,"Underline"
MENU 6,5,1,"Outline"
MENU 6,6,1,"Shadow"
MENU 6,7,1,"Condensed"
MENU 6,8,1,"Extended"
MENU 6,9,0,"-"
MENU 6,10,1,"Quit"

FOR i% = 0 TO 6
    st%(i%+2)=2^i%
NEXT i%

'Variable    Value            Attribute
'    st%(1)      0                Plain Text
'    st%(2)      1                Bold
'    st%(3)      2                Italic
'    st%(4)      4                Underlined
'    st%(5)      8                Outlined
'    st%(6)     16                Shadow
'    st%(7)      32               Condensed 
 '(less space between characters)
'    st%(8)      64               Extended 
 '(more space between characters)

'Set up menu styles
FOR i%= 2 TO 8
    setItemStyle 6,i%,st%(i%)
    st%(i%)=0
NEXT i%

'Set up keyboard equivalents
FOR i% = 1 TO 6
    READ A$
    KbEquiv 6,i%,A$
NEXT i%
 KbEquiv 6,10,"Q"
 
DATA P,B,I,U,O,S

ON MENU GOSUB MenuEvent
MOVETO 10,50
PRINT "Hello World!"
Style%=0
MENU ON
loop:
GOTO loop

MenuEvent:
menunumber%=MENU(0):menuitem%=MENU(1):MENU
IF menunumber%=6 THEN ItemEvent
RETURN

ItemEvent:
ON menuitem% GOSUB plain, bold, Italic, Underlined,      Outlined, Shadow, 
Condensed, Extended,, quit
RETURN

quit:
MENU RESET
END

plain:
Style%=0
MENU 6,1,2
FOR i%=2 TO 8
    MENU 6,i%,1
    st%(i%)=0
NEXT i%
GOSUB printscreen
RETURN

printscreen:
TEXTFACE Style%
CLS
MOVETO 10,50
PRINT "Hello, World!"
RETURN

bold:
IF st%(2)=0 THEN st%(2)=1 ELSE st%(2)=0
IF st%(2)=0 THEN MENU 6,2,1 ELSE MENU 6,2,2

Computestyle:
MENU 6,1,1
Style%=0
FOR i%=1 TO 8
    Style%=Style%+st%(i%)
NEXT i%
GOSUB printscreen
RETURN

Italic:
IF st%(3)=0 THEN st%(3)=2 ELSE st%(3)=0
IF st%(3)=0 THEN MENU 6,3,1 ELSE MENU 6,3,2
GOTO Computestyle

Underlined:
IF st%(4)=0 THEN st%(4)=4 ELSE st%(4)=0
IF st%(4)=0 THEN MENU 6,4,1 ELSE MENU 6,4,2
GOTO Computestyle

Outlined:
IF st%(5)=0 THEN st%(5)=8 ELSE st%(5)=0
IF st%(5)=0 THEN MENU 6,5,1 ELSE MENU 6,5,2
GOTO Computestyle

Shadow:
IF st%(6)=0 THEN st%(6)=16 ELSE st%(6)=0
IF st%(6)=0 THEN MENU 6,6,1 ELSE MENU 6,6,2
GOTO Computestyle

Condensed:
IF st%(7)=0 THEN st%(7)=32 ELSE st%(7)=0
IF st%(7)=0 THEN MENU 6,7,1 ELSE MENU 6,7,2
GOTO Computestyle

Extended:
IF st%(8)=0 THEN st%(8)=64 ELSE st%(8)=0
IF st%(8)=0 THEN MENU 6,8,1 ELSE MENU 6,8,2
GOTO Computestyle

Using HFS with MS BASIC and other applications

The release of the Apple Macintosh plus has created a few compatability problems for MS BASIC users. It is rumored that Microsoft is in the process of fixing MS BASIC so that it will be completely compatable with HFS. The following tips may help in getting around some of the problems until a more permanent solution is released (i.e. a new verison of MS BASIC).

• Problem: MS BASIC can't find files in folders.

Solution: Use the HFS.FIX program by Andy Hertfeld. It will add a resource to your system to help search through folders to find the files you want. This will work in 95% of the cases. In some cases BASIC must be in the root volume with the application. This is true for use of some CLR Libraries. We have not found any CLR routines that do not work with HFS. The problems that exist are related to the BASIC interpreter, not the Libraries. If you suspect a problem, try placing Basic, the application file and the libraries it uses in the root directory for that disk; ie not in any folder. Another solution would be to use MFS formated disks for your BASIC programming. This is NOT the preferred solution, however, it will be sure to work.

• Notes on using the RAM Cache with any software: I recommend that you NEVER change the cache from within any application. Since most software doesn't keep track of the cache, it can cause some catastrophic results. When using Switcher, be sure to turn off the cache completely. Switcher may allocate the same memory that the cache is using (without knowing it); the memory contention will surely cause a disaster. On the Mac Plus there is 850278 bytes of free space left in MS BASIC's data segment with the cache turned off. With a 128K cache on there is still 719214 bytes left. I have not seen any problems in using the cache with BASIC. In fact, your program will run much faster with the cache on. The size of the cache is arbitrary.

• Initializing single sided disks as double sided 800K disks: We take no responsibility if you lose any data when using single sided disks as double sided, however, those that have been re-initializing their 400K disks have not had any noticeable problems with any of them. The differance between single and double sided disks: The side that you use is polished and has been verified before shipping. Typically, both single and double sided disks are manufactured the same way, only the QA checks and certification are missing, meaning you can usually get away with it.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Fresh From the Land Down Under – The Tou...
After a two week hiatus, we are back with another episode of The TouchArcade Show. Eli is fresh off his trip to Australia, which according to him is very similar to America but more upside down. Also kangaroos all over. Other topics this week... | Read more »
TouchArcade Game of the Week: ‘Dungeon T...
I’m a little conflicted on this week’s pick. Pretty much everyone knows the legend of Dungeon Raid, the match-3 RPG hybrid that took the world by storm way back in 2011. Everyone at the time was obsessed with it, but for whatever reason the... | Read more »
SwitchArcade Round-Up: Reviews Featuring...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for July 19th, 2024. In today’s article, we finish up the week with the unusual appearance of a review. I’ve spent my time with Hot Lap Racing, and I’m ready to give my verdict. After... | Read more »
Draknek Interview: Alan Hazelden on Thin...
Ever since I played my first release from Draknek & Friends years ago, I knew I wanted to sit down with Alan Hazelden and chat about the team, puzzle games, and much more. | Read more »
The Latest ‘Marvel Snap’ OTA Update Buff...
I don’t know about all of you, my fellow Marvel Snap (Free) players, but these days when I see a balance update I find myself clenching my… teeth and bracing for the impact to my decks. They’ve been pretty spicy of late, after all. How will the... | Read more »
‘Honkai Star Rail’ Version 2.4 “Finest D...
HoYoverse just announced the Honkai Star Rail (Free) version 2.4 “Finest Duel Under the Pristine Blue" update alongside a surprising collaboration. Honkai Star Rail 2.4 follows the 2.3 “Farewell, Penacony" update. Read about that here. | Read more »
‘Vampire Survivors+’ on Apple Arcade Wil...
Earlier this month, Apple revealed that poncle’s excellent Vampire Survivors+ () would be heading to Apple Arcade as a new App Store Great. I reached out to poncle to check in on the DLC for Vampire Survivors+ because only the first two DLCs were... | Read more »
Homerun Clash 2: Legends Derby opens for...
Since launching in 2018, Homerun Clash has performed admirably for HAEGIN, racking up 12 million players all eager to prove they could be the next baseball champions. Well, the title will soon be up for grabs again, as Homerun Clash 2: Legends... | Read more »
‘Neverness to Everness’ Is a Free To Pla...
Perfect World Games and Hotta Studio (Tower of Fantasy) announced a new free to play open world RPG in the form of Neverness to Everness a few days ago (via Gematsu). Neverness to Everness has an urban setting, and the two reveal trailers for it... | Read more »
Meditative Puzzler ‘Ouros’ Coming to iOS...
Ouros is a mediative puzzle game from developer Michael Kamm that launched on PC just a couple of months back, and today it has been revealed that the title is now heading to iOS and Android devices next month. Which is good news I say because this... | Read more »

Price Scanner via MacPrices.net

Amazon is still selling 16-inch MacBook Pros...
Prime Day in July is over, but Amazon is still selling 16-inch Apple MacBook Pros for $500-$600 off MSRP. Shipping is free. These are the lowest prices available this weekend for new 16″ Apple... Read more
Walmart continues to sell clearance 13-inch M...
Walmart continues to offer clearance, but new, Apple 13″ M1 MacBook Airs (8GB RAM, 256GB SSD) online for $699, $300 off original MSRP, in Space Gray, Silver, and Gold colors. These are new MacBooks... Read more
Apple is offering steep discounts, up to $600...
Apple has standard-configuration 16″ M3 Max MacBook Pros available, Certified Refurbished, starting at $2969 and ranging up to $600 off MSRP. Each model features a new outer case, shipping is free,... Read more
Save up to $480 with these 14-inch M3 Pro/M3...
Apple has 14″ M3 Pro and M3 Max MacBook Pros in stock today and available, Certified Refurbished, starting at $1699 and ranging up to $480 off MSRP. Each model features a new outer case, shipping is... Read more
Amazon has clearance 9th-generation WiFi iPad...
Amazon has Apple’s 9th generation 10.2″ WiFi iPads on sale for $80-$100 off MSRP, starting only $249. Their prices are the lowest available for new iPads anywhere: – 10″ 64GB WiFi iPad (Space Gray or... Read more
Apple is offering a $50 discount on 2nd-gener...
Apple has Certified Refurbished White and Midnight HomePods available for $249, Certified Refurbished. That’s $50 off MSRP and the lowest price currently available for a full-size Apple HomePod today... Read more
The latest MacBook Pro sale at Amazon: 16-inc...
Amazon is offering instant discounts on 16″ M3 Pro and 16″ M3 Max MacBook Pros ranging up to $400 off MSRP as part of their early July 4th sale. Shipping is free. These are the lowest prices... Read more
14-inch M3 Pro MacBook Pros with 36GB of RAM...
B&H Photo has 14″ M3 Pro MacBook Pros with 36GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 Pro MacBook Pro (... Read more
14-inch M3 MacBook Pros with 16GB of RAM on s...
B&H Photo has 14″ M3 MacBook Pros with 16GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $150-$200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 MacBook Pro (... Read more
Amazon is offering $170-$200 discounts on new...
Amazon is offering a $170-$200 discount on every configuration and color of Apple’s M3-powered 15″ MacBook Airs. Prices start at $1129 for models with 8GB of RAM and 256GB of storage: – 15″ M3... Read more

Jobs Board

*Apple* Systems Engineer - Chenega Corporati...
…LLC,** a **Chenega Professional Services** ' company, is looking for a ** Apple Systems Engineer** to support the Information Technology Operations and Maintenance Read more
Solutions Engineer - *Apple* - SHI (United...
**Job Summary** An Apple Solution Engineer's primary role is tosupport SHI customers in their efforts to select, deploy, and manage Apple operating systems and Read more
*Apple* / Mac Administrator - JAMF Pro - Ame...
Amentum is seeking an ** Apple / Mac Administrator - JAMF Pro** to provide support with the Apple Ecosystem to include hardware and software to join our team and Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.