Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
compilation error (*solved*)
#1
I have a compilation eror where it thinks a byte is a label


Attached Files
.bas   linefile.bas (Size: 1.69 KB / Downloads: 437)
.bas   wars.bas (Size: 7.1 KB / Downloads: 322)
.bas   pressedfire.bas (Size: 2.09 KB / Downloads: 267)
Reply
#2
heres the last files.
compile wars.bas


Attached Files
.bas   updatebullet.bas (Size: 1.28 KB / Downloads: 393)
.bas   pathfinding.bas (Size: 5.83 KB / Downloads: 318)
Reply
#3
The problem lies in function ChooseNextUnit()

Code:
const NumUnitsIter as Ubyte = 29

Function ChooseNextUnit() as byte
     if LastColorToMove=0 then
         LastColorToMove=red
     end if

    for NumUnitsIter =1 to NumUnits 'NumUnitsIter is a global constant!
        if ActionPoints(NumUnitsIter)=3 then
            UnitMoving=NumUnitsIter
            Exit for
        end if
    next
end function

The FOR loop is using NumsUnitIter as a variable, but it's already declared globally as a const.
You should add the line
Code:
Dim NumUnitsIter as Ubyte
within the function body, so the compiler will understand you want to override the global constant using the same name for a local variable (the global constant NumUnitsIter won't be available within the function). The compiler won't override (declare) the local variable within the function for you (at the moment).
This is a compiler bug, anyway: it should either stop with an error, or issue a warning "Inner declaration hides global constant", or the like. I will fix it later.
Reply
#4
thanks :oops:


By the way do you think it will be quicker to:

1. take away 1 from a number,
or
2. get a global variable?


so i can loop through an array with FOR
Reply
#5
slenkar Wrote:thanks :oops:


By the way do you think it will be quicker to:

1. take away 1 from a number,
or
2. get a global variable?


so i can loop through an array with FOR
I think the 2nd is faster. Anyway, just use DIM within the function and your code is OK! ;-)
(outside the function you will be using the constant).
Reply
#6
This has been fixed (I think).
Please, download and install the version 1.2.9s910.
Try it and tell me. Wink
Reply
#7
yep that works thanks,

it says its not a variable
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)