Created
July 25, 2012 18:00
-
-
Save adamcameron/3177555 to your computer and use it in GitHub Desktop.
Example of using finally incorrectly: http://bit.ly/O9EXTS
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
function findEntry(filePath, entry) { | |
var file = ""; | |
var line = ""; | |
try { | |
file = fileOpen(filePath, "read", "UTF-8"); | |
line = ""; | |
while (!fileIsEOF(file)) { | |
line = fileReadLine(file); | |
if (listFirst(line, "=") == entry){ | |
// found it | |
return listRest(line, "="); | |
} | |
} | |
} | |
catch (any e){ | |
rethrow; | |
} | |
finally { | |
fileClose(file); | |
// didn't find it | |
return ""; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment