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.

Author
Message
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 30th May 2010 15:01
Only in my new projects, you can't pass a UDT through an function if the UDT isn't local to the source. Even worse is you can have duplicate UDT's across source. So what's going on, cause this never happened before. Could this be a Win 7 issue? or is it something else?

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 30th May 2010 15:08
Could you provide a simple complete example so we know what you mean?
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 30th May 2010 15:26 Edited at: 30th May 2010 15:27
So here's the source files for example:

B Source:


Main Source:


Now that will work fine, but this won't:

Main Source:


Before it worked fine and if you look at a ton of my projects the UDT is in another source, and the projects even compile now. But now it just comes up with a Unknown Parameter Error ONLY IN NEW PROJECTS. If I want to get it to work, I have to do this:

Main Source:


But that mean's I now have two of the same UDT and it should come up with a duplication error, but it doesn't. Weird right.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 30th May 2010 16:30
I agree it doesn't work with U7.5beta13. Can you provide an upgrade where it does work so I can see how it used to work?

I couldn't get any reasonable version of your code to compile.

Looks like a major problem to me.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 30th May 2010 17:36
Quote: "Can you provide an upgrade where it does work so I can see how it used to work"


Well it worked on the same upgrade I'm using now U7.4, the only thing that's changed is I've upgraded to Win 7.

Quote: "I couldn't get any reasonable version of your code to compile."


That doesn't sound good

Quote: "Looks like a major problem to me."


Not again!

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 30th May 2010 21:18 Edited at: 30th May 2010 21:44
Quote: "That doesn't sound good "


I should have made it clear that I was using two dba files - when everything is one file it works fine. With two files I tried putting the type declaration inside a function in one file and called it from the main file. I also tried it without the function definition and call and that wouldn't work either. I may have done something silly since I usually work with small projects with just one dba file.

I'll try again with U7.4 and report back - I'm using my XP machine at the moment.

Edit

Just tested U7.4 with the latest version of the editor and your main snippet



with second file



doesn't work. (I daren't change the editor because I've run into problems doing that before.)

Looks like a possible editor issue to me. Report this on the Upgrade 7.5 thread at the top of this board.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 30th May 2010 22:40
Quote: "Report this on the Upgrade 7.5 thread at the top of this board."


Done Cheers for the assist GG

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Globbits
17
Years of Service
User Offline
Joined: 30th Jan 2009
Location: Cambridge
Posted: 1st Jun 2010 12:54
Don't think this is a bug. It works on U74. I think this may be to do with the compile order. Make sure you are compiling the source file with the UDT definition first. If you don't you will get the parameter error because you are trying to use the UDT without defining it first. Tested on U74 with Win7.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Jun 2010 14:14
Quote: "Don't think this is a bug. It works on U74."


Which version of the editor are you using? Could you supply a zip file with a complete small sample project that works for you?

Quote: "Make sure you are compiling the source file with the UDT definition first."


What do you mean exactly? Sasuke has made it quite clear that he has several working projects which have UDTs declared outside the main file. Unless I've misunderstood what he's doing.

By the way, I get the same problems on Vista and XP using U7.5
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Jun 2010 14:33
Looks like Globbits is right. This is what the Help file says about UDTs in include files:

Quote: "Be aware that included source code is appended to the end of the program, which means such declarations as TYPE and FUNCTION names included are only valid for use within the included file. If you want to use your TYPE globally, ensure it is declared in your main program. "


But that doesn't seem to explain why some versions of Sasuke's example do in fact work. Looks like a bit more clarification is needed from someone who knows.
Globbits
17
Years of Service
User Offline
Joined: 30th Jan 2009
Location: Cambridge
Posted: 1st Jun 2010 15:48
I'm using the U74 editor, although it works in CodeSurge as well.
Source code attached.
If you set the main.dba as the main source file it won't work as the b.dba which contains the UDT definition hasn't been read yet. CodeSurge is better at this because you can change the compile order of all the source files, which is really useful when you are working with a lot of files. With the U74 editor you can only set the main file (as far as I can see).
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 1st Jun 2010 15:56
Haha, your not going to believe this, the code in the project that works was actually rem'd, just didn't look rem'd cause the IDE doesn't like large sections of code being rem'd. My mistake, but lucky I know now. Thanks Globbits and Green Gandalf

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Globbits
17
Years of Service
User Offline
Joined: 30th Jan 2009
Location: Cambridge
Posted: 1st Jun 2010 16:04
This isn't as straightforward as I first thought. The attached code works even though the main.dba is now the main source code file. The only difference is that I had to move the function to the other file. Therefore in this version the UDT definition is NOT in the main source file (making the help inaccurate), but this seems to suggest that functions that contain a UDT parameter must be in the same source file as the UDT definition?
Glad you've got it working though, Sasuke.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 1st Jun 2010 16:19 Edited at: 1st Jun 2010 16:19
Quote: " Therefore in this version the UDT definition is NOT in the main source file (making the help inaccurate), but this seems to suggest that functions that contain a UDT parameter must be in the same source file as the UDT definition"


That's usually how I do it. I only noticed my issue when I was re-writing my code and changed it slightly. But yeah it would make the help inaccurate I think.

Quote: "Glad you've got it working though, Sasuke."


Cheer

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 1st Jun 2010 16:52
Wait, since when can you pass a user defined type to an array? I thought you couldn't? did it change or am I being stupid? and... can you return a user defined type now?

(no time to experiment ATM)


Is't life, I ask, is't even prudence, to bore thyself and bore thy students?
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 1st Jun 2010 16:55
You've always been able to pass UDTs to functions, but never to return them

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 1st Jun 2010 16:59 Edited at: 1st Jun 2010 17:05
I mention it in my: DBP Tips and Tricks (I figured you wrote array by accident and mean't function)

Quote: "can you return a user defined type now"


They (Lee) really should add that feature by now.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Jun 2010 17:02
Quote: "Wait, since when can you pass a user defined type to an array? I thought you couldn't?"


You can't. It's a parameter in a function call in these demos.

Globbits

Thanks for clarifying what's going on. It all seems to make some sort of sense now. [Another Help file obscurity noted.]
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 1st Jun 2010 17:06
Conceptually, the compiler works in phases:
- Includes
- Constant substitution
- Type and function gathering
- Rest of compilation ...

Because types and functions are gathered during the same phase, their order is important, so you get an error by using a type in a function definition if the type is defined later than the function.

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 2nd Jun 2010 03:58
Quote: "Quote: "Wait, since when can you pass a user defined type to an array? I thought you couldn't?"

You can't. It's a parameter in a function call in these demos.
"

blah, typing in a hurry. by "array" I meant "function".


Is't life, I ask, is't even prudence, to bore thyself and bore thy students?

Login to post a reply

Server time is: 2026-07-26 02:10:29
Your offset time is: 2026-07-26 02:10:29