07.05.2015 Views

Download the documentation - True BASIC

Download the documentation - True BASIC

Download the documentation - True BASIC

SHOW MORE
SHOW LESS

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

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

16 Statistics Graphics Toolkit<br />

TextToNum2 (n$(,), n(,))<br />

TextToNum converts a string array n$(,) to <strong>the</strong> corresponding numeric array n(,) by<br />

using StatVal on each element. The two arrays needn’t have <strong>the</strong> same bounds; <strong>the</strong> target<br />

array’s lower bounds are left untouched and its upper bounds adjusted.<br />

NumToText2 (n(,), n$(,))<br />

NumToText converts a numeric array n(,) to <strong>the</strong> corresponding string array n$(,) by<br />

using StatStr$ on each element. The two arrays needn’t have <strong>the</strong> same bounds; <strong>the</strong> target<br />

array’s lower bounds are left untouched and its upper bounds adjusted.<br />

GetStatFile (#n, n$(,))<br />

GetStatFile reads a text file full of statistics data into an array. The file #n must be<br />

opened before you call GetStatFile by a statement such as OPEN #1: NAME “datafile”.<br />

Each row and column of <strong>the</strong> text file data goes into <strong>the</strong> appropriate item of n$(,).<br />

Each line of <strong>the</strong> text file is treated as a row. Blank lines are ignored. Columns are separated<br />

by ei<strong>the</strong>r a tab character, or two or more spaces. Lines in <strong>the</strong> file may have different<br />

numbers of columns; short rows are “left justified” in <strong>the</strong> n$(,) array. Thus if <strong>the</strong><br />

first line in a file contains three columns but some line within <strong>the</strong> file contains only one<br />

data item, <strong>the</strong> last two n$(,) entries for that line are <strong>the</strong> null string. For example:<br />

File<br />

n$(,)<br />

Name Age Weight “Name” “Age” “Weight”<br />

Allen 34 185 “Allen “34” “185”<br />

Byron 170 “Byron” “170” ““<br />

Darcy “Darcy” ““ ““<br />

These rules let you read SPSS files, Excel files, Lotus 1-2-3 files, and text files created<br />

by most common application programs.<br />

Note that all data items are taken as strings; thus you can use files that include column<br />

headers, extraneous information, etc. To convert n$(,) to a numeric array, changing<br />

all nondata items to missing values, try:<br />

call SetHaveMissing(1)<br />

call SetMissingText(““)<br />

call TextToNum2(n$(,), n(,))<br />

See <strong>the</strong> program GETFILE on your disk for an example.<br />

01/01

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

Saved successfully!

Ooh no, something went wrong!