Problem with compiling

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
User avatar
Codemss
Veteran
Posts: 124
Joined: Sun Jun 24, 2007 6:49 am
Location: Utrecht, The Netherlands
Contact:

Problem with compiling

Post by Codemss »

I have a real problem, when I compile this program, it gives me an 'illegal function call'. It runs fine in the IDE, except for some overflow errors in QB 4.5(you can simply solve those with 1& * on the place of the error), but it messes up totally when you compile it.
I have had this same problem more, with the feedback effect. This is also that effect, like everything is blurring 'towards' you.
I know the problem is in the drawer, but I don't know where. When I used a line instead of this weird 1-dimensional plasma it worked great.
BTW Dont get me wrong, I dont ask you to solve this, but I would find it nice if you try if you can compile it or that the same thing happens(Illegal function call)...

Thnx already,

Codemss

Code:

Code: Select all

DECLARE SUB gradient (startcolour%, red1%, blue1%, green1%, endcolour%, red2%, blue2%, green2%)
CLS
SCREEN 13
DEFINT A-Z
CONST scale = .93
REM $DYNAMIC
gradient 0, 0, 0, 0, 31, 63, 0, 0
gradient 32, 63, 0, 0, 63, 0, 63, 0
gradient 64, 0, 63, 0, 91, 0, 0, 63
gradient 92, 0, 0, 63, 123, 63, 63, 0
gradient 124, 63, 63, 0, 155, 0, 63, 63
gradient 156, 0, 63, 63, 187, 63, 0, 63
gradient 188, 63, 0, 63, 255, 63, 63, 63
COLOR 255

CONST i = 15
DIM sin1(319 + 283)
FOR s = 0 TO 319 + 283
  sin1(s) = 25 + SIN(s / 45) * i
NEXT
DIM sin2(319 + 94)
FOR s = 0 TO 319 + 94
  sin2(s) = 25 + SIN(s / 15) * i
NEXT
DIM sin3(319 + 157)
FOR s = 0 TO 319 + 157
  sin3(s) = 25 + SIN(s / 25) * i
NEXT
DIM sin4(-220 TO 319)
FOR s = -220 TO 319
  sin4(s) = 25 + SIN(s / 35) * i
NEXT


DIM lutx(319), luty(319)
FOR x = 0 TO 319
  lutx(x) = (x - 160) * scale + 160
NEXT
FOR y = 0 TO 199
  luty(y) = (y - 100) * scale + 100
NEXT

DIM mul320(199) AS LONG
FOR y = 0 TO 199
  mul320(y) = 320& * y
NEXT

DIM div(5 * 255)
FOR c = 0 TO 5 * 255
  div(c) = c / 5 - 1
  IF div(c) <0> 255 THEN div(c) = 255
NEXT

DIM b1(32001), b2(32001)
GET (0, 0)-(319, 199), b1(0)
seg1 = VARSEG(b1(0)): segment = seg1
GET (0, 0)-(319, 199), b2(0)
seg2 = VARSEG(b2(0))

DIM lut(319)

DO UNTIL LEN(INKEY$)
  DEF SEG = seg1
  c1 = c1 + 1
  IF c1 >= 283 THEN c1 = 0
  c2 = c2 + 2
  IF c2 >= 94 THEN c2 = 0
  c3 = c3 + 3
  IF c3 >= 157 THEN c3 = 0
  c4 = c4 + 2
  IF c4 >= 220 THEN c4 = 0
  REM the problem must be here somewhere
  FOR x = 1 TO 318
    h = sin1(x + c1) + sin2(x + c2) + sin3(x + c3) + sin4(x - c4)
    y = 199 - h
    IF y > 1 AND y < 199 THEN POKE x + 4 + mul320(y), 255
  NEXT
  yp = 0
  FOR y = 0 TO 199
    DEF SEG = seg1
    FOR x = 0 TO 319
      lut(x) = PEEK(mul320(luty(y)) + lutx(x) + 4)
    NEXT
    DEF SEG = 1& * seg2 + yp
    FOR x = 0 TO 319
      POKE x + 4, lut(x)
    NEXT
    yp = yp + 20
  NEXT
  p& = 325
  DEF SEG = seg2
  FOR y = 1 TO 198
    FOR x = 1 TO 318
      POKE p&, div(PEEK(p& - 320) + PEEK(p& - 1) + PEEK(p&) + PEEK(p& + 1) + PEEK(p& + 320))
      p& = p& + 1
    NEXT
    p& = p& + 2
  NEXT
  IF segment = seg1 THEN PUT (0, 0), b1(0), PSET ELSE PUT (0, 0), b2(0), PSET
  SWAP seg1, seg2
LOOP
DEF SEG

