Haven't used qb in awhile, quick question

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

DaveUnit
Veteran
Posts: 72
Joined: Sat Oct 29, 2005 10:07 am

Haven't used qb in awhile, quick question

Post by DaveUnit »

It's been a long time since I've used QB.
I have been trying to get a function to return a UDT. Is it just me not remembering the proper syntax or can QB not do that?
thanks.
Ralph
Veteran
Posts: 148
Joined: Fri Feb 09, 2007 3:10 pm
Location: Katy, Texas

UDT

Post by Ralph »

While I cannot help you in your question, I do think you might get a good answer if you post
1. What you want to do
2. The code that you are trying to use for that purpose
3. Where, in that code, you are having trouble
Ralph, with QuickBASIC 4.5, operating under Windows XP, wiht anHP LaserJet 4L Printer. Bilingual in English/Spanish
roy
Veteran
Posts: 55
Joined: Sun Jul 29, 2007 2:39 pm
Location: London

Post by roy »

Try C++
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Re: Haven't used qb in awhile, quick question

Post by Mac »

DaveUnit wrote:get a function to return a UDT
UDT Ujian Darjah Tiga (Malaysia)
UDT Under Deck Tonnage
UDT Under Declaration of Trust
UDT Underage Drinking Taskforce
UDT Underwater Demolition Team (US Navy SEALs)
UDT Uni?o Democr?tica Timorense (Timor Democratic Union, East Timor)
UDT Uniform Data Transfer (COM-based technologies)
UDT Unit Data Message (SS7)
UDT United Dominions Trust Ltd (UK)
UDT Universal Data Translator (modeling and simulation)
UDT Unstructured Data Structure
UDT Uridine Diphosphate-N-Acetylgulucosamine Transferase
UDT User Data Type (Microsoft)
UDT User Defined Type
UDT User Design Team
UDT User-Defined Table
UDT Utility Dog Tracker (AKC title)

?????

Mac
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt »

Cripes people, this is the easiest damn question to answer.

UDT = User Defined Type.

QB 4.5 doesn't seem to be able to return a UDT from a function because QB 4.5 is locked in the retardodaur days of forced variable suffixes. I don't know about QB 7.1 though, it might allow it. To get around this, create your UDT as usual, then create a global variable that uses it. It's not the most elegant solution, but it gets the job done. You could also pass a UDT variable as an argument to a SUB that modifies it, and on return, it will contain the new data. That way, you don't need a global.
DaveUnit
Veteran
Posts: 72
Joined: Sat Oct 29, 2005 10:07 am

Post by DaveUnit »

Thanks Nodtveidt for understanding my simple question. I just haven't used QB 4.5 in a long time and I took a programming class in my high school and they still teach QB. I know more than my teacher does. :P
What I wanted to do was having a function that would work like a constructor for the type.
I wanted to do myVar = createVar(stuff, ...) but I guess I'll hafta do createVar(myVar, stuff, ...).

thanks again, Nodtveidt.
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Comments

Post by Mac »

> Cripes people, this is the easiest damn question to answer
> Thanks Nodtveidt for understanding my simple question

Glad you guys sorted that out. Now if you could work on your
personalties so that you could feel it in your self to respond
more kindly, you would really grow up and be smarter than your
teachers.

For your information, UDT is not a QBasic term. There is no
reason someone would guess what you want. Below is the QBasic
help on TYPE

Code: Select all

TYPE usertype
  elementname AS typename
  [elementname AS typename]
.
.
.
END TYPE

    ■ usertype       The name of the data type being defined. The name can
                     consist of up to 40 characters and must begin with a
                     letter. Valid characters are A-Z, 0-9, and period (.).
    ■ elementname    An element of the user-defined data type.
    ■ typename       The element's type (INTEGER, LONG, SINGLE, DOUBLE,
                     STRING, or a user-defined data type).
So the original question might have been understood by all QBasic
programmers if stated:

"How can I create a usertype in a SUB"

for which the answer is

"You can't. All usertype's must be defined in MAIN. Sorry!"

