a\\func(...) as shortcut for a\func(a,...)
Posted: Mon Mar 20, 2017 8:38 pm
See topic, nothing to add 

http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
Interface Test
func.i(b.i, c.i)
EndInterface
Structure TestS
*Functions
Value.i
EndStructure
Procedure func(*a.TestS, b.i, c.i)
ProcedureReturn *a\Value*b+c
EndProcedure
Procedure New(Value.i)
Protected *Element.TestS = AllocateStructure(TestS)
*Element\Functions = ?Functions
*Element\Value= Value
ProcedureReturn *Element
DataSection
Functions:
Data.i @func()
EndDataSection
EndProcedure
Define a.Test = New(1)
Define a2.Test = New(2)
Define b.i = 4
Define c.i = 6
Debug a\func(b, c)
Debug a2\func(1, 0)
Code: Select all
Prototype _GetCounter(*self)
Prototype _SetCounter(*self,value)
Prototype _AddCounter(*self,value=1)
Structure Counter
Get._GetCounter
Set._SetCounter
Add._AddCounter
_value.i
EndStructure
Procedure counter_Get(*self.counter)
ProcedureReturn *self\_value
EndProcedure
Procedure counter_Set(*self.counter,value)
*self\_value=value
ProcedureReturn *self\_value
EndProcedure
Procedure counter_Add(*self.counter,value=1)
*self\_value+value
ProcedureReturn *self\_value
EndProcedure
Procedure New_counter(value=0)
Protected *self.counter=AllocateStructure(counter)
*self\Get=@counter_Get()
*self\Set=@counter_Set()
*self\Add=@counter_Add()
*self\_value=value
ProcedureReturn *self
EndProcedure
Macro DisposeObject(a)
FreeStructure(a)
EndMacro
*x.counter=New_counter()
Debug *x\Get(*x)
*x\Set(*x,10)
Debug *x\get(*x)
Debug *x\Add(*x)
DisposeObject(*x)
Code: Select all
Debug *x\\Get()
*x\\Set(10)
Debug *x\\get()
Debug *x\\Add()
Code: Select all
Structure Counter
Get.i (*self.counter)
Set.i (*self.counter,value)
Add.i (*self.counter,value=1)
_value.i
EndStructure
Code: Select all
Structure Counter
Get.i (*self.counter) = @counter_get()
Set.i (*self.counter,value) = @counter_set()
Add.i (*self.counter,value=1) = @counter_add()
_value.i = 1
EndStructure
Code: Select all
x.counter
debug x\\Get()
x\\Set(10)
Debug x\\get()
Debug x\\Add()
Code: Select all
Interface Counter
Get()
Set(value)
Add(value=1)
EndInterface
Structure CounterS
*Functions
Value.i
EndStructure
Procedure counter_Get(*self.CounterS)
ProcedureReturn *self\Value
EndProcedure
Procedure counter_Set(*self.CounterS,value)
*self\Value=value
ProcedureReturn *self\Value
EndProcedure
Procedure counter_Add(*self.CounterS,value=1)
*self\Value+value
ProcedureReturn *self\Value
EndProcedure
Procedure New_counter(value=0)
Protected *self.CounterS=AllocateStructure(CounterS)
*self\Functions = ?Functions
DataSection
Functions:
Data.i @counter_Get(), @counter_Set(), @counter_Add()
EndDataSection
ProcedureReturn *self
EndProcedure
Macro DisposeObject(a)
FreeStructure(a)
EndMacro
*x.counter=New_counter()
Debug *x\Get()
*x\Set(10)
Debug *x\Get()
Debug *x\Add()
DisposeObject(*x)