SUB gradient (startcolour%, red1%, blue1%, green1%, endcolour%, red2%, blue2%, green2%)
Steps% = endcolour% - startcolour% + 1
Redstep! = (red2% - red1%) / Steps%
Bluestep! = (blue2% - blue1%) / Steps%
Greenstep! = (green2% - green1%) / Steps%
FOR ii% = startcolour% TO endcolour%
  OUT &H3C8, ii%
  OUT &H3C9, CINT(j% * Redstep!) + red1%
  OUT &H3C9, CINT(j% * Bluestep!) + blue1%
  OUT &H3C9, CINT(j% * Greenstep!) + green1%
  j% = j% + 1
NEXT ii%
END SUB
Last edited by Codemss on Thu Sep 27, 2007 1:01 pm, edited 1 time in total.
Check out my site: <a href="http://members.lycos.nl/rubynl">Click here</a>
Hope you like it. Send some feedback if you want: <a href="mailto:basicallybest@live.nl">Mail me</a>
Codemss, before known as RubyNL
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Re: Problem with compiling

Post by Mac »

[quote="Codemss"]I can't compile this program.[/quote]

You mean "I can compile the program, but it eventually bombs out when running"?

At least that's what happens to me.

No problem compiling. Runs for a while. Then gets "Illegal Function Call".

I really, really hate to do this: insert ON ERROR GOTO IGNORE at the beginning of the program and where the SUB's start, put
IGNORE: Resume Next

(Comment the first line out when debugging. There is nothing worse than a stupid ON ERROR trap that is active all the time (except in this case to avoid a program bombout)

I was unable to determine why the function call was illegal. Interesting.

Mac
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Re: Problem with compiling

Post by Mac »

[quote="Mac"]I was unable to determine why the function call was illegal.
[/quote]

Well, I figured out this would help, so the error trap is not necessary:

[code]
IF segment = seg1 THEN
if segment<>31999 then PUT (0, 0), b1(0), PSET
ELSE
[/code]

Don't ask me what's wrong with 31,999. I ran in IDE for a LONG time and never got 31999.

Mac
Bulldog
Newbie
Posts: 7
Joined: Wed Aug 09, 2006 9:30 am

Linker

Post by Bulldog »

I find if I compile from command line and link using linker version 5.31.009 it doesn't crash. But using the linker that comes with qb (3.69) it crashes.

The error is happening here

IF segment = seg1 THEN PUT (0, 0), b1(0), PSET ELSE PUT (0, 0), b2(0), PSET
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Re: Linker

Post by Mac »

[quote="Bulldog"]The error is happening here
IF segment = seg1 THEN PUT (0, 0), b1(0), PSET ELSE PUT (0, 0), b2(0), PSET[/quote]

Heh! Missed my post above by 15 minutes! It explains how to get around the error, but not why the bad value occurs.

Mac
User avatar
Codemss
Veteran
Posts: 124
Joined: Sun Jun 24, 2007 6:49 am
Location: Utrecht, The Netherlands
Contact:

Post by Codemss »

Sorry about m fault about that compiling, Mac. But I have not much time to write this, so let's get to the point. It isn't working when I use this:

IF segment = seg1 THEN
if segment <> 31999 then PUT (0, 0), b1(0), PSET
ELSE
if segment <> 31999 then PUT (0, 0), b2(0), PSET
END IF

It's still the same. Thanks for all the suggestions and help though, escpecially Mac.
Check out my site: <a href="http://members.lycos.nl/rubynl">Click here</a>
Hope you like it. Send some feedback if you want: <a href="mailto:basicallybest@live.nl">Mail me</a>
Codemss, before known as RubyNL
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Post by Mac »

[quote="Codemss"]It isn't working when I use this:
IF segment = seg1 THEN
if segment <> 31999 then PUT (0, 0), b1(0), PSET
ELSE
if segment <> 31999 then PUT (0, 0), b2(0), PSET
END IF
[/quote]

I did not put the test into the second "if segment". When I did, I got goofy results.

Mac
User avatar
Codemss
Veteran
Posts: 124
Joined: Sun Jun 24, 2007 6:49 am
Location: Utrecht, The Netherlands
Contact:

Post by Codemss »

Sorry, Mac but your code didn't solved the problem for me. I made the mul320 LUT integer, and now it works, weird enough. It is really weird, because now it gives overflow in IDE, but compiles correctly. Thanks for spending your time on my problems, though. Just change:
DIM mul320(199) AS LONG
to:
DIM mul320(199) AS INTEGER
And compile. Enjoy!

Codemss
Check out my site: <a href="http://members.lycos.nl/rubynl">Click here</a>
Hope you like it. Send some feedback if you want: <a href="mailto:basicallybest@live.nl">Mail me</a>
Codemss, before known as RubyNL
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Post by Mac »

[quote="Codemss"]Codemss[/quote]

RubyNL - My main man! Don't know why you changed your handle, but that happens, I guess.

I used to be Mr. Mac on CraigsList.org, but people kept assuming I used an Apple computer, so I changed it to NT_User.

So everyone changes, I guess.

Mac
Post Reply