Mac

P.S. Also, usertype's must be defined at code-time. One cannot dynamically create a usertype at run-time, unless you are running
in the IDE and you create another program to CHAIN, or something
like that.
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt »

Mac, get a grip already. Ralph's answer was the only one that was actually worth something. I didn't expect roy to say anything intelligent whatsoever...he rarely does. But I at least expected YOU to know what DaveUnit was talking about...the phrase "UDT" is used in BASIC programming all the time. It's even in your little list.

DaveUnit, no problem, anytime. Quite frankly, it's not hard to know more than a programming teacher in school...I could have easily taught the C64 coding course in high school as well as the VB6 coding course in college far better than the teachers of both courses. It seems that programming courses are almost an educational afterthought and are usually taught by math teachers who couldn't code Hello World without a reference manual. Sad, really...
roy
Veteran
Posts: 55
Joined: Sun Jul 29, 2007 2:39 pm
Location: London

Post by roy »

The reason for my post was very intelligent if you knew the background.
This was a post recently by DaveUnit at FB.net :-
DaveUnit


Posted: Jan 22, 2008 11:25 Post subject:

--------------------------------------------------------------------------------

I agree with notthecheatr. OOP has greatly improved my code. If only we had true classes and inheritance.
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Post by Mac »

Nodtveidt wrote:I at least expected YOU to know what DaveUnit was talking about...the phrase "UDT" is used in BASIC programming all the time.
Well, I have the 950-page "Microsoft Quickbasic Bible" by The Waite Group, and I searched in vain for the acronym "UDT". It does not exist. It is just a slang that some people made up and used here and there, not an authoritative Microsoft term. Certainly not in QBasic Help Files". Slang, by the way, that I had never heard before today.

In the bible, I found "User-defined variable data types" so I guess if people used UVDT it would be closer.

Most people that I have seen referring to that construct have simply called them "TYPEs". For example, "Can I define a TYPE in a SUB?".

But say I didn't have any excuse for not knowing what the acronym because, in fact, QBasic HELP had a clear help entry under UDT. In other words, I am an ignorant fool. Still, it would be nice to not point that fact out, but instead to patiently explain.

> Cripes people, this is the easiest damn question to answer.

would be better be said

> Ah, for you have not seen the acronym before, UDT means "user data type" and refers to the TYPE statement you can find in the QBasic HELP.

Informative, non-insulting, mature, nice!

Mac
User avatar
Mentat
Veteran
Posts: 409
Joined: Tue Aug 07, 2007 3:39 pm
Location: NC, US

Post by Mentat »

Regardless of Microsoft's wording, in here UDT is generally assumed to be a special kind of proto|quasi-class.
For any grievances posted above, I blame whoever is in charge . . .
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Why continue this thread?

Post by burger2227 »

If the OP does not have the time to at least explain in ONE freaking paragraph what he wants, then the hell with him!

NOD, Goodbye and stay at the FB area where the rest of the Flamer morons loaf! You don't program anymore! You just Troll........

I agree with Roy. Why answer a lazy ass question in the first place?

There are workarounds, but this poster apparently just does not have the time to post any kind of code or even follow up with more info. Forget about him!

Ted

PS: Mac I love the list of possibilities you gave LOL. I guess you had some free time?
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
User avatar
Mentat
Veteran
Posts: 409
Joined: Tue Aug 07, 2007 3:39 pm
Location: NC, US

Post by Mentat »

Maybe DaveUnit feels that his question was answered well enough and he gave his thanks, or he doesn't have the time yet.
For any grievances posted above, I blame whoever is in charge . . .
DaveUnit
Veteran
Posts: 72
Joined: Sat Oct 29, 2005 10:07 am

Post by DaveUnit »

