Algosim documentation: LoadFromFile

LoadFromFile

Obtains data from a file-system file.

Syntax

Description

If fn is a fully-qualified file name, then LoadFromFile(fn) loads this file into an Algosim object which is returned. The type of the object is determined by the extension of fn. For instance, a file ending in .txt will be loaded into a string object, while a file ending in .png will be loaded into a pixmap object.

LoadFromFile(fn, ct), where ct is a string with an object class name, will load fn into a ct object, irrespective of the extension of fn.

Examples

LoadFromFile("D:\ALICE’S ADVENTURES IN WONDERLAND.txt") \ 50
ALICE’S ADVENTURES IN WONDERLAND

Lewis Carroll
…
LoadFromFile("D:\ALICE’S ADVENTURES IN WONDERLAND.txt", "binary data")
41 4C 49 43 45 E2 80 99 53 20 41 44 56 45 4E 54 55 52 45 53 20 49 4E 20 57 4F 4E 44 45 52 4C 41 4E 44 0D ...
LoadFromFile("D:\matrix.txt")
7	7	6	8	3	3	2	7	1	1
1	7	7	6	1	9	1	9	4	7
2	5	8	1	8	5	4	4	6	9
6	9	1	4	2	8	1	3	4	4
6	5	5	3	4	6	5	4	3	3
6	4	3	8	6	3	2	7	5	2
7	6	5	5	7	3	6	3	9	7
8	8	7	8	8	5	9	9	8	2
7	1	8	4	7	2	7	9	2	8
9	6	5	2	4	5	1	3	5	4
LoadFromFile("D:\Desktop\matrix.txt", "real matrix")
⎛7  7  6  8  3  3  2  7  1  1⎞
⎜1  7  7  6  1  9  1  9  4  7⎟
⎜2  5  8  1  8  5  4  4  6  9⎟
⎜6  9  1  4  2  8  1  3  4  4⎟
⎜6  5  5  3  4  6  5  4  3  3⎟
⎜6  4  3  8  6  3  2  7  5  2⎟
⎜7  6  5  5  7  3  6  3  9  7⎟
⎜8  8  7  8  8  5  9  9  8  2⎟
⎜7  1  8  4  7  2  7  9  2  8⎟
⎝9  6  5  2  4  5  1  3  5  4⎠

See also