### Author Topic: Functions in Types?  (Read 21339 times)

#### Ian Price

• Prof. Inline
• Posts: 4158
• On the shoulders of giants.
##### Re: Functions in Types?
« Reply #30 on: 2010-May-04 »
Quote
And you won't convince me to add anything else now.

Not even DRAWOVAL/DRAWELLIPSE?
I came. I saw. I played.

#### Kitty Hello

• code monkey
• Prof. Inline
• Posts: 10739
• here on my island the sea says 'hello'
##### Re: Functions in Types?
« Reply #31 on: 2010-May-04 »
lol. Nothing that extends the language syntax I meant.
Drawoval is no biggie. You can polyvector it yourself if you want:
Code: (glbasic) [Select]
`DrawOval(100,100,99,33,RGB(255,0,0))SHOWSCREENMOUSEWAITFUNCTION DrawOval%: x, y, w, h, col% INC x, w/2 INC y, h/2 LOCAL phi STARTPOLY -1, 0 POLYVECTOR x,y, 0,0,col FOR phi = 0 TO 360 STEP 5 // how poly do you want it? POLYVECTOR x+COS(phi)*w, y-SIN(phi)*h, 0,0,col NEXT ENDPOLYENDFUNCTION`

#### Ian Price

• Prof. Inline
• Posts: 4158
• On the shoulders of giants.
##### Re: Functions in Types?
« Reply #32 on: 2010-May-04 »
Yeah, I know Gernot. And that was similar to a method I was using myself anyway.

It just felt like a missing command (it's been in pretty much every other extended BASIC syntax I've used for years). We have DRAWRECT as an internal command, so why not DRAWELLIPSE.

It's nothing major.
I came. I saw. I played.

#### Kuron

• Mr. Polyvector
• Posts: 238
##### Re: Functions in Types?
« Reply #33 on: 2010-May-04 »
Most avionics packages (you know, that stuff that runs computers in the plane's front office) is programmed using OO environments (C++ or more often ADA), whether the programmer used it or not....
You seem confused, I actually love OOP.  I just do not like seeing GLB lose what makes it unique and doing something just because other languages may do it

#### Schranz0r

• Prof. Inline
• Posts: 5055
• O Rly?
##### Re: Functions in Types?
« Reply #34 on: 2010-May-04 »

Code: (glbasic) [Select]
`TYPE Tvecx;y;zFUNCTION add: b AS Tvec   INC self.x, b.xENDFUNCTIONENDTYPELOCAL a AS Tveca.add(a)`

Hmmm.... work this in V8?: (Function without calling itself as parameter?)
Code: (glbasic) [Select]
`TYPE Tvecx;y;zFUNCTION create: x, y   self.x = x   self.y = y   ENDFUNCTIONENDTYPELOCAL a AS Tveca.create(10,20)`

EDIT:

Whooops... simply have to look at the first Post
« Last Edit: 2010-May-04 by Schranz0r »
I DGArray's

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

#### Kitty Hello

• code monkey
• Prof. Inline
• Posts: 10739
• here on my island the sea says 'hello'
##### Re: Functions in Types?
« Reply #35 on: 2010-May-04 »
For those who want to test - see the first post.

#### Kuron

• Mr. Polyvector
• Posts: 238
##### Re: Functions in Types?
« Reply #36 on: 2010-May-04 »
Quote
Gernot is not hunting another programming environment's spec sheet.  He's  is responding to customer demand
Yes, he is and he is doing it against his better judgment.

Quote
that keeps GLB from becoming a dinosaur one day...
I agree, it would be sad if GLB suffered the same fate as other indie languages that started down the OOP road.  Luckily, Gernot has put his foot down, so it is now a moot discussion and we should drop it

• Guest
##### Re: Functions in Types?
« Reply #37 on: 2010-May-04 »
Will you be able to get this going in debug mode too?  Works fine in release mode, but in debug mode it just generates "error: expected constructor, destructor, or type conversion before '(' token".

In addition, will this work with arrays ?  I've tried :

Code: (glbasic) [Select]
`TYPE Tvec   x;y;z   FUNCTION null:      self.x = 0; self.y=0; self.z=0   ENDFUNCTION   FUNCTION add: v AS Tvec     INC self.x, v.x     INC self.y, v.y     INC self.z, v.z     WHILE KEY(44)=0      PRINT self.x,0,0      SHOWSCREEN     WEND   ENDFUNCTION      FUNCTION moo%:   ENDFUNCTIONENDTYPELOCAL push AS TvecLOCAL test[] AS TvecDIM test[0]push.null()DIMPUSH test[],pushtest[0].moo()`
But I just get : "error : call to undefined function : Tvec" with the last line.
« Last Edit: 2010-May-04 by MrTAToad »

#### Kitty Hello

• code monkey
• Prof. Inline
• Posts: 10739
• here on my island the sea says 'hello'
##### Re: Functions in Types?
« Reply #38 on: 2010-May-04 »
update at the beta place. Works for me now.

• Guest
##### Re: Functions in Types?
« Reply #39 on: 2010-May-04 »
Same filesize and dates as the previous one - is that correct ?

• Guest
##### Re: Functions in Types?
« Reply #40 on: 2010-May-04 »
I think I've found a compiler bug too - it appears that compound strings are messed up (or the compiler doesn't like //).  With the following :

Code: (glbasic) [Select]
`ok%=NETWEBGET(proxy\$, "http://"+webAddress\$+str\$, port%, baseData.tempFile\$)`
The compiler states :

error: expected `)' before ';' token

And the C file is :

Code: (glbasic) [Select]
`ok=NETWEBGET(proxy_Str, CGStr("http:");`

#### Schranz0r

• Prof. Inline
• Posts: 5055
• O Rly?
##### Re: Functions in Types?
« Reply #41 on: 2010-May-04 »

Code: (glbasic) [Select]
`TYPE Vec x;y;z FUNCTION Create: x, y, z self.x = x self.y = y self.z = z ENDFUNCTION FUNCTION Print_Debug\$: PRINT "x = "+self.x+" y = "+self.y+" z = "+self.z, 10,10 ENDFUNCTION ENDTYPE LOCAL v AS Vecvec.Create(10,20,30)`
"Methods.gbas"(22) error : call to undefined function : vec

Beta from first post installed...
I DGArray's

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

#### bigsofty

• Community Developer
• Prof. Inline
• Posts: 2668
##### Re: Functions in Types?
« Reply #42 on: 2010-May-04 »
Shouldn't that be...

Code: (glbasic) [Select]
`v.Create(10,20,30)`
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

• Guest
##### Re: Functions in Types?
« Reply #43 on: 2010-May-05 »
Yes, it should be

#### Quentin

• Prof. Inline
• Posts: 915
##### Re: Functions in Types?
« Reply #44 on: 2010-May-05 »
of course it should!