Wow the QB community has been reduced to a bunch of d1cks. I asked a simple, easy to understand question. I simply forgot if qb could handle returning user defined types from functions(UDT is a very common acronym, btw). Nodtveidt was the ONLY one to help me. The rest of you just flame me and say my question was "lazy" when I think it made perfect sense. It was not a complex question, I just forgot the answer. I've been using FB for so long now I forgot what could and could not be done in QB. My question didn't need any code to explain it. I wasn't coding an algorithm, it was a question of QB's features. And sorry for not responding right away, I don't eagerly await replies to my topics 24 hours of the day. I go to school and have a part time job and have a social life to keep alive. And this wasn't a question of OOP (@roy) either so I dunno why you bring that into the thread in the first place. Really people, stop being such assholes. If QB doesn't die of old age, it's because of internet assholes like yourselves.

Once again, thanks Nodtveidt. The ONLY helpful person left here apparently.
This place used to be helpful...
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt »

Yes DaveUnit, this place is almost useless nowadays for getting help. There are no decent coding sites left for QB at all.

Mac, according to amazon.com, that book is 650 pages, and was printed in 1990. It's almost 18 years old. Times change, coding discussions change. When one mentions a UDT in BASIC, it is always a User Defined Type. My intention was not to be insulting, but if you took it as an insult, then it just shows how soft-skinned you are. Toughen up, man...it's a dangerous world out there full of people who just don't give a shit. Again, I'm not being insulting, just pointing out the facts to you. Though you are right...I probably could have been a tad bit nicer in my delivery...I'm just not very tactful. :D

burger2227, I understood his question without difficulty. Why didn't you? Oh yeah, that's right...too busy cooking up lame new insults. It's just too bad you once again failed to come up with anything new...same old crap you've been spewing for ages now.
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Be nice

Post by Mac »

Nodtveidt wrote:Mac, according to amazon.com, that book is 650 pages, and was printed in 1990. It's almost 18 years old. Times change, coding discussions change. When one mentions a UDT in BASIC, it is always a User Defined Type. My intention was not to be insulting, but if you took it as an insult, then it just shows how soft-skinned you are.
Amazon must have a typo. I am staring right now at looking at page 650. It is a description of WRITE #. It is about 2/3 the way through the book.

The book is 18 years old. So what? QBasic is an antique language. That's what we love about it. An unchanged beautiful thing. Long live QBasic.

As far as a personal insult, forget it. I am well known amoung those who know me as being incapable of being insulted. I don't personally care. What I care is helping people like you learning how to be decent people people. That is far more important than computers, internet, or even QBasic. A decent person who cuts people slack 1) in traffic, 2) neighbors whose dogs poop in your yard, 3) etc.

Learn to be careful how to treat others is the key to a really nice life. If you read all I post everywhere, you will see a message - be nice! Not to me, to everyone. It's for your benefit!

And I am an atheist, so I'm not feeding you a lot of that religion crap.

Mac
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt »

Well, I'm not a people person, never have been and never will be, really. But at least I understand your intent and message.

I'm atheist too...secular humanist actually, but that's atheist. I think the vast majority of coders are atheists...we're scientists after all. :D
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

FINALLY!!!!!!!!!!!!!

Post by burger2227 »

Once you get flamed buddy, you sure have a WHOLE lot of nothing to say in 2 paragraphs! Don't get me wrong here. I am more than willing to help if I can figure out the question! ADMIT it! You spent a lousy minute typing that sentence in and got no replies until Nod finally figured it out.

For once he was helpful to you, but his constant bashing of QB and FB is intolerable to many. If anybody needs an intellegent smart ass then take your pick.

Post some freaking code or at least STFU about it. NEXT time post something discernable and with a LOT more effort.

Mac is a great QB programmer and all he tried to do was help. You seem to be very rude for not adding more information to begin with. No thanks is rude too. I will remember your smart ass and avoid you...........

Ted, still King!

PS: Nod the only one who believes you exist is yourself family man. LOL
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Post by Mac »

Nodtveidt wrote:I understand your intent and message.
Peace! :)

Mac
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Re: FINALLY!!!!!!!!!!!!!

Post by Mac »

burger2227 wrote:I will remember your (DaveUnit) smart ass and avoid you...........
Come on Ted, be nice!

Mac
Post Reply