PDA

Click to See Complete Forum and Search --> : Importing a matrix from a text file?



Swim'nSasquatch
01-21-2003, 05:45 PM
Is it possible to import a matrix from a *.txt file into flash?
How do the data points have to be de-lineated?
What are the commands to differentiate between Data Points?

This is for a school project where we need to import a (100x100) matrix from an external file in TXT format, perform gaussian elimination, then use the Upper triangular solution method to return 100 values in a 1x100 matrix. Once the above questions are answered I should be OK. Thanks in advance for any help.

-SwimminSasquatch

yams
01-23-2003, 03:23 PM
yes! When I do it I just add an "variable" + "=" on a line before the numbers.
Ex. this is my text file (exported from a 3D program):

Points=
0 -100 -100 -100
1 -100 100 -100
2 100 -100 -100
3 100 100 -100
4 100 -100 100
5 100 100 100
6 -100 -100 100
7 -100 100 100

This is my code to put them into an array (obj is where you want your array):

objInfo.prototype.loadPoints = function(file, obj) {
var loadPoints = new LoadVars();
loadPoints.load(file);
loadPoints.onLoad = function(success) {
if (success) {
obj.pointsData = new Array();
obj.pointsData = this.points.split("\n");
obj.pointsData.pop();
obj.pointsData.shift();
for (var i = 0; i<obj.pointsData.length; i++) {
obj.pointsData[i] = obj.pointsData[i].split("\t");
obj.pointsData[i].shift();
obj.pointsData[i][obj.pointsData[i].length-1] = obj.pointsData[i][obj.pointsData[i].length-1].slice(0, -1);
}
} else {
this.loadedData = false;
}
};
};

Swim'nSasquatch
01-24-2003, 12:08 PM
Thanks Yams, That helps a bunch!