Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

error: result of function not assigned at top level??

abbe prismabbe prism Posts: 8Member
I'm getting this error message: error: result of function not assigned at top level. I'm not sure what it means. Can someone help, please?

[CODE]
function getToken(): Integer;

var
asciiValue : Integer;
begin
tok := -1;
if(tokName = 'for') then
tok := 0;
{long list of these if tokName - then}
else
tok := -1
end; {if I put the semi-colon here I get the error plus another error)
begin
asciiValue = ord(tokName[1]);
c := ord(str[i]);
if(asciiValue = 49 < c < 57) or (asciiValue = 65 < c < 90) or (asciiValue < c < 122) then
tok := 16;
end
end; {getToken}



[/CODE]

This is only one function in this code, there is more. The other error I get is syntax error before begin.

Thank you for your help.

Comments

  • Phat NatPhat Nat Posts: 757Member
    : I'm getting this error message: error: result of function not assigned at top level. I'm not sure what it means. Can someone help, please?
    :
    : [CODE]
    : function getToken(): Integer;
    :
    : var
    : asciiValue : Integer;
    : begin
    : tok := -1;
    : if(tokName = 'for') then
    : tok := 0;
    : {long list of these if tokName - then}
    : else
    : tok := -1
    : end; {if I put the semi-colon here I get the error plus another error)
    : begin
    : asciiValue = ord(tokName[1]);
    : c := ord(str[i]);
    : if(asciiValue = 49 < c < 57) or (asciiValue = 65 < c < 90) or (asciiValue < c < 122) then
    : tok := 16;
    : end
    : end; {getToken}
    :
    :
    :
    : [/CODE]
    :
    : This is only one function in this code, there is more. The other error I get is syntax error before begin.
    :
    : Thank you for your help.
    :

    Haven't tried compiling this, but this line:
    [CODE]
    function getToken(): Integer;
    [/CODE]
    should be
    [CODE]
    function getToken : Integer;
    [/CODE]
    if you're not passing variables into it.

    Also,
    [code]
    end; {if I put the semi-colon here I get the error plus another error)
    begin
    [/code]
    These two lines should be left out, as the compiler thinks you are ending the function, then starting the main section. You don't need to use an END on your IF...THEN...ELSE unless you also use a BEGIN for multiple lines.

    Phat Nat

Sign In or Register to comment.