Using the BIOS Object
Information in this topic can be used with any program that supports using 32-bit OLE servers, such as Visual Basic 4 and higher, and VBScript.
In the December 1999 issue of Computer Shopper, Mike James' Program Control column described creating an object with a similar interface to the old BASIC interface. I have adopted his idea and created the BIOS object, where BIOS stands for BASIC Input/Output System. This article describes how to use my BIOS object.
Please note that the BIOS object hasn't been updated since, well, 1999. One day soon, I may build a new version of it in VB6, fixing a few bugs and adding a few new features.
Creating an instance of the BIOS object is simple. Simply use the CreateObject function under Visual Basic, as follows:
Dim objBIOS As Object
Private Sub Command1_Click()
Set objBIOS = CreateObject("ScriptUtil.BIOS")
You need the Init method to display the BIOS window, because I had a couple of problems with loads of copies of BIOS loading when I was using BIOS in a web page as an ActiveX control.
Now lets get on with using the object. Printing will be our first topic.
The BIOS object supports a BIOSPrint command which you can use to print with. You can't use the Print string1; string2; style as you could with traditional BASIC (and still can do with VB), but you can seperate variables with commas, or simply have one string. Lets use the Visual Basic InputBox to display messages on the BIOS:
Dim PrintString As String
Dim PrintString2 As String
PrintString = InputBox("Enter a message:", "BIOS")
PrintString2 = InputBox("Enter another message:","BIOS")
objBIOS.BIOSPrint "Read These Messages:", PrintString, PrintString2
This will display the text you entered, separated by tabs:
Now comes another powerful feature - the BIOSInput method. This lets you input text from the keyboard. You can either supply the function with an output variable, or an output variable and a prompt. The next example prompts the user for a name and prints it.
Dim InputString As String
Dim InputString2 As String
objBIOS.BIOSInput "What is your first name", InputString
objBIOS.BIOSInput "What is your last name", InputString2
objBIOS.BIOSPrint "Nice to meet you, " & InputString & " " & InputString2 & "."
You will notice that you need to explicitly print the new-line character. This is required because of a little bug in BIOS.
BackColour sets the background colour of the BIOS window. You can use system colour constants as well as RGB-colour values.
Caption sets the caption of the BIOS window.
Cls clears the BIOS window.
Height and Width set the heights and widths of the BIOS window in twips.
You can distribute and use BIOS in web pages and programs. You can put BIOS in a cabinet and use that to install it on the end-user's computer. I have created a cabinet called ScriptUtl.cab that installs BIOS. However, the Visual Basic 4.0 runtime files must be on the target computer. Please also note that this cabinet is not digitally signed, so IE will likely reject it. (If it doesn't, your security settings are set too low - it's not a good idea in this day and age to allow unsigned ActiveX controls, etc, to be installed!) The following code should create an object called objBIOS for you:
<object name="objBIOS" classid="clsid:8189BB3C-B0B6-11D3-96B6-819587A9BE4C" codebase="ScriptUtl.cab#Version=1,0,0,9" border="0" width="1" height="1"></object>
If you are going to distribute BIOS, you must put the following notice in the page:
BIOS: Created by Owen Rudge
See http://www.owenrudge.net/vb/bios for more information.
I will not be held responsible for any losses caused by use of the BIOS Object. It has not worked perfectly on my computer, especially when used in web pages, but has been fine in Visual Basic. Please send me feedback about how you are getting on.