fatihbarut
asked on
Can Someone Solve the mistery of this function please
the code below which is probably written in delphi 4 gives this error
[DCC Error] PCI.PAS(86): E2010 Incompatible types: 'Boolean' and 'Byte'
[DCC Error] PCI.PAS(68): E2004 Identifier redeclared: 'Result'
could someone help me to solve it please
[DCC Error] PCI.PAS(86): E2010 Incompatible types: 'Boolean' and 'Byte'
[DCC Error] PCI.PAS(68): E2004 Identifier redeclared: 'Result'
could someone help me to solve it please
function readPCIRegisterByte(RegisterNumber:word;BusNumber:Byte;FunctionNumber:Byte;var result:byte):boolean;
var okay:boolean;
res:byte;
begin
okay:=false;
res:=0;
asm
db 66h; pusha
mov AX,0B108h
mov BH,busNumber
mov BL,functionNumber
mov DI,RegisterNumber
int 1Ah
jc @noaction
mov res,cl
mov okay,true
@noaction:
db 66h; popa
end;
result:=res;
readPCIRegisterByte:=okay;
end;
ASKER
It solved my problem thanks
However before accept the solution just one more consideration.
What if someone calls the result from out side of the function.
You know, normally result refers the actual output of the function.
do you think it may cause confliction?
However before accept the solution just one more consideration.
What if someone calls the result from out side of the function.
You know, normally result refers the actual output of the function.
do you think it may cause confliction?
well, a function result is of course the result of the function itself, so for definition "Result" become reserved word for this case.
Using this word assigning it to a variable can of course cause a conflict, and that's why modern compilers give errors in this case.
Using this word assigning it to a variable can of course cause a conflict, and that's why modern compilers give errors in this case.
ASKER
so how can I solve this confliction without ruin the function of the function? This is the matter.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes I think this is the solution, compiler made no complain after I added {$X-}
Resulr is already declared into the function as byte but the function result is a boolean value
That's why it says [DCC Error] PCI.PAS(86): E2010 Incompatible types: 'Boolean' and 'Byte'
so the correct one could be
function readPCIRegisterByte(Regist
var okay:boolean;
res:byte;
begin
okay:=false;
res:=0;
asm
db 66h; pusha
mov AX,0B108h
mov BH,busNumber
mov BL,functionNumber
mov DI,RegisterNumber
int 1Ah
jc @noaction
mov res,cl
mov okay,true
@noaction:
db 66h; popa
end;
InternalResult := res;
readPCIRegisterByte:=okay;
end;