Another Illegal Fuction Call Error

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
JasonQuinn1992
Coder
Posts: 42
Joined: Mon Sep 03, 2012 4:32 pm

Another Illegal Fuction Call Error

Post by JasonQuinn1992 » Mon Oct 29, 2012 8:21 pm

I can't figure out why I'm getting an Illegal Function Call error on this line

PRINT M4$
LOCATE 26, 21

My code:

'************************** PROGRAM 9.2 *************************

' THIS IS A MENU-DRIVEN PROGRAM TO CONVERT TO AND FROM U'S',
' EUROPEAN, AND GREAT BRITAIN CURRENCIES

' PROGRAM VARIABLES
'
' CHOICE AND CHOICE$ MENU CHOICES
' M1$, M2$, M3$, M4$, M5$, M6$ AND M7$ USED TO DISPLAY THE MENU
' F1$ F2$, F3$, AND F4$ USED TO PRINT OUT THE FORMULAS
' E$ USED TO DISPLAY AN ERROR MESSAGE
' ANSWER$ CHOICE TO PREFORM A CALCULATION
' USD U.S. DOLLARS
' ERR EURROS
' GBP GREAT BRITAIN POUNDS
' PAUSE$ PAUSE TO READ A MESSAGE

' ***************************** MAIN MODULE **************************

COLOR 14, 3
GOSUB InitializePrintImages
LET CHOICE = 0
DO UNTIL CHOICE = 5 ' 5 IS ENDING VALUE
GOSUB PrintMenu ' PRINT MENU & INPUT CHOICE
SELECT CASE CHOICE
CASE 1 '1 converts US Dollars to Euros
GOSUB CalculateUSDToEUR
CASE 2 '2 converts Euros to US Dollars
GOSUB CalculateEURToUSD
CASE 3 '3 converts US Dollars to British Pounds
GOSUB CalculateUSDToGBP
CASE 4 '4 converts British Pounds to US Dollars
GOSUB CalculateGBPToUSD
CASE 5 '5 quits
CLS
LOCATE 20, 21
PRINT " A penny for you thoughts equals "
LOCATE 22, 21
PRINT " 1 cent in America, "
LOCATE 24, 21
PRINT " 78/100ths of a cent in Europe,"
LOCATE 26, 21
PRINT " and 64/100th of a cent in Great Britain. Good Day!"
LOCATE 36, 21
LOCATE 25, 30
CASE ELSE
LOCATE 18, 25
PRINT E$
LOCATE 30, 47
PRINT " "
INPUT "", CHOICE$
LET CHOICE = VAL(CHOICES$)
END SELECT
LOOP
END

' ************************ INITIALIZE PRINT IMAGES **************

InitializePrintImages:
LET M1$ = "MENU CHOICES"
LET M2$ = "1. CONVERT U.S. DOLLARS TO EUROS"
LET M3$ = "2. CONVERT EUROS TO U.S. DOLLARS"
LET M4$ = "3. CONVERT U.S. DOLLARS TO BRITISH POUNDS"
LET M5$ = "4. CONVERT BRITISH POUNDS TO U.S. DOLLARS"
LET M6$ = "5. END"
LET M7$ = "ENTER MENU CHOICE"
LET F1$ = "1 U.S. DOLLAR (USD) = 0.78 EUROS (EUR)"
LET F2$ = "1 EURO (EUR) 1.28 U.S. DOLLARS (USD)"
LET F3$ = "1 U.S. DOLLAR (USD) = 0.63 BRITISH POUNDS (GBP)"
LET F4$ = "1 BRITISH POUND (GBP) = 1.58 U.S. DOLLARS (USD)"
LET E$ = "INVALID CHOICE. ENTER 1 - 5 ONLY"
RETURN

' ************************** PRINT MENU ******************

PrintMenu:
CLS
LOCATE 15, 34
PRINT M1$
LOCATE 20, 21
PRINT M2$
LOCATE 22, 21
PRINT M3$
LOCATE 24, 21
PRINT M4$
LOCATE 26, 21
PRINT M5$
LOCATE 28, 21
PRINT M6$
LOCATE 30, 28
PRINT M7$
LOCATE 30, 47
INPUT "", CHOICE$
LET CHOICE = VAL(CHOICE$)
RETURN ' TO MAIN MODULE

' *********************** CALCULATE U.S. DOLLARS TO EUROS ***********

CalculateUSDToEUR:
CLS
LOCATE 20, 21
PRINT F1$
GOSUB DesireCalculation
IF UCASE$(ANSWER$) = "Y" THEN
GOSUB PerformUSDToEUR
END IF
RETURN

' ************************ PERFORM USD TO EUR CALCULATION ********

