Recent

Author Topic: Classes Variables  (Read 1119 times)

nugax

  • Full Member
  • ***
  • Posts: 232
Classes Variables
« on: March 06, 2021, 03:16:34 pm »
Hi,

I have a very standard class. I have one variable of a specific type. I wish to refer and use that variable throughout the code, within the class procedures.

I keep getting this error:
cyberio.pas(92,39) Error: Only class methods, class properties and class variables can be accessed in class methods

I have it referenced in the 'pubic' field of the class and have tried referring to it in the class procedures as: self.indentifier, or class.indentifier. Both cause the error.

Does anyone have any information or can assist? I am a bit new to FP Classes.

Thanks.,
-Nugax

jamie

  • Hero Member
  • *****
  • Posts: 6131
Re: Classes Variables
« Reply #1 on: March 06, 2021, 03:48:26 pm »
Going by memory as I have not been doing a lot of work with FPC lately I think you need this

Inside your class


 Class Var Name:Type;
         ^^

The only true wisdom is knowing you know nothing

nugax

  • Full Member
  • ***
  • Posts: 232
Re: Classes Variables
« Reply #2 on: March 06, 2021, 04:18:47 pm »
I believe you are correct. I labeled mine as :
class var
Name : type


Seemed to work
-Nugax

 

TinyPortal © 2005-2018