Qbasicnews.com

Full Version: Variable arguments help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
So, I want a function that can take any number of args, of any type, and print their values out..

Somethig like:
Code:
function foo(arg1 as any, ...)

print arg1, arg1.type

if numArgs then
    for a = 0 to NumArgs
        print ArgValue(a), ArgType(a)
    next
end if
exit function
And yes, I know I'm not using the correct syntax/keywords..


And on a sidenote:
va_first
va_arg
va_next

How about:
ArgAmount 'total number of passed arguments, always, even when not using ..., or only when using ...

ArgValue(N) 'return the value, correctly, type independent, so i dont have to use only integers, of the N'th arg

Yes, more code, and slower EXE if you're using variable argument count.. But way easier to work with.. not to mention WAY more basic..
I don't particularly like this idea... it smells of Variants and other gnarly, nasty Visual Basic things. I personally like the va_* routines, because they're similar to C... VB's version of varargs is slow, ugly, and dependent upon Collections, which are also slow, ugly, and dependent upon the Variant data type. In this case, I think (note: personal opinion! C zealot avoidance warning!) that C's way of doing things is better than any BASIC implementation I've seen. Feel free to point out a better way that doesn't slow things down and uglify them.
So, make me an example, like I said..

And yes, I've looked at the "official" example.. and no, it doesent make any sense..
Noone?

But.. but.. but.. I thought you all bashed me and said this was easy sheit, and I should stop whining?


Really, I have no idea how to do what I'm asking for..

Why? Cause the commands make no sense to me, and I have a strong feeling you cant pass them in any order, but must pass them typewise..

Which kind of makes varargs useless.. Use a freakin array instead!


And yes, I know you can pass different types, but it appears they have to be in the same order, always..
Take your favorite C book and look it up. :lol:

FreeBasic always preferese the faster way independent of whether it's more complicated and error prone. (You know passing a variable amount of arguments is most often the bottleneck in your application Wink ).
That makes perfect sense!

So, I have to learn C, to code in FreeBASIC
Silly me for not understanding that...


No really, you all claim that va_* is faster, better, easier, etc etc yadda yadda bsgallore..

Yet, noone can produce a sample code like the one I request?
Yet, noone can answer ANY of the questions I ask..

All you seem to be able to do is: ZOMG!!11 n00b!11 LEARN C!!11

If I wanted to hear such things I would have stayed with C back when I started in programming..


Really, prove to me that va_* is so much better etc, yadda yadda..

And uhm.. so what if it's more like C.. Last time I checked (about a few seconds ago) FreeBASIC wasnt C.. Really, I'm pretty sure..

Feel free to correct me if I'm wrong..



I have nothing against C as a language (well, besides the ; ) what I have a grudge against is the retarded dumbfucks who make up most of the C community..

And when you reply like you have done to this matter.. you're all coming dangerously close to that..



Prove me wrong.. make me an example that does what I request..
Actually this problem has me intriged as well, anyone got some code?
After playing with it as well, I can't get it to work. It looks like it doesn't care for the any data type. So, I add my voice to those that would like to see how to do this. However, I add my voice in a humble manner.

<rant>
When members start using such childish phrases as those that have been used so far it puts a damper on anyone wanting to help.

FB is a labor of love. Vic isn't getting paid, nor Lilo nor Von nor any of the kind people who come here to help. FB started (correct me where I am wrong, I'm still a newish FB person) as a QB replacement. It has done that.... everything else is just sweet extra. Sometimes that extra may come at a price (like learning a little of C's better habits).

So perhaps if memebers behave more like peers trying to help one another instead of children who are going to scream and curse if they don't get their way (right, NOW NOW NOW NOW NOW), we will all gain here.

And if you haven't thanked Vic and crew for their work recently, perhaps you should. <Thanks to Everyone>

Sorry I went here, but this kind of thing doesn't belong on this board. Leave the childishness to the C++ people :rotfl:
</rant>
I'm not going to praise v1c 24/7 for FB.

If theres something I dont like I'm going to speak my mind about it, and so should everyone else.


He's not making FB for himself, if he was.. why is he releasing it?

He must listen to his userbase (read: us) or FB will be short-lived indeed..


Though it probably will anyways.. for various reasons not to discuss here.. catch me on IRC, MSN or PM if you really feel like talking about it
I'm not saying to not speak one's mind. Feedback is great! But there are better and more articulate ways to express it. These more mature way are a lot more powerful.

Praise Vic for doing it, and then point out constructively how to make it better.

Or, it is open source, hop in there and "fix" it. Big Grin
Pages: 1 2 3 4