Created
October 20, 2020 12:05
-
-
Save shspage/97bb67116072263a3a271f8ff5438b68 to your computer and use it in GitHub Desktop.
Adobe Illustrator: loading a file example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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