Programming Guide



sm_*ww_length

Gets the number of characters in a wordwrapped multiline text widget

int sm_ww_length(int field_number);
int sm_n_ww_length(char *field_name);

field_number, field_name
Specifies the field whose length is required. Word wrapped text is allowed only in multiline text widgets whose word_wrap property is set to PV_YES.

Returns

Description

sm_ww_length returns the number of bytes in a word wrap field—that is, a multiline text widget whose Word Wrap property is set to Yes. You can call this function to get the offset into the end of word wrap field data, then use that offset to append data to the field with sm_ww_write. You can also use it to determine how large a buffer you need to allocate for reading word wrap field data with sm_ww_read.

Example

/* this JPL procedure reads text from a filestream and
* reads each line into a word wrapped field. It uses
* sm_ww_write to reformat the file text so that it
* wraps within the field.
*/

proc wrapFileTextToMulti
{
vars str, last_char, wwErr, err, fileStream

call sm_fio_error_set(0)

/* get file stream sent from previous dialog */
receive DATA fileStream
err = 0
while (err == 0)
{
str = sm_fio_gets(fileStream, 255)
/* check for error condition like EOF */
if (str != "")
{
last_char = sm_n_ww_length("comments")

/* if writing to empty array */
if (last_char = 0)
{
wwErr = sm_n_ww_write("comments", str, last_char)
}

/* otherwise add space after last char before write*/
else
{
wwErr = sm_n_ww_write("comments", " ", last_char)
wwErr = sm_n_ww_write("comments", str, last_char+1)
}
}
else
{
err = sm_fio_error()
}
}
call sm_fio_close(fileStream)
return
}

See Also

sm_ww_read, sm_ww_write