Just starting out? Need help? Post your questions and find answers here.
Josh
Addict
Posts: 1183 Joined: Sat Feb 13, 2010 3:45 pm
Post
by Josh » Mon Jul 22, 2019 11:47 am
Do I have a thinking error or is it a bug?
Code: Select all
Interface MyIface
a (a.s = "3")
b (a.s {100} = 3 )
c (a.s {100} = "3")
EndInterface
Shouldn't an error already occur in method 'b' and no error in method 'c' ?
I'm not quite sure whether a default value for a method makes any sense at all.
Or should no fixed string be allowed, since these are also not allowed in procedure parameters.
sorry for my bad english
NicTheQuick
Addict
Posts: 1226 Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:
Post
by NicTheQuick » Mon Jul 22, 2019 12:05 pm
Looks like an inconsistency in source code parsing and therefore it could be a bug.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
microdevweb
Enthusiast
Posts: 179 Joined: Fri Jun 13, 2014 9:38 am
Location: Belgique
Post
by microdevweb » Mon Jul 22, 2019 12:06 pm
Hello,
i think you can't use a fixed string as parameters of fonction or interface
Use Pb 5.73 lst and Windows 10
my mother-language isn't english, in advance excuse my mistakes.
NicTheQuick
Addict
Posts: 1226 Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:
Post
by NicTheQuick » Mon Jul 22, 2019 12:08 pm
Default values are no problem at all but I don't think it should be allowed to use an integer as default value for a fixed length string.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
mk-soft
Always Here
Posts: 5392 Joined: Fri May 12, 2006 6:51 pm
Location: Germany
Post
by mk-soft » Mon Jul 22, 2019 10:15 pm
An interface describes the functions (procedure) of an object.
There is also no procedure with a parameter as a fixed string. Strings are always passed as pointers to the string.
Code: Select all
Interface iMyObject
Free()
S1(String.s = "Default") ; <- Default Pointer to String
S2(*String.string) ; <- Expert: Pointer to Pointer to string
EndInterface
Structure sMyObject
*vTable
;Data
EndStructure
Procedure S1(*this.sMyObject, String.s = "Default")
Debug String
String = ReverseString(String)
EndProcedure
Procedure S2(*this.sMyObject, *String.string)
Debug *String\s
*String\s = ReverseString(*String\s)
EndProcedure
Procedure free(*this.sMyObject)
FreeStructure(*this)
EndProcedure
Procedure New()
Protected *obj.sMyObject = AllocateStructure(sMyObject)
If *obj
*obj\vTable = ?vTable
EndIf
ProcedureReturn *obj
EndProcedure
DataSection
vTable:
Data.i @Free()
Data.i @S1()
Data.i @S2()
EndDataSection
Global t1.s = "Hello World"
Global t2.String\s = t1
*obj.iMyObject = New()
*obj\S1()
*obj\S1(t1)
Debug t1
*obj\S2(t2)
Debug t2\s
*obj\Free()