Hello everyone and Happy New Year. To start the new year (2016) off right, I wanted to begin a new lesson planer on programming in Alpha Software. The functions and xbasic code we will look at are specific to Alpha Software, but the principles will apply to all programming languages.
Purpose of a Program and or Application:
Programs are created for many reasons;
- Improve Productivity
- Store Information
- Retrieve Information
- Analyze Information
- Solve problems
- Make people happy
- Waste time
and many more. In fact a programs design is only limited to a developers imagination and society’s need. Many needs are physical and our senses give us immediate feedback of the world around us. Example of programs in this vein are programs which help us see beyond the eye’s capability, programs which capture the world around us, or analyze large volumes of information etc.. These programs are not written for the masses rather for specific needs and if done well they can command high fees but have a small market.
Our senses also lend itself to our fancies or moods and compulsions happiness, sadness, desire etc.. These programs are designed for the masses and command small fees but huge sales if done right. (They have an app for that.) What you design is not our interest here rather how you design it.
Alpha Software’s bread and butter is it’s ease of use for developing business applications. Their many wizard’s and genie’s along with drag and drop form design make short work of building a business application. Now with web and mobile integration they offer a complete solution. The application you develop however may not fit in the norm of the wizards and genies so you will have to learn some xbasic in order to make the application exceed the customers requirements.
xBasic:
xBasic code like all code languages simply put, is programming commands. Windows has a computer language which controls the computer. xBasic is Alpha Software’s way of communication with Windows thus the computer. The code you write tells the computer what to do and which actions to perform. When you write a routine in xBasic and save it, it’s called a script. The script list the xBasic commands and functions in a sequence which makes sense and controls the action. For example, you cannot tell the computer to fetch a record in a table if you have not first opened the table. Look at the code below.
t = table.open(“calc_detail”)
t.pack()
t.close()
The above script opens a table called calc_detail, packs the table then closes the table. Notice that each line ends with ‘( )’. This tells you the command before the brackets is a function. A function is code written and stored by Alpha software or the user for use in xBasic scripts. A function is an xBasic command which may or may not take optional values as input and returns an answer for use by the calling script. The table open function only requires a valid table name be passed to it. The table is then assigned to a pointer, (t) then the pack and close functions work with the pointer. As you may imagine, a pointer is a variable which references an object. In this case it is the calc_detail.dbf file.
Now that script is very simple and easy to understand. Others appear to be more complicated but in fact are written exactly the same. The next script is from our calculator on our Desktop App. It is attached to the onPush event of our Convert Button on the calculator.
‘1. First we declare our variables for our popup menudim SHARED conver as N dim SHARED cvlabel as C dim SHARED mymenu as C‘2. Next we set the menu style style = <<%str% menu.v_item_min_leftx=.25 color.menu_v_background=Dirty White color.menu_v_left=Dark Red color.menu_v_right=White font.menu=Tahoma,8,0 %str%‘3. Then we display the menu options vMenuItems = <<%a% Length|Inches|01 To Centimeters Length|Inches|02 To Feet Length|Inches|03 To Yards Length|Inches|04 To Miles Length|Centimeters|05 To Inches Length|Centimeters|06 To Meters Length|Centimeters|07 To Kilometers Length|Feet|08 To Meters Length|Feet|09 To Inches Length|Feet|10 To Yards Length|Feet|11 To Miles Length|Meters|12 To Feet Length|Meters|13 To Centimeters Length|Meters|14 To Kilometers Length|Yards|15 To Inches Length|Yards|16 To Feet Length|Yards|17 To Miles Length|Miles|18 To Kilometers Length|Miles|19 To Inches Length|Miles|20 To Feet Length|Miles|21 To Yards Length|Kilometers|22 To Miles Length|Kilometers|23 To Centimeters Length|Kilometers|24 To Meters Liquids|Teaspoon|25 To Ounce Liquids|Teaspoon|26 To Tablespoon Liquids|Tablespoon|27 To Ounce Liquids|Tablespoon|28 To Teaspoon Liquids|Ounce|29 To Teaspoon Liquids|Ounce|30 To Tablespoon Liquids|Ounce|31 To Cup Liquids|Ounce|32 To Pint Liquids|Ounce|33 To Fifth Liquids|Ounce|34 To Quart Liquids|Ounce|35 To Half Gallon Liquids|Ounce|36 To Gallon Liquids|Cup|37 To Ounce Liquids|Cup|38 To Pint Liquids|Cup|39 To Fifth Liquids|Cup|40 To Quart Liquids|Cup|41 To Half Gallon Liquids|Cup|42 To Gallon Liquids|Pint|43 To Ounce Liquids|Pint|44 To Cup Liquids|Pint|45 To Fifth Liquids|Pint|46 To Quart Liquids|Pint|47 To Half Gallon Liquids|Pint|48 To Gallon Liquids|Fifth|49 To Ounce Liquids|Fifth|50 To Cup Liquids|Fifth|51 To Pint Liquids|Fifth|52 To Quart Liquids|Fifth|53 To Half Gallon Liquids|Fifth|54 To Gallon Liquids|Quart|55 To Ounce Liquids|Quart|56 To Cup Liquids|Quart|57 To Pint Liquids|Quart|58 To Fifth Liquids|Quart|59 To Half Gallon Liquids|Quart|60 To Gallon Liquids|Half Gallon|61 To Ounce Liquids|Half Gallon|62 To Cup Liquids|Half Gallon|63 To Pint Liquids|Half Gallon|64 To Fifth Liquids|Half Gallon|65 To Quart Liquids|Half Gallon|66 To Gallon Liquids|Gallon|67 To Ounce Liquids|Gallon|68 To Cup Liquids|Gallon|69 To Pint Liquids|Gallon|70 To Fifth Liquids|Gallon|71 To Quart Liquids|Gallon|72 To Half Gallon Time|Hundreth's|73 To Minutes Time|Seconds|74 To Minutes Time|Seconds|75 To Moments Time|Seconds|76 To Hours Time|Seconds|77 To Days Time|Minutes|78 To Seconds Time|Minutes|79 To Hundreth's Time|Minutes|80 To Hours Time|Minutes|81 To Moments Time|Minutes|82 To Days Time|Minutes|83 To Weeks Time|Minutes|84 To Fortnight Time|Minutes|85 To Months Time|Minutes|86 To Years Time|Moments|87 To Seconds Time|Moments|88 To Hours Time|Moments|89 To Days Time|Moments|90 To Weeks Time|Moments|91 To Fortnight Time|Moments|92 To Months Time|Moments|93 To Years Time|Hours|94 To Seconds Time|Hours|95 To Minutes Time|Hours|96 To Moments Time|Hours|97 To Days Time|Hours|98 To Weeks Time|Hours|99 To Fortnight Time|Hours|100To Months Time|Hours|101To Years Time|Days|102To Seconds Time|Days|103To Minutes Time|Days|104To Moments Time|Days|105To Hours Time|Days|106To Weeks Time|Days|107To Fortnight Time|Days|108To Months Time|Days|109To Years Time|Weeks|110To Seconds Time|Weeks|111To Minutes Time|Weeks|112To Moments Time|Weeks|113To Hours Time|Weeks|114To Days Time|Weeks|115To Fortnight Time|Weeks|116To Months Time|Weeks|117To Years Time|Fortnight|118To Seconds Time|Fortnight|119To Minutes Time|Fortnight|120To Moments Time|Fortnight|121To Hours Time|Fortnight|122To Days Time|Fortnight|123To Weeks Time|Fortnight|124To Months Time|Fortnight|125To Years Time|Month|126To Seconds Time|Month|127To Minutes Time|Month|128To Moments Time|Month|129To Hours Time|Month|130To Days Time|Month|131To Weeks Time|Month|132To Fortnight Time|Month|133To Years Time|Year|134To Seconds Time|Year|135To Minutes Time|Year|136To Moments Time|Year|137To Hours Time|Year|138To Days Time|Year|139To Weeks Time|Year|140To Fortnight Time|Year|141To Months %a%‘4. Now we capture the user input mymenu = ui_popup_styled_menu(vMenuItems, style) if mymenu = "" then end end if if mymenu = "01 To Centimeters" Then conver = 2.54 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Inches to Centimeters" goto cvert else if mymenu = "02 To Feet" Then conver = 12 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Inches to Feet" goto cvert else if mymenu = "03 To Yards" Then conver = 36 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Inches to Yards" goto cvert else if mymenu = "04 To Miles" Then conver = 63360 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Inches to Miles" goto cvert else if mymenu = "05 To Inches" Then conver = 2.54 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Centimeters to Inches" goto cvert else if mymenu = "06 To Meters" Then conver = 100 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Centimeters to Meters" goto cvert else if mymenu = "07 To Kilometers" Then conver = 100000 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Centimeters to Kilometers" goto cvert else if mymenu = "08 To Meters" Then conver = 3.2808399 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Feet to Meters" goto cvert else if mymenu = "09 To Inches" Then conver = 12 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Feet to Inches" goto cvert else if mymenu = "10 To Yards" Then conver = 3 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Feet to Yards" goto cvert else if mymenu = "11 To Miles" Then conver = 5280 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Feet to Miles" goto cvert else if mymenu = "12 To Feet" Then conver = 3.2808399 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Meters to Feet" goto cvert else if mymenu = "13 To Centimeters" Then conver = 100 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Meters to Centimeters" goto cvert else if mymenu = "14 To Kilometers" Then conver = 1000 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Meters to Kilometers" goto cvert else if mymenu = "15 To Inches" Then conver = 36 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Yards to Inches" goto cvert else if mymenu = "16 To Feet" Then conver = 3 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Yards to Feet" goto cvert else if mymenu = "17 To Miles" Then conver = 1760 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Yards to Miles" goto cvert else if mymenu = "18 To Kilometers" Then conver = 1.609344 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Miles to Kilometers" goto cvert else if mymenu = "19 To Inches" Then conver = 63360 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Miles to Inches" goto cvert else if mymenu = "20 To Feet" Then conver = 5280 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Miles to Feet" goto cvert else if mymenu = "21 To Yards" Then conver = 1760 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Miles to Yards" goto cvert else if mymenu = "22 To Miles" Then conver = .62137 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Kilometers to Miles" goto cvert else if mymenu = "23 To Centimeters" Then conver = 100000 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Kilometers to Centimeters" goto cvert else if mymenu = "24 To Meters" Then conver = 1000 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Kilometers to Meters" goto cvert else if mymenu = "25 To Ounce" Then conver = 6 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Teaspoon to Ounce" goto cvert else if mymenu = "26 To Tablespoon" Then conver = 3 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Teaspoons to Tablespoons" goto cvert else if mymenu = "27 To Ounce" Then conver = .5 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Tablespoon to Ounce" goto cvert else if mymenu = "28 To Teaspoon" Then conver = 3 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Tablespoon to Teaspoon" goto cvert else if mymenu = "29 To Teaspoon" Then conver = 6 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Ounce to Teaspoon" goto cvert else if mymenu = "30 To Tablespoon" Then conver = 2 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Ounce to Tablespoon" goto cvert else if mymenu = "31 To Cup" Then conver = 8 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Ounce to Cup" goto cvert else if mymenu = "32 To Pint" Then conver = 16 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Ounce to Pint" goto cvert else if mymenu = "33 To Fifth" Then conver = 25.6 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Ounces to Fifth" goto cvert else if mymenu = "34 To Quart" Then conver = 32 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Ounce to Quart" goto cvert else if mymenu = "35 To Half Gallon" Then conver = 64 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Ounce to Half Gallon" goto cvert else if mymenu = "36 To Gallon" Then conver = 128 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Ounce to Gallon" goto cvert else if mymenu = "37 To Ounce" Then conver = 8 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Cup to Ounces" goto cvert else if mymenu = "38 To Pint" Then conver = 2 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Cup to Pints" goto cvert else if mymenu = "39 To Fifth" Then conver = 3.2 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Cup to Fifth's" goto cvert else if mymenu = "40 To Quart" Then conver = 4 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Cup to Quart's" goto cvert else if mymenu = "41 To Half Gallon" Then conver = 8 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Cup to Half Gallons" goto cvert else if mymenu = "42 To Gallon" Then conver = 16 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Cup to Gallons" goto cvert else if mymenu = "43 To Ounce" Then conver = 16 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Pint to Ounces" goto cvert else if mymenu = "44 To Cup" Then conver = 2 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Pint to Cups" goto cvert else if mymenu = "45 To Fifth" Then conver = 1.60 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Pint to Fifth" goto cvert else if mymenu = "46 To Quart" Then conver = 2 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Pint to Quart" goto cvert else if mymenu = "47 To Half Gallon" Then conver = 4 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Pint to Half Gallon" goto cvert else if mymenu = "48 To Gallon" Then conver = 8 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Pint to Gallon" goto cvert else if mymenu = "49 To Ounce" Then conver = 25.6 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Fifth to Ounces" goto cvert else if mymenu = "50 To Cup" Then conver = 3.2 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Fifth to cup" goto cvert else if mymenu = "51 To Pint" Then conver = 1.6 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Fifth to Pints" goto cvert else if mymenu = "52 To Quart" Then conver = 1.25 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Fifth to Quart" goto cvert else if mymenu = "53 To Half Gallon" Then conver = 2.5 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Fifth to Half Gallon" goto cvert else if mymenu = "54 To Gallon" Then conver = 5 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Fifth to Gallon" goto cvert else if mymenu = "55 To Ounce" Then conver = 32 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Quart to Ounces" goto cvert else if mymenu = "56 To Cup" Then conver = 4 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Quart to Cups" goto cvert else if mymenu = "57 to Pint" Then conver = 2 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Quart to Pints" goto cvert else if mymenu = "58 To Fifth" Then conver = 1.25 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Quart to Fifth" goto cvert else if mymenu = "59 To Half Gallon" Then conver = 2 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Quart to Half Gallon" goto cvert else if mymenu = "60 To Gallon" Then conver = 4 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Quart to Gallons" goto cvert else if mymenu = "61 To Ounce" Then conver = 64 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Half Gallon to Ounces" goto cvert else if mymenu = "62 To Cup" Then conver = 8 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Half Gallon to Cups" goto cvert else if mymenu = "63 To Pint" Then conver = 4 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Half Gallon to Pints" goto cvert else if mymenu = "64 To Fifth" Then conver = 2.5 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Half Gallon to Fifths" goto cvert else if mymenu = "65 To Quart" Then conver = 2 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Half Gallon to Quarts" goto cvert else if mymenu = "66 To Gallon" Then conver = 2 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Half Gallon to Gallons" goto cvert else if mymenu = "67 To Ounce" Then conver = 128 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Gallon to Ounces" goto cvert else if mymenu = "68 To Cup" Then conver = 16 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Gallon to Cups" goto cvert else if mymenu = "69 To Pint" Then conver = 8 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Gallon to Pints" goto cvert else if mymenu = "70 To Fifth" Then conver = 5 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Gallon to Fifths" goto cvert else if mymenu = "71 To Quart" Then conver = 4 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Gallon to Quarts" goto cvert else if mymenu = "72 To Half Gallon" Then conver = 2 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Gallon to Half Gallons" goto cvert else if mymenu = "73 To Minutes" Then conver = .6 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Hundreth's to Minutes" goto cvert else if mymenu = "74 To Minutes" Then conver = 60 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Seconds to Minutes" goto cvert else if mymenu = "75 To Moments" Then conver = 90 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Seconds to Moments" goto cvert else if mymenu = "76 To Hours" Then conver = 3600 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Seconds to Hours" goto cvert else if mymenu = "77 To Days" Then conver = 86400 vLastEntry = vLastAns/conver vOpr = "*" cvlabel = "Seconds to Days" goto cvert else if mymenu = "78 To Seconds" Then conver = 60 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Minutes to Seconds" goto cvert else if mymenu = "79 To Hundreth's" Then conver = .6 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Minutes to Hundreths" goto cvert else if mymenu = "80 To Hours" Then conver = 60 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Minutes to Hours" goto cvert else if mymenu = "81 To Moments" Then conver = 1.5 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Minutes to Moments" goto cvert else if mymenu = "82 To Days" Then conver = 1440 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Minutes to Days" goto cvert else if mymenu = "83 To Weeks" Then conver = 10080 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Minutes to Weeks" goto cvert else if mymenu = "84 To Fortnight" Then conver = 20160 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Minutes to Fortnights" goto cvert else if mymenu = "85 To Months" Then conver = 43829.1 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Minutes to Months" goto cvert else if mymenu = "86 To Years" Then conver = 525949.2 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Minutes to Years" goto cvert else if mymenu = "87 To Seconds " Then conver = 90 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Moments to Seconds" goto cvert else if mymenu = "88 To Hours" Then conver = 40 vLastEntry = vLastAns/conver vOpr = "" cvlabel = "Moments to Hours" goto cvert else if mymenu = "89 To Days" Then conver = 960 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Moments to Days" goto cvert else if mymenu = "90 To Weeks" Then conver = 6720 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Moments to Weeks" goto cvert else if mymenu = "91 To Fortnight" Then conver = 13440 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Moments to Fortnight" goto cvert else if mymenu = "92 To Months" Then conver = 29219.4 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Moments to Months" goto cvert else if mymenu = "93 To Years" Then conver = 350632.8 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Moments to Years" goto cvert else if mymenu = "94 To Seconds" Then conver = 3600 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Hours to Seconds" goto cvert else if mymenu = "95 To Minutes" Then conver = 60 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Hours to Minutes" goto cvert else if mymenu = "96 To Moments" Then conver = 40 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Hours to Moments" goto cvert else if mymenu = "97 To Days" Then conver = 24 vLastEntry = vLastAns/conver vOpr = "" cvlabel = "Hours to Days" goto cvert else if mymenu = "98 To Weeks" Then conver = 168 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Hours to Weeks" goto cvert else if mymenu = "99 To Fortnight" Then conver = 336 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Hours to Fortnights" goto cvert else if mymenu = "100To Months" Then conver = 730.485 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Hours to Months" goto cvert else if mymenu = "101To Years" Then conver = 8765.82 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Hours to Years" goto cvert else if mymenu = "102To Seconds" Then conver = 86400 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Days to Seconds" goto cvert else if mymenu = "103To Minutes" Then conver = 1440 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Days to Minutes" goto cvert else if mymenu = "104To Moments" Then conver = 960 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Days to Moments" goto cvert else if mymenu = "105To Hours" Then conver = 24 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Days to Hours" goto cvert else if mymenu = "106To Weeks" Then conver = 7 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Days to Weeks" goto cvert else if mymenu = "107To Fortnight" Then conver = 14 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Days to Fortnights" goto cvert else if mymenu = "108To Months" Then conver = 30.436875 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Days to Months" goto cvert else if mymenu = "109To Years" Then conver = 365.2425 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Days to Years" goto cvert else if mymenu = "110To Seconds" Then conver = 604800 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Weeks to Seconds" goto cvert else if mymenu = "111To Minutes" Then conver = 10080 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Weeks to Minutes" goto cvert else if mymenu = "112To Moments" Then conver = 6720 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Weeks to Moments" goto cvert else if mymenu = "113To Hours" Then conver = 168 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Weeks to Hours" goto cvert else if mymenu = "114To Days" Then conver = 7 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Weeks to Days" goto cvert else if mymenu = "115To Fortnight" Then conver = 2 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Weeks to Fortnight" goto cvert else if mymenu = "116To Months" Then conver = 4.3333 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Weeks to Months" goto cvert else if mymenu = "117To Years" Then conver = 52 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Weeks to Years" goto cvert else if mymenu = "118To Seconds" Then conver = 1209600 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Fortnight to Seconds" goto cvert else if mymenu = "119To Minutes" Then conver = 20160 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Fortnight to Minutes" goto cvert else if mymenu = "120To Moments" Then conver = 13400 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Fortnight to Moments" goto cvert else if mymenu = "113To Hours" Then conver = 336 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Fortnight to Hours" goto cvert else if mymenu = "114To Days" Then conver = 14 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Fortnight to Days" goto cvert else if mymenu = "123To Weeks" Then conver = 2 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Fortnight to Weeks" goto cvert else if mymenu = "124To Months" Then conver = 2.174 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Fortnight to Months" goto cvert else if mymenu = "125To Years" Then conver = 26.089 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Fortnight to Years" goto cvert else if mymenu = "126To Seconds" Then conver = 2629746 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Months to Seconds" goto cvert else if mymenu = "127To Minutes" Then conver = 43829 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Months to Minutes" goto cvert else if mymenu = "128To Moments" Then conver = 29219.4 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Months to Moments" goto cvert else if mymenu = "129To Hours" Then conver = 730.485 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Months to Hours" goto cvert else if mymenu = "130To Days" Then conver = 30.436875 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Months to Days" goto cvert else if mymenu = "131To Weeks" Then conver = 4.348 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Months to Weeks" goto cvert else if mymenu = "132To Fortnight" Then conver = 2.174 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Months to Fortnight" goto cvert else if mymenu = "133To Years" Then conver = 12 vLastEntry = vLastAns/conver vOpr = "/" cvlabel = "Months to Years" goto cvert else if mymenu = "134To Seconds" Then conver = 31556952 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Years to Seconds" goto cvert else if mymenu = "135To Minutes" Then conver = 525949.2 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Years to Minutes" goto cvert else if mymenu = "136To Moments" Then conver = 350632.8 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Years to Moments" goto cvert else if mymenu = "137To Hours" Then conver = 8765.82 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Years to Hours" goto cvert else if mymenu = "138To Days" Then conver = 365.2425 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Years to Days" goto cvert else if mymenu = "139To Weeks" Then conver = 52 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Years to Weeks" goto cvert else if mymenu = "140To Fortnight" Then conver = 26.089 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Years to Fortnights" goto cvert else if mymenu = "141To Months" Then conver = 12 vLastEntry = vLastAns*conver vOpr = "*" cvlabel = "Year to Months" goto cvert end ifend cvert: ’5. Now we process the requested actiont = table.current() t.enter_begin() t.Date = Date() t.SAVECNT = vSaveCnt t.TAPETYPE = vTapeType t.TITLE = vTitle t.NVALUE = conver t.NANSWER = vLastAns t.Lineitemdesc = cvlabel t.Coperand = vOpr t.cVALUE = str(t.NValue,16,vDec,vFmtType) t.cANSWER = str(vLastAns,16,vDec,vFmtType) t.enter_end(.t.) vLastAns = t.NANSWER cdcTapeCalc:nanswer.entry.dec = vDec vLineItem = "" cdcTapeCalc:nanswer.entry.format = vFmtType 'cdcTapeCalc:browse1:nvalue.entry.dec = vDec 'cdcTapeCalc:browse1:nvalue.entry.format = vFmtType cdcTapeCalc:nanswer.refresh() cdcTapeCalc:vlineitem.Refresh() cdcTapeCalc.Fetch_Last() cdcTapeCalc:browse1.refresh()vLastAns = vLastEntry t = table.current() t.enter_begin() t.Date = Date() t.SAVECNT = vSaveCnt t.TAPETYPE = vTapeType t.TITLE = vTitle t.NVALUE = vLastEntry t.NANSWER = vLastAns t.Lineitemdesc = "Answer" t.Coperand = "=" t.cVALUE = str(t.NValue,16,vDec,vFmtType) t.cANSWER = str(vLastAns,16,vDec,vFmtType) t.enter_end(.t.)‘6. Finally we write the result and refresh our form and variables vLastAns = t.NANSWER cdcTapeCalc:nanswer.entry.dec = vDec vLineItem = "" cdcTapeCalc:nanswer.entry.format = vFmtType 'cdcTapeCalc:browse1:nvalue.entry.dec = vDec 'cdcTapeCalc:browse1:nvalue.entry.format = vFmtType cdcTapeCalc:nanswer.refresh() cdcTapeCalc:vlineitem.Refresh() cdcTapeCalc.Fetch_Last() cdcTapeCalc:browse1.refresh() cdcTapeCalc:btntapeedit.push()
Like the first example, this script simply organizes the code in an order which makes sense and displays the proper result.
Motion:
As stated above, when we run our script the xBasic code performs a series of actions which result in motion of an object. In most cases we simply move pixels around to change the image of the screen. Other times we may ring a bell, cause the printer to turn on and print, or turn on some other piece of equipment so it can perform an action. Since motion is the physical action we are performing, lets look at how motion affects our programs.
Everyone learns that if an object is still, it is still forever unless affected externally and if an object is moving, it moves continually unless affected externally. The same is true with the data in our tables. Once entered by the user, data just sits in the table until some action calls it and displays or prints or computes it. The external events in Alpha Software are in object Events. Objects such as forms, fields, and buttons are used to trigger code in response to mouse or keyboard input which then runs the calling event. The event then runs the code which is entered by you as you design the application. That code will hopefully return the information the user expects or a message if an error occurs
Alpha Software’s built in functions which can be used in your event code allow you to easily transform data, build and load array’s, query tables and much more. Are focus will look at how to use these functions to simplify your xBasic programming and we will look at many of then through out this year starting with
lookup()
The lookup function; one of my favorites; is used to search an external table for the first record which matches the filter set for the lookup and returns the value for the field requested. You can also use
- lookupc() – character value
- lookupd() – Date value
- lookupL() – Logical value
- lookupn() – Numeric value
Typically I will use the look up function to assign a value based on customer selection. In the Collectibles application we just finished I use the following lookup
lookupn(“F”, TRANS_ID,”seller_id”,”transaction_hdr”,”Trans_Id”)
in the field rules of the transaction_detail table. When the user enters a record in the transaction table they could select the seller ID from a lookup table but since the software already knows which seller is being used it looks up the value electronically based on trans_ID. This action takes place in the background and the user reaps the benefit without the input. (The seller ID is captured from the external table Sellers and moved-copied to transaction detail). There is a difference in the use of lookup and one of the other specific lookup functions. Lookup accepts a filter argument but others do not. They work using a key value and requires and index for searching the lookup table. Both functions will accept variables.
In our next session we will look at a practical application of the various lookup functions. I hope you will join us.
If you have questions or suggestions leave a comment and I will get back to you. As always I know your time is important and I appreciate you spending some of it with me. Have a great day.
Leave a comment