OPERATING SYSTEM SELECTION

© 2003, Jason Herbert

author email:

aceUSMC@aol.com

Home

Tip Cornner

Alyce's Favorite LB Sites

Haiku For Programmers

Haiku Generator

API File Operations

OS Selection

Binary Coding

Beginning Programming 3

DatePup32 DLL

Newsletter Help

Index

Want to be able to handle multiple operatng systems?

Hey LB'ers! This is Jason Herbert (A.K.A. "ACE") This article explains what I did to create a simple GUI "front" for programs that have different versions for different OS's. First I wanted an array for adding the different options available...

So I put this at the top of the program:

dim operating$(8)

I had 9 options so I "dim" 'ed an array of "8", using 0 to 8 it gives me the needed 9 options.

I didn't want a main window so I eliminated it...

nomainwin

Then I set the regular options...

WindowWidth = 200
WindowHeight = 175

I used the array variable "operating$( )" to set my options...

operating$(0)= "Windows 3.1"
operating$(1)= "Windows 95"
operating$(2)= "Windows 98"
operating$(3)= "Windows 2000"
operating$(4)= "Windows ME"
operating$(5)= "Windows XP"
operating$(6)= "Windows (16-bit Operating System)"
operating$(7)= "Windows (32-bit Operating System)"
operating$(8)= "Linux\Unix\BeOS\Other"

As you can see I set it for 9 options not wanting to limit the user. Then I asked the user to select his/her operating system and provide a listbox to select from available options...

Statictext #main, "Please select your operating system:", 10, 15, 190, 20
listbox #main.os, operating$(), [select], 40, 40, 100, 20

Here I open my window with an appropriate title...

open "Operating System Select" for window as #main

And set the close (big "X" on window's upper right corner) button

#main, "trapclose [quit]"

And then have the computer wait for user input...

wait

I set the closing programs options...

[quit]
close #main
end

And then used a "select case" thingy to find the option the user speciefied...

[select]
print #main.os, "singleclickselect"
print #main.os, "selection? selected$"

And then used a "select case" thingy to find the option the user specified option and have the program find the correct response to that option

Select Case selected$

   Case "Windows 3.1"
        Notice "You have selected a 16-bit Windows OS"
        goto [16bit]
   Case "Windows 95"
        Notice "You have selected a 16-bit Windows OS"
        goto [16bit]
   Case "Windows 98"
        Notice "You have selected a 32-bit Windows OS"
        goto [32bit]
   Case "Windows 2000"
        Notice "You have selected a 32-bit Windows OS"
        goto [32bit]
   Case "Windows ME"
        Notice "You have selected a 32-bit Windows OS"
        goto [32bit]
   Case "Windows XP"
        Notice "You have selected a 32-bit Windows OS"
        goto [32bit]
   Case "Windows (16-bit Operating System)"
        Notice "You have selected a 16-bit Windows OS"
        goto [16bit]
   Case "Windows (32-bit Operating System)"
        Notice "You have selected a 32-bit Windows OS"
        goto [32bit]

Since Liberty Basic only runs on certain OS's I had to add an "other" field to tell the user that it wasn't available.

   Case "Linux\Unix\BeOS\Other"
        Notice "Sorry this program only runs on windows!"
End Select
wait

[16bit]

Here is where I would run the 16-bit version of my program...

'run 16-bit program version
'run dir\filename.ext
notice "Running 16-bit program"
wait

[32bit]

And here is where I would run the 32-bit version of my program...

'run 32-bit program version
'run dir\filename.ext
notice "Running 32-bit program"
wait

There are two ways of running different progs. One, put the two different program's code under the appropriate branch. Two, tokenize the programs and direct the first program (the one above) to the appropriate directory. The latter, I believe, is the better way to go... for two reasons it allows for faster programming execution and it provides a cleaner, more professional look. Here is the complete version.


[Editors Note: An interesting article. One possible enhancement would be to automatically detect the users OS using a windows API call, then suggesting this as the OS of choice in the listbox. I would also consider using a Combobox, as the user can see all the possible choices. Note that you must double-click to select the choice. A button that said "Run My Application" (naming the application) would be more intuitive as well if I were making changes. A great idea non-the-less. Thanks Jason - Brad]


Here is the program

Simply select the program, copy (using the right mouse click and select copy) and then paste it into LB3 and go...


dim operating$(8)
nomainwin

WindowWidth = 200
WindowHeight = 175

operating$(0)= "Windows 3.1"
operating$(1)= "Windows 95"
operating$(2)= "Windows 98"
operating$(3)= "Windows 2000"
operating$(4)= "Windows ME"
operating$(5)= "Windows XP"
operating$(6)= "Windows (16-bit Operating System)"
operating$(7)= "Windows (32-bit Operating System)"
operating$(8)= "Linux\Unix\BeOS\Other"
Statictext #main, "Please select your operating system:", 10, 15, 190, 20
listbox #main.os, operating$(), [select], 40, 40, 100, 20
open "Operating System Select" for window as #main
#main, "trapclose [quit]"
wait

[quit]
close #main
end

[select]
print #main.os, "singleclickselect"
print #main.os, "selection? selected$"

Select Case selected$

   Case "Windows 3.1"
        Notice "You have selected a 16-bit Windows OS"
        goto [16bit]
   Case "Windows 95"
        Notice "You have selected a 16-bit Windows OS"
        goto [16bit]
   Case "Windows 98"
        Notice "You have selected a 32-bit Windows OS"
        goto [32bit]
   Case "Windows 2000"
        Notice "You have selected a 32-bit Windows OS"
        goto [32bit]
   Case "Windows ME"
        Notice "You have selected a 32-bit Windows OS"
        goto [32bit]
   Case "Windows XP"
        Notice "You have selected a 32-bit Windows OS"
        goto [32bit]
   Case "Windows (16-bit Operating System)"
        Notice "You have selected a 16-bit Windows OS"
        goto [16bit]
   Case "Windows (32-bit Operating System)"
        Notice "You have selected a 32-bit Windows OS"
        goto [32bit]
   Case "Linux\Unix\BeOS\Other"
        Notice "Sorry this program only runs on windows!"
End Select
wait

[16bit]
'run 16-bit program version
'run dir\filename.ext
notice "Running 16-bit program"
wait
[32bit]
'run 32-bit program version
'run dir\filename.ext
notice "Running 32-bit program"
wait


Home

Tip Cornner

Alyce's Favorite LB Sites

Haiku For Programmers

Haiku Generator

API File Operations

OS Selection

Binary Coding

Beginning Programming 3

DatePup32 DLL

Newsletter Help

Index