When trying to save the text written to a file in a new window locally, I encountered an error while using the saveAs
and msSaveBlob
methods.
window.navigator.msSaveBlob(blob, 'msSaveBlob_testFile.txt');
var blob = new Blob([output], {type: "text/plain;charset=utf-8"}); saveAs(blob, "thing.txt");
function exportGeometry ( ) {
var output=[];
output.push("//TLR:Format:Vishama Creations:v1.0\n//Pattern_no,Pattern_NumLines,FrstPointIndx,PointName,aX,aY,aZ,bX,bY,bZ,SecondPointIndex,PointName,aX,aY,aZ,bX,bY,bZ\nL\n");
output.push(fpatternIndex);
output.push(fpatternLineCount);
output.push(fpatternPointCount);
for(var b=0;b<fpatternLineCount;b++)
{
output.push(ffirstPtIndx[b]);
output.push(fpatternPointName[ffirstPtIndx[b]]);
output.push(fpatternPoint[ffirstPtIndx[b]].x/300);
output.push(fpatternPoint[ffirstPtIndx[b]].y/300);
output.push(fpatternPoint[ffirstPtIndx[b]].z/300);
output.push(fsecondPtIndx[b]);
output.push(fpatternPointName[fsecondPtIndx[b]]);
output.push(fpatternPoint[fsecondPtIndx[b]].x/300);
output.push(fpatternPoint[fsecondPtIndx[b]].y/300);
output.push(fpatternPoint[fsecondPtIndx[b]].z/300);
}
output.push("\nL\n");
output.push(bpatternIndex);
output.push(bpatternLineCount);
output.push(bpatternPointCount);
for(var b=0;b<bpatternLineCount;b++)
{
output.push(bfirstPtIndx[b]);
output.push(bpatternPointName[bfirstPtIndx[b]]);
output.push(bpatternPoint[bfirstPtIndx[b]].x/300);
output.push(bpatternPoint[bfirstPtIndx[b]].y/300);
output.push(bpatternPoint[bfirstPtIndx[b]].z/300);
output.push(bsecondPtIndx[b]);
output.push(bpatternPointName[bsecondPtIndx[b]]);
output.push(bpatternPoint[bsecondPtIndx[b]].x/300);
output.push(bpatternPoint[bsecondPtIndx[b]].y/300);
output.push(bpatternPoint[bsecondPtIndx[b]].z/300);
}
var blob = new Blob([output], {type: "text/plain;charset=utf-8"});
var objectURL = URL.createObjectURL(blob);
window.open(objectURL, '_blank');
window.focus();
};
Attempting to use saveAs(blob ,test.txt) resulted in an error stating that saveAs is not defined.