Wednesday, March 23, 2011

Arrays as result type and input for functions

in delphi7 i have a function that i need to return a array as a result type b

"function createsbox(key:tkey):array[0..255] of byte;" this is not allowed it is expecting a "identifyer expected but array found" is the error throw up. seems to work fine if i declare a record type of array but it seems pointless to do this for one function.

From stackoverflow
  • The issue is that you're not allowed to create a new type in a function declaration. But that's what you're doing when you specify the return type as array[0..255] of Byte. Instead, declare a named type, and then use it for the return type:

    type
      TSBox = array[0..255] of Byte;
    
    function CreateSBox(const Key: TKey): TSBox;
    

0 comments:

Post a Comment