debug()  log()

Chapter 5: General Objects and Methods

format()

Description

Mimics the C sprintf API, putting the data into the string. The arguments are the format string and the arguments are listed in the format string. printform uses the same formatting as the C sprintf API.

Syntax

format(string printform, args);

Parameter

Description

printform

Print formatting.This string should be in the format of C language sprintf strings, with parameter characters preceded by a percentage character (%).

args

Any arguments called for in the printform. If the character is a control character, it must be in either local or hexidecimal format.

Return value

Integer. Returns 1 for success, and 0 for failure.

Usage

Pointer to object

Object

ps->format (“%02d times %01d =    %i”,a,3.5, a*3.5);

mystring.format    (“Hello, %s,name);

The object would then hold    “3.66 times 3.5 = 12.81”

mystring would then hold    “Hello, Ed”

Examples

Example 60

The format string has 3 arguments: a decimal with 2 places, a decimal with 1 place, and an unlimited decimal. The object would hold “3.66 times 3.5 = 12.81”.

mystring.format (“%.2d times %.1d = %i”, a,3.5, a*3.50);




Copyright © 2005. Sybase Inc. All rights reserved. log()

View this book as PDF