Controls-Array from Frame-Object not found...

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

Post Reply
User avatar
Blueplayer
Posts: 170
Joined: 05 Apr 2011, 17:34

Controls-Array from Frame-Object not found...

Post by Blueplayer »

Hi all,

I want to get the Controls-Array from a Frame-Object, but always there´s a compilation error.
Here´s a example:

Manialink:

Code: Select all

<manialink>
  <frame id="Frame1">
    <entry id="Entry1">
  </frame>
</manialink>
Maniascript:

Code: Select all

<script>
  declare Text EntryContent;
  EntryContent = Page.Controls["Frame1"].Controls["Entry1"].Value;
  log(EntryContent);  
</script>
Here´s the error message: The member or variable Controls does not exist.


I also tried the following code:

Code: Select all

Page.Controls["Frame1"]["Entry1"].Value
Error Message: quare brackets '[]' must apply to an array or a vector.


Can somebody please help me?
User avatar
eyebo
Translator
Translator
Posts: 3493
Joined: 15 Jun 2010, 12:01
Location: Kansas, USA
Contact:

Re: Controls-Array from Frame-Object not found...

Post by eyebo »

Congrats on writing the 37000th post in the English TrackMania 2 subforum.

I hope you get the answer to your question.
Former QC Manager at Ubisoft Nadeo.
My tracks on: Mania Exchange (TM2) | TrackMania Exchange (TMUF)

For the devs: Ryzen 7 1800X / 32GB RAM / GTX 1080 (477.22) @ 3840x2160 / Win10 64bit
Lmb-willy
Posts: 135
Joined: 15 Jun 2010, 15:48
Location: Germany
Contact:

Re: Controls-Array from Frame-Object not found...

Post by Lmb-willy »

eyebo wrote:Congrats on writing the 37000th post in the English TrackMania 2 subforum.

I hope you get the answer to your question.
Congrats eyebo to the 49700th post of the english foroum :yes: :yes:

i hope too that blue become a answer
User avatar
m4rcel
Posts: 650
Joined: 15 Jun 2010, 11:12
Contact:

Re: Controls-Array from Frame-Object not found...

Post by m4rcel »

You have to typecast the received Control object to the Frame type to be able to use the Frame's methods and fields. And of course, you mast typecast the Entry to be able to use its Value property.

In other words, do the following:

Code: Select all

declare CGameManialikFrame Frame = (Page.Controls["Frame1"] as CGameManialinkFrame);
declare CGameManialinkEntry Entry = (Frame.Controls["Entry1"] as CGameManialinkEntry);
declare Text EntryContent = Entry.Value;
log(EntryContent);
The Controls array always holds object from type "CGameManialinkControl", and a Control does not know .Controls or .Value. Only with "saying" (typecasting) that the Control actually is a Frame or Entry, it "remembers" that there is a .Controls or .Value respectively.
ImageImage
Image
User avatar
Blueplayer
Posts: 170
Joined: 05 Apr 2011, 17:34

Re: Controls-Array from Frame-Object not found...

Post by Blueplayer »

Thanks.
That works fantastic. :)
Post Reply

Return to “ManiaScript”

Who is online

Users browsing this forum: No registered users and 3 guests