WWGetString Function Library

Posted on 333 views

Description

WWGetString() is used to get strings out of an ASCII-file, which includes a number of strings each characterized by an unique index.

Use

Output = WWGetString(Path, Separator, Index);
Path A Message tag or a quoted string (example: “C:\text.csx”) with the path of the ASCII-file)
Separator A Message tag or a quoted string (example: “;”), which is used as separator in the csv-file
Index A Integer tag  (example: 1), which is also included in the csv-file reffering to a textstring
Output A Message tag that is used to return the corresponding string of the index-number

Returns

If the function works OK, the corresponding string of the  index-value will be returned, otherwise the corresponding error message is returned by the function.

The following table lists possible error messages:

Error message

File open error!
File close error!
Index number not found!
Index number too long!
Wrong separator found behind index number!
Line in file too long!
String is empty!
String too long!
One or more index number(s) in CSV-file too long!

Details of WWGetString()

A special format is needed for the ASCII file that holds the indices and the corresponding strings:
Each single line of the file can only hold one index plus the corresponding string. The line must begin with the index (a simple number). Leading spaces and zeros are ignored.

Index numbers of different lines do not have to be in any order. The maximum index number allowed is 999999. However, for performance reasons it is better to divide a very large ASCII file in multiple, smaller files.

The number must be followed by a separator (comma, semicolon or similar). Spaces will be ignored.
The rest of the text in the line following directly behind the separator is the string which corresponds to the index number.
Lines that do not start with a number are interpreted as comment lines and therefore are not used by the function WWGetString().

Since the index and the string are separated, this type of file is often referred to as a comma separated values file or CSV. Only ASCII characters may be used in the file. Individual lines must be terminated by a Carriage Return/New Line that is by the ASCII characters 13 and 10. Such a file can be generated by most of the spreadsheet programs for windows and – most simply – by the notepad editor of windows. Be aware that most word processors generate no pure ASCII files in their standard configuration.

Example of Using WWGetString()

Sample File

A typical file used with WWGetString() may look as follows:

1  ,First entry
2  ,  Second entry
1000,Entry with a high index number

Imagine this file is saved at C:\TEST.CSV then

Output = WWGetString(“C:\TEST.CSV”, “,”, 1); results in Output= “First Entry”
Output = WWGetString(“C:\TEST.CSV”, “,”, 2); results in Output= ” Second Entry”
Output = WWGetString(“C:\TEST.CSV”, “,”, 1000); results in Output= “Entry with a high index number”

Download the WWGetString.zip file.

  1. Unzip the WWGetString.zip file.
  2. Copy the WWGetStr.dll, WWGetStr.wdf and WWGetStr.hlp files and place them in your InTouch™ Install directory.

The function will then be available from scripts when running WindowMaker.

Leave a Reply

Your email address will not be published. Required fields are marked *

4 × = 12