FontLab Forum
2012-05-23, 23:55:13 *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome to the FontLab forum, read how to use it! Update: Archives from old MSN forums are now available on our forum.
 
   Home   Help Search Calendar Downloads Tags Login Register  
Del.icio.us Digg FURL FaceBook Stumble Upon Reddit SlashDot

Pages: [1]
  Print  
Author Topic: Write File Error  (Read 2737 times)
malcolm
Hero Member
*****

Karma: +0/-0
Posts: 29


Email
« on: 2011-01-20, 10:11:04 »

Hi

I am trying to stop an error being raised whenever my macro gets to the part of writing a file, and then the user decides to Cancel. In my script I have something like:

Code:
output = open(fl.GetFileName(0, "txt", "KernPairs", "Kern Pairs (*.txt)"),'w')
output.write(KernData)
output.close()

But if the user clicks 'Cancel' in the Save dialog an error is raised. How can I stop this?

thanks
Logged
Eigi
Beta: FontLab Studio Mac
Hero Member
***

Karma: +7/-0
Germany Germany

Posts: 57



WWW
« Reply #1 on: 2011-01-20, 10:25:19 »

Try this:

Code:
filename = fl.GetFileName(0, "txt", "KernPairs", "Kern Pairs (*.txt)")
if filename:
    output = open(filename, 'w')
    output.write(KernData)
    output.close()
« Last Edit: 2011-01-20, 10:27:06 by Eigi » Logged
malcolm
Hero Member
*****

Karma: +0/-0
Posts: 29


Email
« Reply #2 on: 2011-01-20, 11:14:19 »

Cool, thanks Eigi
 Smiley
Logged
Tags:
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!