PROTOTYPE !

Previous topic - Next topic

Schranz0r

Hi Gernot!


So erstmal der Code, evtl. fällts dir selber auf!:

Code (glbasic) Select


PROTOTYPE P_TTest: t AS TTest, text$, x, y
PROTOTYPE P_1Args: t AS TTest
PROTOTYPE P_String$: t AS TTest
TYPE TTest
x;y
text$
test AS P_TTest = F_TTest
GetX AS P_1Args = F_GetX
GetY AS P_1Args = F_GetY
GetText$ AS P_String$ = F_GetText$
ENDTYPE

GLOBAL _TTest AS TTest

LOCAL test AS TTest
test.test(test,"Blabla",10,20)


WHILE TRUE

SHOWSCREEN
WEND
END

FUNCTION F_TTest: t AS TTest, text$, x = 0 , y = 0
  t.x = x
  t.y = y
ENDFUNCTION

FUNCTION F_GetText$: t AS TTest
RETURN t.text$
ENDFUNCTION

FUNCTION F_GetX: t AS TTest
RETURN t.x
ENDFUNCTION

FUNCTION F_GetY: t AS TTest
RETURN t.y
ENDFUNCTION 



Richtig! Es können keine String-Funktionen von PROTOTYPES verarbeitet werden.

Und das "t AS TTest" ist auch (hoffentlich nicht mehr lange)nervig :) :whip:
Hast du schon irgend einen Plan, wie man das lösen "KÃâ€"NNTE"  :-[

sowas wär doch auch ne nette Lösung(sofern es überhaupt machbar wäre):


Code (glbasic) Select


PROTOTYPE P_TTest CALLTYPE TTest: text$, x, y

TYPE TTest
x;y
text$
test AS P_TTest = F_TTest
ENDTYPE

...

FUNCTION F_TTest CALLTYPE TTest: text$, x, y
    TTest.text$ = text$  // Hier TTest nehmen um es übersichtlich zu halten?! oder doch lieber this/self?
    TTest.x = x
    TTest.y = y
ENDFUNCTION


CALLTYPE würde hier prüfen beim aufruf der Funktion, ob es sich um eine TTest Instanz handelt:

Code (glbasic) Select

LOCAL test AS TTest // instanz erstellen

test.test("test",10,20)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Kitty Hello

Oh mei. Das wäre ja dann Generics (Template) programming. Das ist echt kein BASIC mehr. Dafür gibt's doch INLINE.

Die Strings sind bug. Grrr. ;)

Kitty Hello

Code (glbasic) Select

PROTOTYPE func_proto$: a

TYPE Tfoo
   moo AS func_proto$
ENDTYPE

LOCAL pFoo$ AS func_proto$
   IF pFoo$=FALSE THEN STDOUT "has no pointer\n"
   pFoo$ = f1$
   pFoo$(1)

   pFoo$ = f2$
   pFoo$(2)

   call(pFoo$)


   LOCAL tp AS Tfoo
   tp.moo = f1$
   tp.moo(4)

   ALIAS fkt AS tp.moo
   fkt(5)
   KEYWAIT


FUNCTION f1$: one
   STDOUT "f1: "+one+"\n"
ENDFUNCTION


FUNCTION f2$: a
RETURN "test"
   STDOUT "f2: "+a+"\n"
ENDFUNCTION

FUNCTION call: foo$ AS func_proto$
   foo$(3)
ENDFUNCTION

geht im nächsten Update. Wie ekelhaft.

trucidare

ich hätte dann doch bitte gern inline asm :D
MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC

Kitty Hello

Code (glbasic) Select

INLINE
__asm {
...
}
ENDINLINE


Quentin

na super. Gibt es dann demnächst auch eine Schnittstelle zu einem Lochkarten-Lesegerät? :)

Kitty Hello

Code (glbasic) Select

INLINE
__lochkart {
001001001-0
110100111-0
001000101-1
}
ENDINLINE


trucidare

wir brauchen ein Sarkasmus tag im editor ;)
MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC

Schranz0r

I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard