Can you pass a string to a function like this?
Basically if you have this function :
public myfunc( blah, blah[], ... ) { } Can you pass something like: myfunc( 12, "hello %s %s", "world", "!" ); Is this at all possible? I just don't want to keep doing a format() before a function call... Thanks, Josh |
Not as far as I know. The way string formatting works is by using format in whatever function allows you to do it. For example, client_print allows you to format strings because it has format coded inside it.
If you somehow coded format into your function, you might be able to, but otherwise I don't think so. |
Yea I was worried that it would have to be a module function :/
|
If you know the exact number of args, you could probably do this, although I don't know how safe it is:
Code:
|
Yes it's possible. I'll try to find the functions in a bit and then post back.
|
Ah yes... Found it.
I use this while debugging my plugins. The part that you're most interested in is my use of the format_args function. It essentially acts as the format function and, as such, returns a formatted string. Let me know if you have any questions. Code:
|
There are also functions for getting the unknown arguements, and setting them, as they are all passed by reference.
|
Thanks guys, Brad I think that's exactly what I need...
:) |
Guys I'm getting total garbage...
This is how I call it: Code:
This is the function: Code:
Can I not do the %L stuff w/format_args ?? |
NOTE: format_args() is deprecated. It was never ported to the new format() system. It's also a really messy native that I think is basically unused.
I'll try to add something new and pretty, like: Code:
Also, I think your 3 should be a 5 (not entirely sure, maybe a 4). |
| All times are GMT -4. The time now is 16:42. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.