Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, Grant, Neb), 908 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Accessing a PANEL froma struct #410880
11/10/12 13:27
11/10/12 13:27
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
Code:
typedef struct Applet 
{
	STRING * Name;
	STRING * Author;
	STRING * Version;
	STRING * Description;
	
	PANEL * Container;
	void * Initilize;
	void * Deinitlize;
	int init;
}Applet;



Code:
if(is(applet->Container,SHOW) { reset(applet->Container,SHOW); return 0; }


Here I get a syntax error when I try to access a PANEL from the structure.

Whats the bug there??

Thank && Regards


Keep smiling laugh
http://translation.babylon.com/ - Translate many languages
Re: Accessing a PANEL froma struct [Re: Yashas] #410883
11/10/12 14:03
11/10/12 14:03
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
I'm not sure if this is the problem but try the struct-name APPLET in stead of Applet.

Kartoffel wink


POTATO-MAN saves the day! - Random
Re: Accessing a PANEL froma struct [Re: Kartoffel] #410884
11/10/12 14:06
11/10/12 14:06
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
I have decleared the applet as
Applet * applet = sys_malloc(sizeof(Applet));
Then assigned the values to it.


Keep smiling laugh
http://translation.babylon.com/ - Translate many languages
Re: Accessing a PANEL froma struct [Re: Yashas] #410886
11/10/12 14:14
11/10/12 14:14
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
did you try what I suggested?

I meant you use:

Code:
typedef struct
{
[...]
} APPLET;

and

APPLET* applet = sys_malloc(...);


Also make sure the pointers inside your struct are set to an object (PANEL* container to an existing PANEL*) or to an allocated memory block.

Last edited by Kartoffel; 11/10/12 14:15.

POTATO-MAN saves the day! - Random
Re: Accessing a PANEL froma struct [Re: Kartoffel] #410887
11/10/12 14:17
11/10/12 14:17
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
oh, wait! theres something missing tongue

if(is(applet->Container,SHOW)) { reset(applet->Container,SHOW); return 0; }


POTATO-MAN saves the day! - Random
Re: Accessing a PANEL froma struct [Re: Kartoffel] #410889
11/10/12 14:22
11/10/12 14:22
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Roxas Offline
Member
Roxas  Offline
Member

Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Try defining it without the *.
I've got a pretty similar problem a couple of minutes ago.

I wanted to add extra functionality to the panel's and made an "advanced panels" struct.

looks like this:

Code:
typedef struct
{
	PANEL* panel;		// pointer to a standard panel
	
	int anim;		// Animation-Attribute for the panel
	
} advPANEL;



I defined it simply as:

Code:
advPANEL myAdvPanel;

myAdvPanel.panel = pan_create(NULL, 25);

if(myAdvPanel.panel != NULL)
{
   myAdvPanel.panel.bmap = bmap_create("...");
   myAdvPanel.panel.pos_x = ...
   ...
}



works like a charm.

Cheers
Roxas

Last edited by Roxas; 11/10/12 14:22.
Re: Accessing a PANEL froma struct [Re: Roxas] #410892
11/10/12 14:34
11/10/12 14:34
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
LOL ,I forgot one bracket grin

And I get one more syntax error "if(applet->init)"
I dont kno why


Keep smiling laugh
http://translation.babylon.com/ - Translate many languages
Re: Accessing a PANEL froma struct [Re: Yashas] #410897
11/10/12 15:05
11/10/12 15:05
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Ugh, seriously, guys if you have no idea what you are saying then don't say anything at all. Lite-C is confusing enough for beginners especially when it comes to pointers. We don't need anymore false information the like of "void is faster than function because herp derp".

@Kartoffel: The case doesn't matter. If you are not sure about an answer, test it yourself first.
@Roxas: What you are describing is static vs dynamic memory allocation, however, even if Yashas hadn't allocated backing memory for his instance (which he has, as his second post shows), it wouldn't result in a compile time error.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Accessing a PANEL froma struct [Re: WretchedSid] #410912
11/10/12 19:11
11/10/12 19:11
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Roxas Offline
Member
Roxas  Offline
Member

Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
@JustSid,

what I described was one way of accessing PANELs declared in a struct, that's what the topic's about. Since I had that problem myself I wanted to share what I just found out.

Thus I'm not providing false information. I'm learning lite-c myself. If something work's for me I share it, because I know that this forum can be a hassle sometimes. There are a lot of skilled people here but just a few take their time to explain those things to newcomers or beginners.

At least I'm trying to help even if I consider myself as a beginner as well. A lot of people here don't even bother.

Cheers
Roxas


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1