Illegal Function Call?

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!
Post Reply
JasonQuinn1992
Coder
Posts: 42
Joined: Mon Sep 03, 2012 4:32 pm

Illegal Function Call?

Post by JasonQuinn1992 »

Hey guys,

Im writing a program for my BASIC class and have suddenly gotten an "Illegal Function Call" error on one of the lines and I really dont know why

The error occurs at the "PRINT USING T1$; PageCt 'Print title line" line


' MINITEST 2

' Variables Used:
' T1$, H1$, H2$, D1$ Print images
' TL$ Print images
' Nam$ Names
' Num Number of people
' Rate Hourly Rate
' AmountOwed Amount Owed
' NumTot Number Totals
' AmountTot Amount Total

' **********************************************
' * PROGRAM MAINLINE *
' **********************************************

CLS
GOSUB InitializeVariables
GOSUB PrintHeadings
GOSUB ProcessDetail
GOSUB PrintTotals
END
' *********************************************
' * Initialize Variables *
' *********************************************

InitializeVariables:
LET Rate = 0
LET Num = 0
LET NumTot = 0
LET AmountTot = 0
' ***********************************************
' Initialize Images
' ************************************************

InitializeImages:
' T1$ Title Outputs
' H1$, H2$ Column Headings
' D1$ Detail (names, # of people, amount owed>
' TL$ Totals

' ****************************************************
' LPRINT HEADINGS *
' ****************************************************

PrintHeadings:
PRINT USING T1$; PageCt 'Print title line
PRINT
PRINT H1$ 'Print column headings, line 1
PRINT H2$ 'Print column headings, line 2
PRINT
RETURN

' *******************************************************
' * PROCESS DETAIL *
' *******************************************************

ProcessDetail:
GOSUB ReadData 'Prime Nam$, Num
LET Names$ = Nam$
DO UNTIL Nam$ = "END"
RateLookup:
IF Num <1>= 1 AND Num <4> 11 THEN
LET Rate = 100
END IF
LOOP
RETURN

' *************************************************
' * READ DATA *
' *************************************************

ReadData:
READ Nam$, Num, AmountOwed
DATA ABC company, 5, $80.00
DATA NBC Corporation, 7, $80.00
DATA XLR company,8, $80.00
DATA Lucent corp, 12, $60.00
DATA Ameritech, 3, $100.00
DATA Rambo Mart, 0, $0
DATA END, 0,0,0
RETURN

' **************************************************
' * Calculate Amount Owed *
' **************************************************

AmountOwed:
LET AmountOwed = Rate * Num
RETURN

' **************************************************
' * CALCULATE TOTALS *
' **************************************************

CalculateTotals:
LET NumTot = NumTot + Num 'Add to number total
LET AmountTot = AmountTot + AmountOwed 'Add to amount total
RETURN

' **************************************************
' * LPRINT DETAILS *
' ***************************************************

PrintDetail:
LPRINT USING D1$; Nam$; Num; AmountOwed 'Print details
RETURN

' ******************************************************
' * LPRINT TOTALS *
' *******************************************************

PrintTotals:
LPRINT
LPRINT USING TL$; NumTot; AmountTot ' Print totals line
RETURN

' *****************************************************************
' * END OF PROGRAM *
' *****************************************************************

Anyone have any ideas?

Thanks for the help!
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

String T1$ needs to be defined with numerical ## digit positions in the string to reflect the numerical variable using the template.

PRINT USING "Value:###.##"; variable
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 »

After I did as you suggested im getting an error stating, "expected: tab or spc or expression or end of statement"



Also,
Then im getting a Syntax error at the

READ Nam$, Num, AmountOwed line
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

DATA can be placed anywhere. You can label it to RESTORE MyData to the beginning of DATA so it doesn't error.

Code: Select all

FOR i = 1 TO 6 'reads 6 lines of data
GOSUB ReadData
PRINT Nam$, Num, "$"; AmountOwed
NEXT

END

ReadData: 
READ Nam$, Num, AmountOwed 
RETURN 

MyData:
DATA ABC company, 5, 80.00 
DATA NBC Corporation, 7, 80.00 
DATA XLR company,8, 80.00 
DATA Lucent corp, 12, 60.00 
DATA Ameritech, 3, 100.00 
DATA Rambo Mart, 0, 0 
DATA END, 0,0,0 
If you want the dollar sign value change AmountOwed to a string.
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 »

What you suggested seems to be working but now I get an Syntax error at the

READ Nam$, Num, AmountOwed line
Post Reply