Skip to content

Instantly share code, notes, and snippets.

@shspage
Created October 20, 2020 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shspage/97bb67116072263a3a271f8ff5438b68 to your computer and use it in GitHub Desktop.
Save shspage/97bb67116072263a3a271f8ff5438b68 to your computer and use it in GitHub Desktop.
Adobe Illustrator: loading a file example
// refer to "JavaScript Tools Guide" for more information about File object.
// https://www.adobe.com/content/dam/acom/en/devnet/scripting/estk/javascript_tools_guide.pdf
function loadFile(){
var data;
try{
var f = File.openDialog("select input file");
if(f == null) return;
if(!f.open("r")){
alert("failed to load");
return null;
}
data = f.read();
f.close();
} catch(e){
alert("failed to load:" + e.message);
return null;
}
var lines = data.split("\n");
alert(lines[0]);
return lines;
}
var lines = loadFile();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment