sprintf

By tlacaelel Last update Aug 29, 2007 — Installed 206 times.

Archived Comments (locked)

in
Subscribe to Archived Comments 8 posts, 3 voices



Jesse Andrews Admin

The following is an archive of comments made before threaded discussions was implemented (November 16th, 2008)

 
tlacaelel Script's Author

C'mon people, stop my monolog.

 
tlacaelel Script's Author

usage


>>> x = new String(" Hello %s ");
[" ", "H", "e", "l", "l", "o", " ", "%", "s", " "]
>>> x.sprintf(" ? ")
" Hello ? "
>>> x.sprintf(" ? ", "a")
" Hello %s "
>>> x.sprintf(4)
" Hello 4 "
>>> x = new String(" %s %s ! ")
[" ", "%", "s", " ", "%", "s", " ", "!", " "]
>>> x.sprintf("Hello", "World")
" Hello World ! "
>>> x.sprintf("Hello", "John")
" Hello John ! "
>>> x.sprintf("Hello", "Good Nite")
" Hello Good Nite ! "
>>> x.sprintf("Hello", "Good Bye")
" Hello Good Bye ! "
>>> x.sprintf("Hello", ", Good Bye")
" Hello , Good Bye ! "
>>> x.sprintf("Hello", "& Good Bye")
" Hello & Good Bye ! "

 
tlacaelel Script's Author

problem fixed, it works!

I added it to the String-object's prototype
below it's a firebug test!


>>> x = new String(" Hello %s ");
[" ", "H", "e", "l", "l", "o", " ", "%", "s", " "]
>>> x.sprintf(" ? ")
" Hello ? "

 
tlacaelel Script's Author

Does somebody have an idea for this issue?

I have been trying different kinds of things but nothing works!

I made this function so it can be adapted to other programs but there is no way to execute it.

perhaps it gets executed previously somewhere in the cache or something like that?

if you look at the source you may see what I've
tried.

at the moment I am doing an extension to the Object & String prototypes.

any other ocurrences?

I also tried to copy the function to the window or document property but whenever I try to reach it through the firebug console, its unreachable or something!

probably gets set as a private method?

 
tlacaelel Script's Author

thx pojo, I added it as a firefox extension and tried to run it through the firebug console but it didn't work perhaps it gets executed but it never reaches the actual document for execution.

so I am making a test script that will execute the sprintf function lets see how it works. cheers!

 
pojo Scriptwright

good idea :)

 
tlacaelel Script's Author

okay!
well.. can somebody see this?

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel