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.

Newcomers DBPro Corner / How do I declare a global array of a user-defined type?

Author
Message
Tallun
20
Years of Service
User Offline
Joined: 30th Oct 2004
Location: Existence
Posted: 6th Feb 2005 00:54 Edited at: 17th Jun 2006 17:03
The game I'm making requires a system of menus for which I'm using a user-defined type called Menu. I want to use an array of this type, called Menus, to store information for the menus required for the game. However, a global declaration appears to allow me neither to make it an array nor make it of a user-defined type. I have tried a few different methods of attempting this, but none have succeeded. Does anyone know how to do this, or if it's even possible?
Baggers
20
Years of Service
User Offline
Joined: 31st May 2004
Location: Yonder over dem dere hills
Posted: 6th Feb 2005 02:34
I think ithis is what you are asking for


If it isnt then sorry, someone lese will get it right ! good luck though.
Tallun
20
Years of Service
User Offline
Joined: 30th Oct 2004
Location: Existence
Posted: 6th Feb 2005 06:25 Edited at: 17th Jun 2006 17:03
I should have been slightly more specific: I need to call Menus from a function. If I can't, I can probably work around it by making it return the value(s) required.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 6th Feb 2005 23:54
arrays are global by default, but you cant pass arrays or types in and out of functions.

Tallun
20
Years of Service
User Offline
Joined: 30th Oct 2004
Location: Existence
Posted: 7th Feb 2005 06:29 Edited at: 17th Jun 2006 17:03
Thanks.
Tallun
20
Years of Service
User Offline
Joined: 30th Oct 2004
Location: Existence
Posted: 8th Feb 2005 10:12 Edited at: 17th Jun 2006 17:03
It's not working. My function isn't assigning the information to the variable. My function's code is in the code box.

An explanation of the function: It reads strings from a specifically-formatted file for the purpose of displaying a menu. It makes sure that the file's extension is .djm before it does anything, otherwise it shows an error message and exits. (I don't think it's necessary to include the code of InErr().) It assigns values to NewMenu fine, but doesn't seem to do anything to the array Menus, which is of the Menu type (see below). A side note: It doesn't check to see if the specified menu number exists, but that's not my current problem, and will be easily coded later.

Menu.djm, the menu I load first for my program, contains the following:

Main Menu
4
Single Player/Multiplayer/Profiles/Exit
m_SinglePlayer.djm/m_Multiplayer.djm/m_Profiles.djm/iv_Go_0

In case you're wondering, the last line is instructions for the buttons to follow when pressed.

Also required and used in my program is the Menu type, which contains the fields accessed in the function.
anomer
20
Years of Service
User Offline
Joined: 11th Oct 2004
Location: City of Tears
Posted: 9th Feb 2005 11:02
global dim enemies(5) as characters

~astro
(stands for astronomer in case you cared )
wmf
20
Years of Service
User Offline
Joined: 6th Nov 2004
Location:
Posted: 9th Feb 2005 12:00
calling the function with 1,"main.djm" it prints the following:

Main Menu
4
Single Player/Multiplayer/Profiles/Exit
m_SinglePlayer.djm/m_Multiplayer.djm/m_Profiles.djm/iv_Go_0

and printing menus(menunumber) prints this 23070576
so what is it supposed to be.
wmf
20
Years of Service
User Offline
Joined: 6th Nov 2004
Location:
Posted: 9th Feb 2005 22:37
after sleeping I think I know what you want. this stores both fields in menus(1) and prints in and out of the function. newmenu isn't needed.
Tallun
20
Years of Service
User Offline
Joined: 30th Oct 2004
Location: Existence
Posted: 12th Feb 2005 23:25 Edited at: 17th Jun 2006 17:03
@wmf
The printing part is for testing. I just forgot to remove it. That isn't the problem, however. I'm not sure what the thing with menunumber is, but it probably isn't a problem. I also know that NewMenu isn't necessary, it's also just part of testing the function that I forgot to remove. I will try your suggestion in your second post when I get the chance.

@anomer
I will also try that.

Anyway, thanks for your help, everyone who's posted.
Tallun
20
Years of Service
User Offline
Joined: 30th Oct 2004
Location: Existence
Posted: 14th Feb 2005 00:57 Edited at: 17th Jun 2006 17:03
Perfect! LoadMenu() works now!

@anomer
The global dim was what I needed for the array Menus. Now the function works with the Menus variable that I need it to work with, not a function variable of the same name.

Thanks everyone! My problems are solved!

Login to post a reply

Server time is: 2024-11-27 22:34:17
Your offset time is: 2024-11-27 22:34:17