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!

Moderators: Pete, Mods

Post Reply
Piolho
Newbie
Posts: 2
Joined: Thu Apr 06, 2006 8:16 pm

Illegal function call

Post by Piolho » Thu Apr 06, 2006 9:08 pm

I'm not a programmer, but 12 yrs ago, more or less, I needed a program so I wrote it, in QBASIC, I think. Now I need the program again, and when I attempt to run it in Qbasic, or Power BASIC, when it gets to the Circle statement, it stops with the notice, "Illegal Function". I am using an OLD computer with DOS on it, don't know what version, but all the files are dated 1994. Can anyone tell me why I ger this error, and what I need to do to get this program to run?

The following is the program
Any help will be greatly appreciated

'CONCV.BAS (CONCAVE)

MaxD = 2.75 'MAXIMUM DIAMETER
CSC = 0 'CAM SHAFT CLEARANCE
RR = 9 'REDUCTION RATIO
RlD = 3 / 8 'ROLLER DIAMETER
OfSt = RlD / 5 'OFF SET
PI = 3.141593
RD = 180 / PI
CIRCLE (X,Y), 1.125 / 2, 11
CIRCLE (X, Y), MaxD / 2, 12
CIRCLE (X, Y), (MaxD / 2) + RlD, 13
FOR ANG = 0 TO 360 STEP 1
XX = COS(ANG / RD) * (MaxD / 2 + CSC - (RlD / 2) - OfSt)
YY = SIN(ANG / RD) * (MaxD / 2 + CSC - (RlD / 2) - OfSt)
DANG = ANG / RD * (RR + 0)
X = XX + COS(DANG) * OfSt
Y = YY + SIN(DANG) * OfSt
PSET (X, Y), 7
CIRCLE (X, Y), RlD / 2, 9, , , ASP
X$ = MID$(STR$(X), 2): IF X < 0 THEN X$ = STR$(X)
Y$ = MID$(STR$(Y), 2): IF Y < 0 THEN Y$ = STR$(Y)
PRINT #1, X$,",", Y$,",", Z$;
NEXT ANG

RyanKelly
Coder
Posts: 48
Joined: Sun Jan 22, 2006 6:40 pm
Contact:

Post by RyanKelly » Thu Apr 06, 2006 9:11 pm

Before using any graphic statements, you need to set the screen mode with the SCREEN statement.

Piolho
Newbie
Posts: 2
Joined: Thu Apr 06, 2006 8:16 pm

Same program

Post by Piolho » Thu Apr 06, 2006 9:51 pm

Thanks Ryan! Now,,,This program used to work just fine and I don't recall doing anything special to get the results in inches, but when I run it now, I get some thing too small to even discern what in blazes it is. Any ideas on that? Could you run the prog and tell me what you get? If not, O.K., but if so let me know, if it ain't too much trouble. Thanks

moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo » Fri Apr 07, 2006 7:44 pm

Piolho,

Just noticed the following PRINT statement in your program.

Code: Select all

 PRINT #1, X$,",", Y$,",", Z$; 
1) First of all, you never opened any file as #1.

2) The Z$ variable was never assigned anywhere.

3) The PRINT statement ends with a semicolon, which means that you will never output to the file. Do you really want all the output on one line? If so, do a PRINT #1 at the end before exiting the program. If not, then get rid of the semicolon on the end.
*****

Post Reply