Stringrückgabe in PB-"Klassen"
Verfasst: 07.01.2016 03:33
Ich bin am Verzweifeln. Warum erhalte ich irgendeine Nummer und nicht den "Hallo, Welt"-String?
Zur Erläuterung: Das ist der Versuch, PureBasics Kniffe-und-Tricks-Ecke soweit auszureitzen, dass es beinahe OOP ermöglicht.
Code: Alles auswählen
Interface Str
Delete ()
String ()
EndInterface
DeclareModule Str
Declare New (String$ = #Empty$)
EndDeclareModule
Module Str
Structure SString
*VTABLE
String$
EndStructure
Procedure IDelete (*this. SString)
FreeMemory (*this)
EndProcedure
Procedure New (String$ = #Empty$)
Protected *this. SString
*this = AllocateMemory (SizeOf (SString))
If *this
*this \ VTABLE = ? VTABLE_SSTRING
*this \ String$ = String$
ProcedureReturn *this
EndIf
EndProcedure
Procedure$ IString (*this. SString)
ProcedureReturn *this \ String$
EndProcedure
DataSection
VTABLE_SString:
Data. i @ IDelete ()
Data. i @ IString ()
EndDataSection
EndModule
Text. Str = Str::New ("Hallo, Welt!")
Debug Text \ String ()