'------------------------------------------------------------------------------------------------
' EBAC Calculator v1.0 by George McGinn, MAY, 2021
' Copyright (C)2021 by George McGinn/Linux Software Systems
' All Rights Reserved.
'
' Program is designed to run as an App in iTunes to run specifically
' on an iPhone so those who would like to know their esitmate BAC and
' how long it will take to get to a level to drive safely and legally.
'
' Blood alcohol content (BAC) can be estimated by a method developed by
' Swedish professor Erik Widmark in the 1920s.
'
' Gives the estimated BAC (EBAC), algorhithm reduced as:
' EBAC=A/(r*Wt)*1.055-B*T (verified by Wiki source listed below)
' Where:
' EBAC: Estimated Blood Alcohol Content (%)
' A: Alcohol consumed (in ounces to grams) or FLoz
' r: Ratio of body water to total weight (men: .68, women: .55)
' Wt: Body weight (in pounds to kilograms)
' B: Rate alcohol metabolized (men: .019/hr, women: .017/hr)
' T: Time alcohol in blood or time since consumption began
' 1.055: Constant value of density of blood
'
' The formula can also be reduced as follows (called the 8/10 formula):
' For Men: EBAC = 7.97*A/Wt-B*T
' For Women: EBAC = 9.86*A/Wt-B*T
'
' Factors 7.97 and 9.86 are derived from "r" and 1.055.
' Also, this formula is geared to fluid ounces and pounds, not
' grams and kilograms. While the suggested values were 8 and 10,
' testing showed the results were not accurate. So I reworked it
' and found that 7.97 and 9.86 gives better results.
'
' It will be this reduced formula the program will use.
'
' Each shot, wine glass and bottle/can of beer contains .6oz of
' alcohol. User records the number of drinks, which will then be
' converted to ounces (drinks * .6)
'
' *** Formulas created/translated by George McGinn using the following sources:
' * Blood alcohol content can be estimated by a method developed
' by Swedish professor Erik Widmark [sv] in the 1920s.
' (https://web.archive.org/web/20031202155933/http://www.dui-law.com/810art.htm)
' * https://www.ou.edu/police/faid/blood-alcohol-calculator
' * https://www.gambonelaw.com/faqs/the-widmark-formula-and-calculating-your-bac-level/
' * https://en.wikipedia.org/wiki/Blood_alcohol_content
' * https://en.wikipedia.org/wiki/Binge_drinking
' * https://en.wikipedia.org/wiki/Alcohol_intoxication
' * https://en.wikipedia.org/wiki/Breathalyzer
' * https://ndaa.org/wp-content/uploads/toxicology_final.pdf
' * http://njlaw.rutgers.edu/collections/courts/supreme/a-96-06.doc.html
' * https://www.researchgate.net/profile/Alan-Jones-14/publication/318055507_Profiles_in_Forensic_Toxicology_Professor_Erik_Widmark_1889-1945/links/595794330f7e9ba95e0fd91d/Profiles-in-Forensic-Toxicology-Professor-Erik-Widmark-1889-1945.pdf?origin=publication_detail
' * https://www.cdc.gov/alcohol
'------------------------------------------------------------------------------------------------
'
' PROGRAM NOTES:
' --------------
' This blood alcohol content or BAC, for short, calculator can estimate
' your blood alcohol levels. Metabolism, body fat percentage and
' medication are other factors that can affect the rate of absorption
' by the body, and these are not considered in this calculation.
'
' Blood alcohol content (BAC) or blood alcohol level is the
' concentration of alcohol in the bloodstream. It is usually measured
' as mass per volume. For example, a Blood alcohol content BAC of
' 0.04% means 0.4% (permille) or 0.04 grams of alcohol per 100 grams
' of individual’s blood. Use this BAC Calculator for informational
' purposes only, and not to drink and drive or drink and work.
'
' Important Note: There is no BAC calculator that is 100% accurate.
' This is due to the number of factors that come into play regarding
' the consumption and alcohol processing rates of different people.
' Factors include the gender of the drinker (biologic, not identity),
' their differing metabolism rates, various health issues, and the
' combination of medications and supplements that might be taken by
' the drinker, drinking frequency, amount of food in the stomach and
' small intestine and when it was eaten, elapsed time, and other
' factors. The best that can be done is a rough estimation of the
' bloodstreams alcohol content or the BAC level based on known inputs.
'
' Every state in the U.S. has a legal Blood Alcohol (BAC) limit of
' 0.05% or 0.08%, (depending on the state you are driving in). Most
' states also have lower legal BAC limits for young and inexperienced
' drivers, professional drivers and commercial drivers. Sentences for
' drunk driving include imprisonment, large fines, lengthy drivers
' license suspension and/or revocation, house arrest, community
' service, DUI schools, alcohol treatment programs, vehicle forfeiture
' and ignition interlock restrictions.
'
'------------------------------------------------------------------------------------------------
' Program Copyright (C)2021 by George McGinn/Pyramid Software Systems
' All Rights Reserved.
'
' EBAC Calculator by George McGinn is licensed under a Creative Commons
' Attribution-NonCommercial 4.0 International License.
'
' Full License Link: https://creativecommons.org/licenses/by-nc/4.0/
'
'
' You are free to (For non-commerical purposes only):
' Share - copy and redistribute the material in any medium or format.
' Adapt - remix, transform, and build upon the material.
' Attribution - You must give appropriate credit, provide a link to
' the license, and indicate if changes were made. You may do so in any
' reasonable manner, but not in any way that suggests the licensor
' endorses you or your use.
' Non Commercial - You may not use the material for commercial purposes.
'
' *** None of this code is considered in the Public Domain. Rights granted under CC 4.0
' are outlined as above and the disclaimer below:
'
' *** DISCLAIMER ***
' Unless otherwise separately undertaken by the Licensor, to the extent possible,
' the Licensor offers the Licensed Material as-is and as-available, and makes no
' representations or warranties of any kind concerning the Licensed Material, whether
' express, implied, statutory, or other. This includes, without limitation, warranties
' of title, merchantability, fitness for a particular purpose, non-infringement, absence
' of latent or other defects, accuracy, or the presence or absence of errors, whether or
' not known or discoverable. Where disclaimers of warranties are not allowed in full or
' in part, this disclaimer may not apply to You.
'
' To the extent possible, in no event will the Licensor be liable to You on any legal theory
' (including, without limitation, negligence) or otherwise for any direct, special, indirect,
' incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages
' arising out of this Public License or use of the Licensed Material, even if the Licensor has
' been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation
' of liability is not allowed in full or in part, this limitation may not apply to You.
'
' The disclaimer of warranties and limitation of liability provided above shall be interpreted
' in a manner that, to the extent possible, most closely approximates an absolute disclaimer and
' waiver of all liability.
'------------------------------------------------------------------------------------------------
'--------------------------------
'*** Initialize SCREEN
'SCREEN 12
'*** Setup Font Type and Size
fontpath$ = "Verdana.ttf"
QBMain:
'*** Setup constant variables
A = 0
Wt = 0
B = .0
T = 0: St = 0
I = 0
Bdl = 1.055
OZ = .5
TRUE = 1: FALSE = 0
SOBER = FALSE
'*** Get INPUT for values for calculations
PRINT "BLOOD ALCOHOL CALCULATOR" PRINT "------------------------" INPUT "YOUR SEX (M/F): "; SEX$
INPUT "YOUR WEIGHT (lbs): "; Wt
INPUT "NUMBER OF DRINKS: "; A
INPUT "TIME (HRS) SINCE CONSUMPTION BEGAN: "; T
'*** Convert Drinks into Fluid Ounces of EtOH (Pure Alcohol).
'*** A is number of drinks. 1 drink is about .6 FLoz of alcohol
FLoz = A * OZ
'*** Set/calculate EBAC values based on SEX$
B = .017
EBAC = 7.97 * FLoz / Wt - B * T
B = .019
EBAC = 9.86 * FLoz / Wt - B * T
'*** DISPLAY RESULTS
PRINT USING "ESTIMATED BLOOD ALCOHOL CONTENT (EBAC) in g/dL = #.###"; EBAC
'*** IF DRUNK DISPLAY WARNING (.10 WAS DRUNK IN 1984, .08 IN 2003/2004)
PRINT:
PRINT "*** ALERT: CALL AN AMBULANCE, DEATH LIKELY" PRINT "Unconsious/coma, unresponsive, high likelihood of death. It is illegal to operate a motor vehicle at this level of intoxication in all states." PRINT:
PRINT "*** ALERT: CALL AN AMBULANCE, DEATH POSSIBLE" PRINT "Onset of coma, and possible death due to respiratory arrest. It is illegal to operate a motor vehicle at this level of intoxication in all states." PRINT:
PRINT "*** ALERT: CALL AN AMBULANCE, SEVERE ALCOHOL POISONING" PRINT " Coma is possible. This is the level of surgical anesthesia. It is illegal to operate a motor vehicle at this level of intoxication in all states." PRINT:
PRINT "*** ALERT: YOU ARE IN A DRUNKEN STUP0R, AT RISK TO PASSING OUT" PRINT "STUPOR. You have little comprehension of where you are. You may pass out suddenly and be difficult to awaken. It is illegal to operate a motor vehicle at this level of intoxication in all states." PRINT:
PRINT "*** ALERT: SEVERLY IMPAIRED - DRUNK ENOUGH TO CAUSE SEVERE INJURY/DEATH TO SELF" PRINT "All mental, physical and sensory functions are severely impaired. Increased risk of asphyxiation from choking on vomit and of seriously injuring yourself by falls or other accidents. It is illegal to operate a motor vehicle at this level of intoxication in all states." PRINT "Feeling dazed/confused or otherwise disoriented. May need help to stand/walk. If you injure yourself you may not feel the pain. Some people have nausea and vomiting at this level. The gag reflex is impaired and you can choke if you do vomit. Blackouts are likely at this level so you may not remember what has happened. It is illegal to operate a motor vehicle at this level of intoxication in all states." PRINT:
PRINT "YOUR ARE SEVERLY DRUNK - ENOUGH TO BECOME VERY SICK" PRINT "Dysphoria predominates, nausea may appear. The drinker has the appearance of a 'sloppy drunk.' It is illegal to operate a motor vehicle at this level of intoxication in all states." PRINT:
PRINT "* Dysphoria: An emotional state of anxiety, depression, or unease." PRINT:
PRINT "YOU ARE VERY DRUNK - ENOUGH TO LOSE PHYSICAL & MENTAL CONTROL" PRINT "Gross motor impairment and lack of physical control. Blurred vision and major loss of balance. Euphoria is reduced and dysphoria* is beginning to appear. Judgment and perception are severely impaired. It is illegal to operate a motor vehicle at this level of intoxication in all states." PRINT:
PRINT "* Dysphoria: An emotional state of anxiety, depression, or unease." PRINT "Significant impairment of motor coordination and loss of good judgment. Speech may be slurred; balance, vision, reaction time and hearing will be impaired. Euphoria. It is illegal to operate a motor vehicle at this level of intoxication in all states." PRINT "Slight impairment of balance, speech, vision, reaction time, and hearing. Euphoria. Judgment and self-control are reduced, and caution, reason and memory are impaired (in some* states .08 is legally impaired and it is illegal to drive at this level). You will probably believe that you are functioning better than you really are." PRINT:
PRINT "(*** As of July, 2004 ALL states had passed .08 BAC Per Se Laws. The final one took effect in August of 2005.)" PRINT "Feeling of well-being, relaxation, lower inhibitions, sensation of warmth. Euphoria. Some minor impairment of reasoning and memory, lowering of caution. Your behavior may become exaggerated and emotions intensified (Good emotions are better, bad emotions are worse)" PRINT:
PRINT "YOU MAY BE OK TO DRIVE, BUT IMPAIRMENT BEGINS" PRINT "No loss of coordination, slight euphoria and loss of shyness. Depressant effects are not apparent. Mildly relaxed and maybe a little lightheaded."
'*** Determine if Drunk (>.08 EBAC) and calculate:
'*** - When user will be less than .08
'*** - How long it will take to become completely sober
SOBER = FALSE
CEBAC = EBAC
St = T
T = T + 1
IF CEBAC
> .0799 THEN I
= I
+ 1
B = .015
CEBAC = 7.97 * FLoz / Wt - B * T
B = .015
CEBAC = 9.86 * FLoz / Wt - B * T
PRINT USING "It will take ## hours from your last drink to be able to drive."; I
PRINT USING "It will take # hours from your last drink to be able to drive."; I
legalToDrive = TRUE
PRINT USING "It will take you ## hours from your last drink to be completely sober."; T
- St
PRINT USING "It will take you # hours from your last drink to be completely sober."; T
- St
SOBER = TRUE