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.

Code Snippets / UDT's and functions with 5.4

Author
Message
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 30th Jun 2004 16:08
this appears to be the only way to use them.

it requires some local variables in your function but you can now return a result from a UDT.




If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself
DeepBlue
21
Years of Service
User Offline
Joined: 17th May 2003
Location: A little box in the UK
Posted: 30th Jun 2004 19:54
You can only seem to return a single element in a UDT from a function not a whole UDT.

Passing UDT's to functions works fine as in the example below



But can't return a whole UDT. If someone would like to demonstrate how to return the midPoint UDT in the example back from the function in one call then, rather than having to pass back to a global variable I'll be convinced it works

Seems only to be 50% of the way there to me at the moment

The coder formerly known as Twynklet.
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 30th Jun 2004 20:23
they are global if used in the function from being declared previously but yes as parameters there is issues perhaps.

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself
DeepBlue
21
Years of Service
User Offline
Joined: 17th May 2003
Location: A little box in the UK
Posted: 30th Jun 2004 22:07
From what I can see it is not possible to return a UDT from a function ie. endfunction myUDTValue (where it returns an entire UDT structure)

So not really any further forward as most of the time if I want to pass a UDT to a function then the return I require is often also a UDT, not a single variable within the UDT.

I would have expected a function decleration similar to

Function myFunction ( InVal as MyType ) as MyType
RetVal as MyType
RetVal.Num1=InVal.Num2
RetVal.Num2=InVal.Num1
EndFunction RetVal

with a call similar to
newVal=myFunction ( oldVal )

But nope not working. I'm very dissapointed by this

The coder formerly known as Twynklet.

Login to post a reply

Server time is: 2024-11-23 20:04:53
Your offset time is: 2024-11-23 20:04:53