I found that I'm running into some unexpected issues...
I retyped the program — line numbers and all — and ran it in -lang qb mode. Once I fixed my typoes everything worked as expected except for the first line. FreeBASIC didn't like the program's use of the COLOR keyword. I strongly suspect this was written in GW-BASIC back in the day as it uses the COLOR keyword with three arguments instead of two. (If I recall correctly, the third argument is to set the boarder color.) FreeBASIC doesn't support this usage and it's not critical to the program, so I just commented it out. That cleared the first issue. Easy fix.
Next, I replaced the GOTO targets with line labels and deleted the remaining line numbers. The resulting code worked in -lang qb just fine. At this point, I'm thinking "okay, cool time to switch to -lang fblite and start modernizing the code with things like proper modern functions, etc." I re-ran the now labeled code in fblite mode and initially everything seemed to work. But then I noticed computational errors that resulted in some values unexpectedly reading zero. I'm not sure what the deal is with this. What quirk of fblite am I running into?
Also, I ran into something strange when running the code in some terminals. On a typical terminal you'll find in KDE/GNOME/XFCE the program works fine. In Kitty Terminal, a modern terminal with programmer ligature support, everything locks up around the second prompt and won't take any input. It just hangs until I hit <CTRL+C>. I'm not sure what the deal is there, whether it's a FreeBASIC bug or a Kitty Terminal bug.
Can someone point me in the right direction? I'm running FreeBASIC 1.09.0 under Gentoo Linux. The code is below:
Code: Select all
'COLOR 15,1,4:CLS:PRINT:PRINT:PRINT:REM REV. 2.1 10/27/96
PRINT " MAIN BEAM POWER DENSITY ESTIMATION PROGRAM"
PRINT " FOR ROUTINE EVALUATION OF RF SAFET COMPLIANCE"
PRINT:PRINT
PRINT "This program uses the formulas given in FCC OET Bulletin No. 65"
PRINT "to estimate power density in the mane lobe of an antenna, with"
PRINT "use of the EPA-recommended ground reflection factor as an option."
PRINT:PRINT "This program is intended for for far field calculations. It may"
PRINT "overestimate the actual field strength of high-gain antennas in"
PRINT "the near field (within several wavelengths of the antenna)."
PRINT "However, it may also underestimate the strength of fields that may"
PRINT "be encountered in 'hot spots' in the near field. No computer"
PRINT "program can predict where wiring or reflective objects may create"
PRINT "hot spots in your particular installation.":PRINT
PRINT "This is a public domain program by Wayne Overbeck, N6NB":PRINT
INPUT "WHAT IS THE AVERAGE POWER AT THE ANTENNA (IN WATTS)"; WATTS
PWR = 1000 * WATTS
PRINT:PRINT "WHAT IS THE ANTENNA GAIN IN DBI?"
INPUT "(Enter 2.2 for dipoles; add 2.2 for antennas rated in DBD): ",GAIN
REM NOW CALCULATING EIRP IN MILLIWATTS
EIRP=PWR*(10^(GAIN/10))
PRINT:INPUT "WHAT IS THE DISTANCE TO AREA OF INTEREST FROM ANTENNA CENTER IN FEET";FT
REM NOW CONVERTING TO CM
DX=FT*30.48
MHZ_PROMPT:
PRINT:INPUT "WHAT IS THE FREQUENCY IN MHZ";F
IF F<1.34 THEN STD1=100:STD2=100:GOTO GROUND_EFFECTS_PROMPT
IF F<3 THEN STD1=100:STD2=180/((F)^2):GOTO GROUND_EFFECTS_PROMPT
IF F<30 THEN STD1=900/((F)^2):STD2=180/((F)^2):GOTO GROUND_EFFECTS_PROMPT
IF F<300 THEN STD1=1:STD2=.2:GOTO GROUND_EFFECTS_PROMPT
IF F<1500 THEN STD1=F/300:STD2=F/1500:GOTO GROUND_EFFECTS_PROMPT
IF F<100000! THEN STD1=5:STD2=1:GOTO GROUND_EFFECTS_PROMPT
PRINT "The FCC DOES NOT HAVE EXPOSURE LIMITS ABOVE 100 GHZ":GOTO MHZ_PROMPT
GROUND_EFFECTS_PROMPT:
PRINT:PRINT "NOW, DO YOU WISH TO INCLUDE THE EFFECTS OF GROUND REFLECTIONS?"
PRINT "(Ground effects need not be included in most main-beam calculations"
PRINT "but including them may yield more accurate results with very low"
PRINT "antennas, not-directional antennas, and calculations below the"
PRINT "main lobe of directional antennas.) INCLUDE GROUND EFFECTS (Y/N)";G$
GF=.25:GR$="WITHOUT":IF G$="Y" THEN GF=.64:GR$="WITH"
IF G$="y" THEN GF=.64:GR$="WITH"
PWRDENS=(GF*EIRP)/(3.14159*(DX^2))
PWRDENS=(INT((PWRDENS * 100000) +.5))/10000
DX1=SQR((GF*EIRP)/(STD1*3.14159)):DX1=DX1/30.48:DX1=(INT((DX1*10)+.5))/10
DX2=SQR((GF*EIRP)/(STD1*3.14159)):DX1=DX1/30.48:DX1=(INT((DX1*10)+.5))/10
STD1=(INT((STD1*100)+.5))/100:STD2=(INT((STD2*100)+.5))/100
CLS:PRINT "THE RESULTS ARE AS FOLLOWS:":PRINT
PRINT "WITH";WATTS;"WATTS AND";GAIN;"DBI GAIN ";GR$;" GROUND REFLECTIONS, AT";FT;"FEET"
PRINT "FROM THE ANTENNA CENTER THE ESTIMATED POWER DENSITY IS";PWRDENS;"MW/CM2.":PRINT
PRINT "AT";F;"MHZ, THE MAXIMUM PERMISSIBLE EXPOSURE (MPE) IN `CONTROLLED"
PRINT "ENVIRONMENTS` (SUCH AS YOUR OWN HOUSEHOLD OR CAR) IS";STD1;"MW/CM2."
PRINT "THE MPE IN `UNCONTROLLED ENVIRONMENTS` (SUCH AS NEIGHBORS PROPERTY)"
PRINT "IS";STD2;"MW/CM2. THIS INSTALLATION WOULD MEET THE CONTROLLED MPE"
PRINT "LIMIT AT";DX1;"FEET AND THE UNCONTROLLED LIMIT AT";DX2;"FEET."
PRINT:PRINT "ALTERNATE CALCULATION METHODS:"
PRINT " 1) Exposure is averaged over six minutes in controlled environments"
PRINT "and 30 minutes in uncontrolled environments. If you never transmit more"
PRINT "than three minutes in any six-minute period, divide the power density"
PRINT "shown above by two then calculating the power density in your own house-"
PRINT "hold. Also divide by two when calculating fields beyond your property"
PRINT "if you never transmit more than 15 minutes in any 30-minute period."
PRINT " 2) If you wish to estimate the power density at a point below the main"
PRINT "lobe of a directional antenna, and if the antenna's vertical pattern is"
PRINT "known, recalculate using the antenna's gain in the relevant direction."