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 / using varibales in other variable names?

Author
Message
Gibbon28
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location: Derbyshire, UK
Posted: 30th Oct 2012 11:53
Hi, i dont suppose there is but usin tier 1 is there any way of using variables withing variable names?

like PHP:

var1 = "foo"
${var1} = hello.

result : foo = hello.

Thanks
Andy
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 30th Oct 2012 12:05
Nope, you can't do that in Tier 1 or Tier 2.

Jim can you do it in Tier 3?

Gibbon28
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location: Derbyshire, UK
Posted: 30th Oct 2012 12:06
Hmm Tier one would be amazing if it had the ability to create classes, or user functions within types.

Andy
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 30th Oct 2012 12:15
Quote: "Hmm Tier one would be amazing if it had the ability to create classes, or user functions within types."

I agree the Tier 1 language could use some more features, referencing is something I'd really like to see. It's the main reason I mostly use Tier 2 now. Tier 1 is great for fast prototyping though.

JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 30th Oct 2012 13:27
Pascal is strongly typed, so this kind of fast-and-loose assignment is not regarded as good practice. But you can assign any simple (ie non-structured type) to a Variant:



They can be useful for COM objects and Interfaces. I've only used them when programming compilers, where they are handy for containing the next token.

Personally I wouldn't recommend using them under ordinary circumstances, because they cannot be optimised, since the compiler doesn't know the type of the assignment to a variant until run time. This means they will be substantially slower than typed variables.

As far as extending Tier 1 with OOP stuff etc goes, this has been argued to death in the forum. Maybe I should make a few videos to show that Pascal is just as easy to use as Basic, and all these goodies come with it. There's no real need to keep re-inventing the wheel.

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Gibbon28
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location: Derbyshire, UK
Posted: 30th Oct 2012 15:09
HI JimHawkins, i actuall know pascal quite well, as a full time programmer i use delphi and lazarus for linux.

The problem i have is keeping with updates. Ive used other engines that focus on one language but is compatiable for all these but then over time they get "left" behind in regards to updates.

So i dont want that to happen here.

IS there any docs or tuts on getting a pascal written AppGameKit app to IOS devices?

Thanks
Andy
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 30th Oct 2012 17:31
Have a look at:

http://www.bilsen.com/agkpas/index.shtml

All the source is there, so future-proof.

Current version is 1076. When the newest version is stable Erik will update the Pascal.

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 30th Oct 2012 18:02
Quote: "Nope, you can't do that in Tier 1 or Tier 2. "


Phew... There's almost nothing that cannot be done within C++... Have a look at boost libraries, that's some firepower.

I am not sure if I understand OP's question. Did you mean something like interfaces ( as in AS3 )?

Or something like,



If not, please explain. Unless you don't want to know how to do that with C++.

Follow me on twitter! @MotionStruct
Motion Struct blog
Gibbon28
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location: Derbyshire, UK
Posted: 30th Oct 2012 18:13 Edited at: 30th Oct 2012 18:14
Ill give an example of why i need this.

If i want create my own type:



i want to then have a function that can dynamically create types:



i could then do


Thanks
Andy
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 30th Oct 2012 18:40 Edited at: 30th Oct 2012 18:49
Well, in C++ you could do that;



And that should work (written from head, so not so sure)

Follow me on twitter! @MotionStruct
Motion Struct blog
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 30th Oct 2012 18:49 Edited at: 30th Oct 2012 18:54
Ew. Wait. This works,



Is that what you've wanted?
Or you've wanted to make operator = overloaded, just as in C++?
So that you could, testType as myType = 266. In that case it's impossible within AGK.

Follow me on twitter! @MotionStruct
Motion Struct blog
Gibbon28
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location: Derbyshire, UK
Posted: 30th Oct 2012 21:25 Edited at: 30th Oct 2012 21:29
I dont think the above is what i want.

Basically i want to be able to declare types dynamically.

This cannot be done, not even with an array.

If you make a type, the only way to then declare them is giving them variable name directly, not from a loop, or from dynamic variable names. for instance this would be what i want.



Andy
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 30th Oct 2012 21:29
Well this sample:



Is kinda breaking whole programming logics.
To be accurate, this line:



you can't have test+I. That's just impossible in very most of languages.

You would have an array instead.


But nope, it's not possible within AppGameKit then.

Follow me on twitter! @MotionStruct
Motion Struct blog
Gibbon28
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location: Derbyshire, UK
Posted: 30th Oct 2012 21:30
Sorry i edited to:

test[I] as myType

but still, it doesnt work.

Andy
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 30th Oct 2012 21:56 Edited at: 30th Oct 2012 22:12
I know that what you want is possible within AS3 for sure. Should be possible ( and is ) within C++. I am speaking of having an array / vector of different classes.

The best you can have in AppGameKit is:



So, an array has to be defined type.

In AS3 you can have something like this:



Follow me on twitter! @MotionStruct
Motion Struct blog
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 30th Oct 2012 22:25
Quote: "Phew... There's almost nothing that cannot be done within C++... "

What I originally though he was trying to do was create a new variable with the variable name equal to the string of another variable. I know next to nothing about php but I just remembered that web based languages often refer to variables using quotation marks.

So I thought he was trying to do this:
String a = "ten"
magic(a)
// new variable suddenly made called ten
ten = 0

Quote: "Basically i want to be able to declare types dynamically."

This can't be done in Tier 1, but can be done in C++. You could use templates to dynamically assign types to things.

E.g


JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 31st Oct 2012 01:19 Edited at: 31st Oct 2012 01:21
Andy - I'm still not at all clear why you want to go down this route. It sure as hell isn't going to happen in Tier 1 Basic. You could probably do this quite easily using Lua, but Tier 1 doesn't have a Lua interface, so you would have to use C++ or Pascal.

So - is the need:

a) make Tier 1 do something it doesn't do
b) have some dynamic event most of us don't grasp

If you're an experienced Delphi programmer you will only suffer endless grief expecting T1 to give you what you're used to, whereas you could be up and running in seconds using the familiar language and IDE of Delphi (almost any version) and Lazarus/Free Pascal.

I notice that you have only just joined the forum. Have you purchased AppGameKit? If so, AppGameKit for Pascal is there waiting for you!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL

Login to post a reply

Server time is: 2024-04-28 18:36:24
Your offset time is: 2024-04-28 18:36:24