[Gambas-user] Property question....
Stephen Bungay
sbungay at ...981...
Sat Mar 15 00:06:23 CET 2008
Benoit Minisini wrote:
> On vendredi 14 mars 2008, Stephen Bungay wrote:
>> Stephen Bungay wrote:
>>> Benoit Minisini wrote:
>>>> On vendredi 14 mars 2008, Stephen Bungay wrote:
>>>>> Given the following....
>>>>>
>>>>> PUBLIC mRecordSet AS Result
>>>>>
>>>>> PROPERTY RecordSet AS Result
>>>>> PRIVATE FUNCTION RecordSet_Read() AS Result
>>>>> RETURN (mRecordSet) ' This will probably never get used
>>>>> ' access mRecordSet directly.
>>>>> END
>>>>>
>>>>> PRIVATE SUB RecordSet_Write(Value AS Result)
>>>>> IF NOT IsNull(Value) THEN
>>>>> IF Value.Count > 0 THEN
>>>>> mRecordSet = Value
>>>>> PopulateForm
>>>>> END IF
>>>>> END IF
>>>>> END
>>>>> .
>>>>> .
>>>>> .
>>>>> ' Only gets called when Property RecordSet is written to...
>>>>> Private Sub PopulateForm()
>>>>> ' Code to populate the form from data in mRecordSet goes here
>>>>> END
>>>>>
>>>>>
>>>>> An assignment of a result set to property 'RecordSet' will yield
>>>>> "Unknown identifier: RecordSet at line [line number] in
>>>>> [formname].class.
>>>> This is a compiler error. Please explain how you can get it at runtime
>>>> while assigning the property!
>>> Yes the error is happening at compile time and is something I did not
>>> expect (i.e. since RecordSet is declared as a property it should be a
>>> 'known' identifier).
>> So if we have a button on the form called Button1 and the intent of
>> this action is to execute an SQL and assign the result to the property
>> 'RecordSet', that is where the compiler presents the error. It appears
>> that the compiler isn't aware of the Property.
>>
>> Private Sub Button1_Click()
>> 'Compiler gives an 'unknown identifier' error on the next line.
>> RecordSet = DatabaseConnection.Exec("Select * FROM MyTable")
>> END
>>
>
> You must write ME.Recordset at the moment. I think this is a lack in the
> compiler that cannot compile properties without ME, whereas it could with
> methods and variables.
>
> Regards,
>
Thanks Benoit.
More information about the User
mailing list