HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Endfunction?...

03-24-2006, 09:45 PM#1
Thunder_Eye
Ok can someone tell me what is wrong with this function?
Collapse JASS:
function Calc takes integer fishlevel returns integer
    if (fishlevel <= 99) then
        return 1
    else if (level => 100) And (fishlevel <= 149)
        return 2
endfunction

It says it cant find the "endfunction"
03-24-2006, 09:48 PM#2
johnfn
Okay, I'm not brushed up on my JASSing, but dont you need to

a) inclose the entire if second condition in ()s

b) have an endif

?
03-24-2006, 09:50 PM#3
Thunder_Eye
oh the endif was the problem ;P
I was going to add more elseif's so didnt think of adding endif yet.

anyway thanks (cant rep, need to spread some before I rep you again ;P)

EDIT: Hmm WE still crashes :/
03-24-2006, 09:54 PM#4
Zoxc
Collapse JASS:
function Calc takes integer fishlevel returns integer
    if fishlevel <= 99 then
        return 1
    elseif (level => 100) and (fishlevel <= 149)
        return 2
    endif
endfunction

A better one.
03-24-2006, 10:00 PM#5
Thunder_Eye
Well WE still crashes when I add the function, so it doesnt matter
03-24-2006, 10:02 PM#6
Taur
thats because of this

Quote:
else if (level => 100)
it should say fish level
03-24-2006, 10:03 PM#7
Thunder_Eye
yeah I know, though it still crashes
03-24-2006, 10:05 PM#8
Blade.dk
You need to have a return statement that for sure will take effect, this means that if you add something like " return 0" before the endfunction line it will work.
03-24-2006, 10:06 PM#9
Anitarf
>=
03-24-2006, 10:08 PM#10
Thunder_Eye
Well how will that work then? first it return 1, and then later in the function it returns 0? What value will be returned?
EDIT: Still crashes WE
Collapse JASS:
function Calc takes integer fishlevel returns integer
    if fishlevel <= 99 then
        return 1
    elseif (fishlevel => 100) And (fishlevel <= 149)
        return 2
    endif
    return 0
endfunction
03-24-2006, 10:09 PM#11
Anitarf
function execution terminates at return statements, obviously.
03-24-2006, 10:12 PM#12
Thunder_Eye
Well how do I fix this? I was thinking if the problem was that you cant have more then 1 return in the function, though that wasnt the problem, still crashes WE anyway
03-24-2006, 10:13 PM#13
Blade.dk
elseif (fishlevel => 100) And (fishlevel <= 149)

you miss a "then" in the end.
03-24-2006, 10:15 PM#14
Thunder_Eye
I thought I didnt need one when it was a "elseif", anyway gonna test if it works.
EDIT: I repeat myself again. WE still crashes
Ran it in JassCraft which finds 2 parse errors on the "elseif....." row
03-24-2006, 10:22 PM#15
Blade.dk
It is spelled "and" not "And". "and" is an operator, "And" is a function.