Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Help using variables in variable names within variable names .....

Author
Message
ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 14th Jan 2013 00:26
I'm curious if AppGameKit can do this (or something close) and if so how exactly?

Lets say I have 2 type definitions set up which result in the following 8 variables.....



I'd like to be able to write a function that can pass in ('ship' or 'turretFront') and be able to abstractly address either of those 2 sets of 4 statements. For example:


... and pass it either Bob(ship) or Bob(turretFront).

The above code won't work for obvious reasons, but is there some other form which will? Or something reasonably close?

Many thanks in advance ...

----
From the Desk of Prof Versaggi ...
ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 14th Jan 2013 09:55
To make it more clear ... is it possible to pass in a 'type' to a function and if so how is it done?

----
From the Desk of Prof Versaggi ...
MarcoBruti
13
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 14th Jan 2013 10:03
AGK Basic is not a real object oriented language. Such a thing may be done in Java (where there is the Class type) or, I presume, other OO languages as python or ruby. Even to use parametric variable names, may be done in Perl, Javascript, PHP, ruby, shell script, but not in T1 AppGameKit Basic.
As I and other people suggested, AppGameKit Basic should be improved a lot, in term of more Object Orientation.
Juande
13
Years of Service
User Offline
Joined: 2nd Sep 2011
Location:
Posted: 14th Jan 2013 10:16
Hi,

I don't understand you very well, but... Is this what you want?

ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 14th Jan 2013 12:49
@Juande:
Very close .. but I'd not want to pass the variables in the form of (variable1 as var1, variable2 as var2), I'd just rather pass them in as variable1 w/out specifying the actual type. It seems though, that AppGameKit doesn't support that.

However, what you've written will serve as inspiration elsewhere.

----
From the Desk of Prof Versaggi ...
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 14th Jan 2013 13:44
I'm afraid this is one of the several hundred good reasons for using C++ or Object Pascal. Lots of repetition can be avoided with some simple design. Using inheritance you can design a base class and then extend it. And classes can have methods, keeping it all neatly in one place.



The only way to do something like object passing etc in AppGameKit Basic is to declare a global array and pass the index of the array structure to the function.

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 14th Jan 2013 16:38
The short answer is No for Tier 1.

Easily, sort of, doable in Tiers 2 (C++) and 3 (Pascal) using inheritance, as JimHawkins points out.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Login to post a reply

Server time is: 2024-11-24 05:32:25
Your offset time is: 2024-11-24 05:32:25