12.07.2015 Views

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

96 Part I ■ Learning to ProgramA <strong>for</strong>mat string can contain literal characters <strong>and</strong> special conversion codesthat are used along with the arguments to create the final result. Conversioncodes begin with a percent sign (%) <strong>and</strong> contain one <strong>of</strong> the following specifiersthat indicate what type <strong>of</strong> data the argument should be treated as:%c—Takes a number argument <strong>and</strong> <strong>for</strong>mats it as the ASCII character thatcorresponds to the number.%d, %i—Takes a number argument <strong>and</strong> <strong>for</strong>mats it as a signed integer.%o—Takes a number argument <strong>and</strong> <strong>for</strong>mats it as an octal number.%u—Takes a number argument <strong>and</strong> <strong>for</strong>mats it as an unsigned integer.%x—Takes a number argument <strong>and</strong> <strong>for</strong>mats it as a hexadecimal number,using lowercase letters.%X—Takes a number argument <strong>and</strong> <strong>for</strong>mats it as a hexadecimal number,using capital letters.%e—Takes a number argument <strong>and</strong> <strong>for</strong>mats it as scientific notation, witha lowercase e.%E—Takes a number argument <strong>and</strong> <strong>for</strong>mats it as scientific notation, withan uppercase E.%f—Takes a number argument <strong>and</strong> <strong>for</strong>mats it as a floating-point number.%g <strong>and</strong> %G—Takes a number <strong>and</strong> <strong>for</strong>mats it according to either %e (or %Eif %G is specified) or %f, depending on which is shortest.%q—Formats a string so it can safely be read back into a Lua interpreter.%s—Takes a string <strong>and</strong> <strong>for</strong>mats it according to the supplied options.Several options can be used in a conversion specification between thepercentsign<strong>and</strong>thetypespecifier.Thefollowing options can be included, inthis specific order:1. Sign specification (either a + or a –) that causes a sign to be printed withany number. By default, the sign is only printed with negative numbers.2. A padding character (either a space, or a 0) that will be used whenpadding the result to the correct string width. By default, any results willbe padded with spaces to meet the correct width, if specified.3. An alignment specification that causes the result to be left-justified orright-justified. The default is right-justification, whereas a – characterwill make the result left-justified.4. A width specification that specifies the minimum width <strong>of</strong> the resultingstring.5. A precision specification that dictates how many decimal digits shouldbe displayed when <strong>for</strong>matting a floating-point number. When specified<strong>for</strong> strings, the resulting string will be cut <strong>of</strong>f at this number <strong>of</strong>characters.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!