PerformUSDToEUR:
CLS
LOCATE 15, 21
PRINT "CONVERT U.S. DOLLARS TO EUROS"
LOCATE 20, 21
INPUT "ENTER U.S. DOLLAR AMOUNT $", USD
LET EUR = USD * .78
LOCATE 22, 21
PRINT USD; "U.S. DOLLARS EQUALS "; EUR; "EUROS"
LOCATE 30, 21
INPUT "PRESS RETURN TO CONTINUE ", PAUSE$
RETURN

' ********************** CALCULATE EUROS TO U.S. DOLLARS *****************

CalculateEURToUSD:
CLS
LOCATE 20, 21
PRINT F2$
LOCATE 22, 21
PRINT USD; "U.S. DOLLARS EQUALS "; GBP; "BRITISH POUNDS"
LOCATE 30, 21
INPUT "PRESS RETURN TO CONTINUE ", PAUSE$
RETURN


' *********************** CALCULATE BRITISH POUNDS TO U.S. DOLLARS *******

CalculateGBPToUSD:
CLS
LOCATE 20, 21
PRINT F4$
GOSUB DesireCalculation
IF UCASE$(ANSWER$) = "Y" THEN
GOSUB PerformGBPToUSD
END IF
RETURN

' ******************* PERFORM GBP TO USD CALCULATION *******************

PerformGBPToUSD:
CLS
LOCATE 15, 21
PRINT "CONVERT BRITISH POUNDS TO U.S. DOLLARS"
LOCATE 20, 21
INPUT "ENTER BRITISH POUNDS AMOUNT ", GBD
LET USD = GBD * 1.58
LOCATE 22, 21
PRINT GBD; "BRITISH POUNDS EQUALS "; USD; "U.S. DOLLARS"
LOCATE 30, 21
INPUT "PRESS RETURN TO CONTINUE ", PAUSE$
RETURN

' ********************* DESIRE CALCULATION ******************

DesireCalculation:
LOCATE 22, 15
PRINT "PERFORM A CALCULATION USING THIS FORMULA (Y/N)";
INPUT ANSWER$
DO WHILE UCASE$(ANSWER$) <> "N" AND UCASE$(ANSWER$) <> "Y"
LOCATE 22, 63
GOSUB DesireCalculation
IF UCASE$(ANSWER$) = "Y" THEN
GOSUB PerformEURToUSD
END IF
LOOP
RETURN

' ***************** PERFORM EURO TO USD CALCULATION **************

PerformEURToUSD:
CLS
LOCATE 15, 21
PRINT "CONVERT EUROS TO U.S. DOLLARS"
LOCATE 20, 21
INPUT "ENTER EUROS AMOUNT ", EUR
LET USD = EUR * 1.28
LOCATE 22, 21
PRINT EUR; "EUROS EQUALS "; USD; "U.S. DOLLARS"
LOCATE 30, 21
INPUT "PRESS RETURN TO CONTINUE ", PAUSE$
RETURN

' ***************** CALCULATE U.S. DOLLARS TO BRITISH POUNDS **************

CalculateUSDToGBP:
CLS
LOCATE 20, 21
PRINT F3$
GOSUB DesireCalculation
IF UCASE$(ANSWER$) = "Y" THEN
GOSUB PerformUSDToGBP
END IF
RETURN

' ******************* PERFORM USD TO GBP CALCULATION ****************

PerformUSDToGBP:
CLS
LOCATE 15, 21
PRINT "CONVERT U.S. DOLLARS TO BRITISH POUNDS"
LOCATE 20, 21
INPUT "ENTER U.S. DOLLAR AMOUNT $", USD
LET GBP = USD * .63
LOCATE 22, 21
PRINT USD; "U.S. DOLLARS EQUALS "; GBP; "BRITISH POUNDS"
LOCATE 30, 21
INPUT "PRESS RETURN TO CONTINUE ", PAUSE$
RETURN

' ******************* DESIRE CALCULATION ************************


LOCATE 22, 15
PRINT "PERFORM A CALCULATION USING THIS FORMULA (Y/N)";
INPUT ANSWER$
DO WHILE UCASE$(ANSWER$) <> "N" AND UCASE$(ANSWER$) <> "Y"
LOCATE 22, 63
INPUT ANSWER$
LOOP
RETURN
' ************************** END OF PROGRAM ************************


How should I fix this problem?

User avatar
burger2227
Veteran
Posts: 2425
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Tue Oct 30, 2012 12:53 pm

LOCATE in Qbasic can only got to row 25 on most screens. 30 on SCREEN 11 or 12.

WIDTH columns, rows 'can set 43 or 50 rows in SCREEN 0, or 60 rows in 11 or 12

Prints on the bottom 2 rows will cause the screen to roll. Use a semicolon after the print statement to prevent that.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

JasonQuinn1992
Coder
Posts: 42
Joined: Mon Sep 03, 2012 4:32 pm

Post by JasonQuinn1992 » Tue Oct 30, 2012 5:45 pm

I was able to get it to work after fixing the screen width

Thanks for the help!

Post Reply