jpm Posted January 26, 2004 Share Posted January 26, 2004 I want to implement a StringFormat("printf format", var1, ... varn) How can I generate the sprintf(szBuffer, vParams[0].szValue(),vParams[1].szValue(), vParams[2].szValue(), vParams[3].szValue(), vParams[4].szValue(), vParams[5].szValue()); the above is only working if the var's are strings and a fixed number of parameter I cannot manage to have the type of the var used. I would prefer a variable number of parameters as in sprintf Thanks for the help Link to comment Share on other sites More sharing options...
Administrators Jon Posted January 26, 2004 Administrators Share Posted January 26, 2004 Just have a high optional number of parameters, like {1, 32}. Then you can see how many parameters you were actually passed with iNumParams. Use vParams[n].isNumber and .isString to see what type of param was passed. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
jlandes Posted January 26, 2004 Share Posted January 26, 2004 Do you plan on implimenting any format type functions into AutoIt? This way I know if I should spend the time at this point trying to write UDFs. Thanks. Sincerely yours,Jeremy Landesjlandes@landeserve.com Link to comment Share on other sites More sharing options...
jpm Posted January 26, 2004 Author Share Posted January 26, 2004 Just have a high optional number of parameters, like {1, 32}. Then you can see how many parameters you were actually passed with iNumParams. Use vParams[n].isNumber and .isString to see what type of param was passed.Jon, that does solve the type of parameter sprintf is requesting. I cerlainly need to split the "printf format" at each reference and concataned the different piece. I don't know how sprintf is implemented but they did it perhaps with the help of the compiler So I will split/concatanate Thanks Link to comment Share on other sites More sharing options...
Valik Posted January 26, 2004 Share Posted January 26, 2004 I've seen an implementation of a sprintf-like function that did something along the lines of look for a % and when that's found, enter a case structure and compare the next character to 'c', 's', 'd', 'f' et cetera. If it matched, then it does the necessary type conversions or whatever. Otherwise, the characters are just concactenated to the string it's making. The function is long and ugly, but it's probably more meticulous to write than it is anything else. However, the version I saw was optimized for some specific use (I can't remember exactly what). Link to comment Share on other sites More sharing options...
jpm Posted January 26, 2004 Author Share Posted January 26, 2004 I've seen an implementation of a sprintf-like function that did something along the lines of look for a % and when that's found, enter a case structure and compare the next character to 'c', 's', 'd', 'f' et cetera. If it matched, then it does the necessary type conversions or whatever. Otherwise, the characters are just concactenated to the string it's making. The function is long and ugly, but it's probably more meticulous to write than it is anything else. However, the version I saw was optimized for some specific use (I can't remember exactly what).Thanks Valik,That almost what I described. I think I have an implementation for tomorrow Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now