Am i using the try-catch right?

The compiler gives me ompile error saying "catch without try".
Here's parts of my code....
          if ( actionIs.equals( Name.ADD ) ) {
              try
                  amount = Integer.parseInt(theInputPQ.getText());
                  if (amount < 0) {
                  theOutput.setText("Try Again");
            else
                  theStock.addStock(pn, amount);
                  theAction.setText(               
                  pr.getDescription() + " : " + 
                  theMoney.format(pr.getPrice()) +
                  " (" + pr.getQuantity() + ")" );
                catch (NumberFormatException e) {
                    theOutput.setText("Try Again");
                Product pr = theStock.getDetails( pn );             
                theAction.setText(                   
                pr.getDescription() + " : " +      
                theMoney.format(pr.getPrice()) +   
                " (" + pr.getQuantity() + ")" );
            if ( actionIs.equals( Name.ADD ) )
          } else {                                  // F
            theAction.setText(                      //  Inform Unknown
              "Unknown product number " + pn        //  product number
        }

Here's parts of the code....
                  try
                      amount = Integer.parseInt(theInputPQ.getText());
                      if (amount < 0) {
                          theOutput.setText("Try Again");
                        else
                            theStock.addStock(pn, amount);
                            theAction.setText(               
                            pr.getDescription() + " : " + 
                            theMoney.format(pr.getPrice()) +
                            " (" + pr.getQuantity() + ")" );
                        catch (NumberFormatException e) {
                            theOutput.setText("Try Again");
                        Product pr = theStock.getDetails( pn );             
                        theAction.setText(                   
                        pr.getDescription() + " : " +      
                        theMoney.format(pr.getPrice()) +   
                        " (" + pr.getQuantity() + ")" );

Similar Messages

  • About the finally block of the try catch.

    I know that finally block contains the code that will be executed in any condition of the try catch.
    However, I think it is unneccessary, since the stack after the try catch stack will be executed any way.
    Any one can help?
    for example
    try{
    System.in.read();
    catch(Exception e){}
    finally
    { System.out.println("does this matter?");}and
    try{
    System.in.read();
    catch(Exception e){}
    System.out.println("does this matter?");

    However, I think it is unneccessary, since the stackafter the try catch
    stack will be executed any way.That does assume that you catch and handle the error
    appropriately.
    Of course this is valid as well, and demonstrates
    when you would WANT a finally clause.
    Connection con = null;
    Statement stmt = null;
    try{
    con  = Database.getConnection();
    stmt = con.createStatement("Select * from dual");
    // maybe something throws an exception here?
    finally{
    if (stmt != null){
    stmt.close();
    if (con != null){
    con.close();
    The finally block here might throw a null pointer exception itself use
    null!=stmt null!=stmt

  • How to get the returned error messages in the Try/Catch block in DS 3.0?

    A customer sent me the following questions when he tried to implement custom error handling in DS 3.0. I could only find the function "smtp_to" can return the last few lines of trace or error log file but this is not what he wants. Does anyone know the answers? Thanks!
    I am trying to implement the Try/Catch for error handling, but I have
    hard time to get the return the msg from DI, so I can write it to out
    custom log table.
    Can you tell me or point me to sample code that can do this, also, can
    you tell me which tables capture these info if I want to query it from
    DI system tables

    Hi Larry,
    In Data Services XI 3.1 (GAd yesterday) we made several enhancements for our Try/Catch blocks. One of them is the additional of functions to get details on the error that was catched :
    - error_message() Returns the error message of the caught exception
    - error_number() Returns the error number of the caught exception
    - error_timestamp() Returns the timestamp of the caught exception.
    - error_context() Returns the context of the caught exception. For example, "|Session Datapreview_job|Dataflow debug_DataFlow|Transform Debug"
    In previous versions, the only thing you could do was in the mail_to function specify the number of lines you want to include from the error_log, which would send the error_log details in the body of the mail.
    Thanks,
    Ben.

  • How to know if a UDF form is opened else then using a TRY CATCH ?

    I'm looking for any way to find out if the UDF form is visible
    else then trying to open it in a try catch and if it's not sending a key.  This if very ugly, slow and not really my kind.
    I tried to iterate through all the forms in SBO_Application.Forms but it's not there.  All I see is the main form
    I just need to make sure the UDF form is visible when Inventory form is loaded so I can put a value in one of the UDF
    If there's a better way I'm buying it

    Hi Marc,
    Rather than putting your data in the UDF in the UDF side form, you can add a control to the main form (during the load event of the form) and bind this to the UDF through the DBDataSource that is already available on the main form. This means that you don't need to worry about whether the UDF form is open or not because you can always read or write to your UDF data from the main form.
    Alternatively, the UDF form TypeEx property is always the same as the main form but with a minus sign in front. Therefore, if you know the TypeEx and FormTypeCount of the main form then you can use the GetForm method of the Application object to get the UDF form.
    oForm = _sboApp.Forms.GetForm("-" + oMainForm.TypeEx, oMainForm.TypeCount);
    You'd still need a try/catch around this and if it raises an error then activate the 6913 menu to open the UDF form.
    Kind Regards,
    Owen

  • How does one use the middle and right buttons in AIR without the cursor showing?

    All I want to do is use all three botton clicks without the cursor showing (assistive technology situation). So I use Mouse.hide(). All works fine with the Left mouse button. With the middle and right buttons the cursor reappears as soon as the middle and right mouse is in the DOWN state (and stays visible until rehidden--see code). Are there Mouse parameters that could be added? (I can't find any such references.) Do I need to create a custom cursor Class that makes the cursor invisible at all times? Here is my simple AS 3 test code.
    // MyClickListener.fla
    // Using the Stage to listen for button events
    // Why do the Middle and Right clicks reexpose the mouse cursor as soon as the DOWN state is encountered?
    import flash.display.DisplayObject;
    import flash.events.*;
    import flash.ui.Mouse;
                Mouse.hide();
                var leftClick:int = 0;
                var middleClick:int = 0;
                var rightClick:int = 0;   
    function leftClickHandler(event:MouseEvent):void
                // Mouse.hide();   // I do not need this -- mouse cursor does not reappear
                trace(event.target.name);          
                trace("You pressed the Left Button.");
                leftClick ++;
                trace("Left Clicks = " + leftClick);
    function middleClickHandler(event:MouseEvent):void
                Mouse.hide(); //I use this to rehide the mouse that reappears after click.
                trace(event.target.name);
                trace("You pressed the Middle Button.");
                middleClick ++;
                trace("Middle Clicks = " + middleClick);
    function rightClickHandler(event:MouseEvent):void
                Mouse.hide();  // I use this to rehide the mouse that reappears after click.
                trace(event.target.name);
                trace("You pressed the Right Button.");
                rightClick ++;
                trace("Right Clicks = " + rightClick);
    stage.addEventListener(MouseEvent.CLICK, leftClickHandler);
    stage.addEventListener(MouseEvent.MIDDLE_CLICK, middleClickHandler);
    stage.addEventListener(MouseEvent.RIGHT_CLICK, rightClickHandler);
    Help appreciated.
    Thanks,
    Michael
    Message was edited by: MBM111

    Dear Tuttle and Tom:
    You both sent me to the appropriate place. I downloaded the instruction file (PDF). Many thanks.
    Incidentally, I then downloaded the upgrade offered at the top of that page (from v3.2 to v3.2.4) but after ±90% of the necessary time needed, it shut down with a "Failed to Mount" message (whatever that might mean). It took more than 28 minutes to download that much even though I'm using DSL! Have either of you upgraded to v3.2.4 with or without difficulty?
    Thanks again for your right-on assistance.
    PowerBook G4   Mac OS X (10.4.2)  

  • Comment on my use of try / catch / finally

    Below is a code fragment from an application I'm working on. I have a couple questions about it. Is the way that I'm using "finally" correct? It's supposed to make sure the Connection gets closed. Note that I have a separate class close the Connection.
    (ConnectionFactory is a class I wrote so I don't have to write the DB connection code over and over.)
            Connection con = null;
            try
                con = ConnectionFactory.getPooledConnection(Constants.JNDI_DS_NAME_LOCAL);
                Statement stmt = con.createStatement();
                stmt.executeUpdate("DELETE FROM person WHERE ID='" + personFormBean.getID() + "'");
            } catch (SQLException e)
                System.out.println(e.getMessage());
                e.printStackTrace();
            } finally
                ConnectionFactory.close(con);
            }Here's how I close the Connection:
        public static void close(Connection con)
            try
                if (con != null && !con.isClosed())
                    con.close();
            } catch (SQLException e)
                System.out.println(e.getMessage());
                e.printStackTrace();
        }My other question is about the code in the catch block. Is there anything different that should be done in the catch block?

    Below is a code fragment from an application I'm
    working on. I have a couple questions about it. Is
    the way that I'm using "finally" correct? It's
    supposed to make sure the Connection gets closed.
    Note that I have a separate class close the
    Connection.Excellent. I do this, too. (First person I had suggest it was jverd on this forum.)
    >
    (ConnectionFactory is a class I wrote so I don't have
    to write the DB connection code over and over.)
            Connection con = null;
    try
    con =
    con =
    con =
    ConnectionFactory.getPooledConnection(Constants.JNDI_D
    S_NAME_LOCAL);
    Statement stmt = con.createStatement();
    stmt.executeUpdate("DELETE FROM person
    FROM person WHERE ID='" + personFormBean.getID() +
    } catch (SQLException e)
    System.out.println(e.getMessage());
    e.printStackTrace();
    } finally
    ConnectionFactory.close(con);
    }Here's how I close the Connection:
        public static void close(Connection con)
    try
    if (con != null && !con.isClosed())
    con.close();
    } catch (SQLException e)
    System.out.println(e.getMessage());
    e.printStackTrace();
    }My other question is about the code in the catch
    block. Is there anything different that should be
    done in the catch block?Looks fine. I'd recommend that you add methods to explicitly close Statement and ResultSet, too. Call the method to close statement in the finally block before you close the Connection.
    I think logging the stack trace is the best thing to do. Printing the stack trace is okay, as long as someone can actually SEE the System.out stream. I think printing the message is a waste.
    Do you want commit/rollback logic for the DELETE?
    I'd pass the Connection into the method so it can participate in a unit of work. I don't have SQL methods get their own statement. Let the caller be responsible for obtaining and closing the Connection.
    CRUD operations in DAO is a nice pattern. I commend it to you.
    You do a lot right here, but I think it's possible to do better still.
    %

  • Scrolling using the Left and Right Soft Key

    Hi guys,
    Good day!
    I need your help with regards to using scroll wherein my control is the right or
    left soft key
    I want to implement those like in calendar wherein year can navigate using right or left soft key like this
    Display:
    *< 2008 >*
    if i pressed left would display - 2007
    if i pressed right would display- 2009
    Please help! Thanks in Advance.
    Regards,
    Psyeu

    Err.. keyCodes for the softkeys are non-standard. In fact, all devices don't have softkeys ... one example is Motorola E6.
    From the documentation for Canvas:
    MIDP defines the following key codes: KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_STAR, and KEY_POUND. (These key codes correspond to keys on a ITU-T standard telephone keypad.) Other keys may be present on the keyboard, and they will generally have key codes distinct from those list above. In order to guarantee portability, applications should use only the standard key codes.
    db

  • Can I use the left or right convenience buttons to switch my ringer to vibrate only?

    Trying to figure out how to switch my ringer to vibrate (with no ringing) only easier than going into the phone menu, any ideas?

    On some of the Operating System verisons, for the Pearl, you can press the # key to switch between vibrate and your normal profile.
    If you have a custom profile set, it will toggle between vibrate and the custom profile.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Why can't I use the left/right arrow keys to go to the next page or back a page?

    When reading manga, I used to be able to go to the next page or go back a page using the left and right arrow keys. Doesn't work anymore, how can I fix that?

    Such a feature can only be added by an extension.
    Maybe:
    *NextPlease!: https://addons.mozilla.org/firefox/addon/nextplease/

  • OutOfMemory Exceptions on Servlets, Try-Catch unable to help

    Hi, I'm playing with Java servlets right now and I seem to be getting some OutOfMemory errors. The weird thing is that even though I had identify the souce of error and tried to enclose it with a try-catch, the exception still occurs. Why is that so?

    OutOfMemoryError is actually a java.lang.Error, not a RuntimeException. So if you use a try/catch like this
    try {
      // stuff
    } catch (Exception e) {..}Errors will fall through, since Error is not a subtype of Exception. (Check the API.)
    You can catch it by catching Error or Throwable, like this:
    try {
      // stuff
    } catch (Error e) { //  this is rarely a good idea
    }But you normally wouldn't want to do this. When there's no memory left, there's not a whole lot you can do about it, and most of the code you might want to put inside the catch block will merely throw another OutOfMemoryError.
    As voronetskyy said, you're either creating too many (or too large) objects (typically in an endless loop), or you have specified too little memory for your application.

  • Can't find class because of try catch block ?!

    Hello,
    I'm using the JNI to use a java library from my c++ code.
    JNI can't find the "Comverse10" class below, but when i put the try catch block in createMessage in comment, FindClass succeeds ?!
    Unfortunatly i need the code inside the try block ;-)
    I tried a few things, but none of them worked:
    - let createMessage throw the exception (public void createMessage throws ElementAlreadyExistsException ), so there isn't a try catch block in createMessage => result: the same
    - make a "wrapper" class Comverse that has a Comverse10 object as attribute and just calls the corresponding Comverse10.function. Result: Comvers could be found, but not constructed (NewObject failed).
    Can someone tell me what is going on ?!
    Thank you,
    Pieter.
    //Comverse10 class
    public class Comverse10 {
    MultimediaMessage message;
    /** Creates a new instance of Comverse10 */
    public Comverse10() {
    public void createMessage() {
    TextMediaElement text1 = new TextMediaElement("Pieter");
    text1.setColor(Color.blue);
    SimpleSlide slide1 = new SimpleSlide();
    //if i put this try catch block in comment, it works ?!
    try{
    slide1.add(text1);
    catch(com.comverse.mms.mmspade.api.ElementAlreadyExistsException e){}
    MessageContent content = new MessageContent();
    content.addSlide(slide1);
    this.message = new MultimediaMessage();
    message.setContent(content);
    message.setSubject("Mijn subjectje");
    for those of you who are intersted: here's my C++ code:
    //creation of JVM
    HRESULT Java::CreateJavaVMdll()
         HRESULT HRv = S_OK;
    char classpath[1024];
         jint res;
         if(blog)     this->oDebugLog->Printf("CreateJavaVMdll()");
         strcpy(classpath,"-Djava.class.path="); /*This tells jvm that it is getting the class path*/
         strcat(classpath,getenv("PATH"));
         strcat(classpath,";D:\\Projects\\RingRing\\MMSComposer;C:\\Progra~1\\j2sdk1~1.1_0\\lib");     //;C:\\Comverse\\MMS_SDK\\SDK\\lib\\mail.jar;C:\\Comverse\\MMS_SDK\\SDK\\lib\\activation.jar;C:\\Comverse\\MMS_SDK\\SDK\\lib\\mmspade.jar
         //------Set Options for virtual machine
         options[0].optionString = "-Djava.compiler=NONE"; //JIT compiler
         options[1].optionString = classpath;                                        //CLASSPATH
         //------Set argument structure components
         vm_args.options = options;
         vm_args.nOptions = 2;
         vm_args.ignoreUnrecognized = JNI_TRUE;
         vm_args.version = JNI_VERSION_1_4;
         /* Win32 version */
         HINSTANCE hVM = LoadLibrary("C:\\Program Files\\j2sdk1.4.1_01\\jre\\bin\\client\\jvm.dll");
         if (hVM == NULL){
              if(blog) oDebugLog->Printf("Can't load jvm.dll");
              return E_FAIL;
         if(blog) oDebugLog->Printf("jvm.dll loaded\n");
         LPFNDLLFUNC1 func = (LPFNDLLFUNC1)GetProcAddress(hVM, "JNI_CreateJavaVM");
         if(!func){
              if(blog)     oDebugLog->Printf("Can't get ProcAddress of JNI_CreateJavaVM");
              FreeLibrary(hVM);     hVM = NULL;
              return E_FAIL;
         if(blog)     oDebugLog->Printf("ProcAddress found");
         res = func(&jvm,(void**)&env,&vm_args);
         if (res < 0) {
    if(blog)     oDebugLog->Printf("Can't create JVM with JNI_CreateJavaVM %d\n",res);
    return E_FAIL;
         if(blog)     oDebugLog->Printf("JVM created");
         return HRv;
    //finding Comverse10 class:
    HRESULT CALLAS MMSComposer::InitializeJNI(void)
         HRESULT HRv=E_FAIL;
         DWORD T=0;
         try
              if(blog)     oDebugLog->Printf("\nInitializeJNI()");
              bJVM = FALSE;
              jni = new Java(oDebugLog);
              if(jni->CreateJavaVMdll()!=S_OK){
                   if(blog)     oDebugLog->Printf("CreateJavaVMdll() failed");     
                   return HRv;
              jclass jcls = jni->env->FindClass("Comverse10");
              if (jcls == 0) {
    if(blog)     oDebugLog->Printf("Can't find Comverse10 class");
                   jclass jcls2 = jni->env->FindClass("test");
                   if (jcls2 == 0) {
                        if(blog)     oDebugLog->Printf("Can't find test class");
                        return HRv;
                   if(blog)     oDebugLog->Printf("test class found %08x",jcls2);
    return HRv;
              if(blog)     oDebugLog->Printf("Comverse10 class found %08x",jcls);
              jmethodID mid = jni->env->GetMethodID(jcls , "<init>", "()V");
              if (mid == 0) {
                   if(blog)     oDebugLog->Printf("Can't find Comverse10() constructor");
    return HRv;
              if(blog)     oDebugLog->Printf("Comverse10() constructor found");
              jobject jobj = jni->env->NewObject(jcls,mid);
              if(jobj==0)
                   if(blog)     oDebugLog->Printf("Can't construct a Comverse10 object");
    return HRv;
              if(blog)     oDebugLog->Printf("Comverse10 object constucted");
              //Create Global reference, so java garbage collector won't delete it
              jni->jobj_comv = jni->env->NewGlobalRef(jobj);
              if(jni->jobj_comv==0)
                   if(blog)     oDebugLog->Printf("Can't create global reference to Comverse10 object");
    return HRv;
              if(blog)     oDebugLog->Printf("global reference to Comverse10 object %08x created",jni->jobj_comv);
              bJVM=TRUE;
              HRv=S_OK;
         }     catch( IDB * bgError ) { throw bgError->ErrorTrace("InitializeJNI::~InitializeJNI",HRv, 0, T); }
              catch(...) { throw IDB::NewErrorTrace("InitializeJNI::~InitializeJNI",HRv, 0, T ); }
              return HRv;

    >
    I would guess that the real problem is that that the
    exception you are catching is not in the class path
    that you are defining.Thanks jschell, that was indeed the case.
    I don't have the docs, but I would guess that
    FindClass() only returns null if an exception is
    thrown. And you are not checking for the exception.
    Which would tell you the problem.Ok, i'll remember that. But what with exceptions thrown in my java code, the documents say
    // jthrowable ExceptionOccurred(JNIEnv *env);
    // Determines if an exception is being thrown. The exception stays being thrown until either the native code calls ExceptionClear(), or the Java code handles the exception
    so, what if the java code throws an exception and catches it, will i be able to see that in my c++ code with ExceptionOccurred ?
    or
    should the java method be declared to throw the exception (and not catch it inside the method)
    Again, thank you for your help, it's greatly appreciated !

  • Exception handling with try/catch in acrobat

    Hi
    I have a problem using a try/catch block in my acrobat document-script. Try to enter the following into the debugger-console:
    try{nonexistentFunction();}catch(e){console.println('\nacrobat can't catch')}
    and run it. The output will be:
    nonexistentFunction is not defined
    1:Console:Exec
    acrobat can't catch
    true
    The whole point of a rty/catch block is for the application  NOT to throw an exception, but instead execute the catch-part of the  statement. However, acrobat does both: It throws an exception AND  executes the catch-block.
    Is there another way to suppress the exception, or to make the try/catch-block work as it's supposed to?

    > Also Adobe provides for free the JS or compiled file for Acrobat Reader to support the JS console.
    Where is that file located ? How to install it or where to place it ?
    What is the method referred by try67 on his site where he sells a product ?
    Is that the same as the compiled file you refer to ? or did he sell his solution to adobe ?
    It is helpful if people can get an idea of the nature of choices available and make informed decisions, than a cloak and dagger approach.
    For some jobs that we have, I have been very frustrated by a consultant who wont even give basic info for transparent billing despite all assurances for privacy, as a result we are forced to do the job ourselves.
    Dying Vet

  • Return statement and Try Catch problem

    Hi!!
    I've got the next code:
    public ResultSet DBSelectTeam(String query) {
    try {
    Statement s = con.createStatement();
    ResultSet rs = s.executeQuery(query);
    return rs;
    } catch (Exception err) {
    JOptionPane.showMessageDialog(null, "ERROR: " + err);
    But I need a return statement in the catch-block, but I don't know what's the best option.
    Help...
    Many thanks.

    The error message is: "missing return statement", Yes, I know.
    You have to either return from the catch statement, or throw from the catch statement, or return or throw after the catch statement.
    The only ways your method is allowed to complete is by returning a value or throwing an exception. As it stands, if an exception is thrown, you catch it, but then you don't throw anything and you don't return a value.
    So, like I said: What would you return from within or after catch? There's no good value to return. The only remotely reasonable choice would be null, but that sucks because now the caller has to explicitly check for it.
    So we conclude that catch shouldn't return anything. So catch must throw something. But what? You could wrap the SQLE in your own exception, but since the caller is dealing with JDBC constructs anyway (he has to handle the RS and close it and the Statement), there's no point in abstracting JDBC away. Plus he has to deal with SQLE anyway in his use of the RS and Statement. So you might as well just throw SQLE.
    So since you're going to just throw SQLE anyway, just get rid of the try/catch altogether and declare your method throws SQLException

  • Problem with a Try/catch exception

    Hello everyone here on the forums. I'm brand new to Java and have a bit of a problem with a try catch statement I'm making. In the following code if a user enters a non-integer number the program will display "Sorry, incompatible data." Problem is it gets caught in a loop and continues to display "Sorry, incompatible data." My aim with the try catch was if the user is not quite smart enough to understand quadratic programs don't use symbols and characters it would state it isn't correct and continue running the program.
    Heres my code thus far:
    package finishedquadraticprogram;
    import java.util.*;
    * @author Matt
    public class quad {
         * @param args the command line arguments
        public static void main(String[] args) {
            boolean verification = true;
            double a, b, c, root1, root2, discriminant;
            Scanner keyInput = new Scanner(System.in);
            while ( verification)
            try
            System.out.println("a: ");
            a = keyInput.nextDouble();
            System.out.println("b: ");
            b = keyInput.nextDouble();
            System.out.println("c: ");
            c = keyInput.nextDouble();
            discriminant = Math.sqrt(b * b - 4 * a * c);
            root1 = (-b + discriminant) / 2 * a;
            root2 = (-b - discriminant) / 2 * a;
            verification = false;
            System.out.println("Root 1 = " +root1+ "\nRoot 2 = " +root2);
            } //try
            catch  (InputMismatchException iMe)
              System.out.println( "Sorry. incompatible data." );  
    }I'm pretty sure the problem is something to do with the keyboard buffer, but I'm not sure what I need to do to either reset it or clear it, whichever one works. (Oh, and how would I go about making the program use complex numbers? I realize Java can't use complex numbers and will just display NaN ... any ideas how to make this work?)
    Thanks a lot for all of your help guys, it's appreciated.

    this is better:
    package finishedquadraticprogram;
    import java.util.*;
    /** @author Matt */
    public class quad
       private static final double TOLERANCE = 1.0e-9;
       /** @param args the command line arguments */
       public static void main(String[] args)
          boolean verification = true;
          double a, b, c, root1, root2, discriminant;
          Scanner keyInput = new Scanner(System.in);
          while (verification)
             try
                System.out.println("a: ");
                a = keyInput.nextDouble();
                System.out.println("b: ");
                b = keyInput.nextDouble();
                System.out.println("c: ");
                c = keyInput.nextDouble();
                discriminant = Math.sqrt(b * b - 4 * a * c);
                if (Math.abs(a) < TOLERANCE)
                   root1 = 0.0;
                   root2 = -c/b;
                else
                   root1 = (-b + discriminant) / (2 * a);
                   root2 = (-b - discriminant) / (2 * a);
                verification = false;
                System.out.println("Root 1 = " + root1 + "\nRoot 2 = " + root2);
             } //try
             catch (InputMismatchException iMe)
                System.out.println("Sorry. incompatible data.");
                keyInput.next();
    }

  • ExtendScript try/catch difference when script ran from ESTK and Illustrator

    Hello,
    I've written an ExtendScript for Illustrator using the ExtendScript ToolKit (ESTK).  This scripts works really well when running it in Illustrator from the ESTK (using the target application functionality).
    However when I run it directly within Illustrator (by selecting it from the dropdown File > Scripts) I get a run time error.  Is this normal?  Should I expect differences when running the script in these two different ways?
    The error is in this function...
    ```
    function itemUsable (arr, item) {
        var usable = true;
        try {
            arr[item];
            usable = true;
        } catch(e) {
            $.global.alert(e);
            usable = false;
        return usable;
    ```
    The point of the code is to get around Illustrator's issue of throwing errors when accessing properties that don't always exist.  Ran from ESTK the try/catch statement catches the error "No such element" and then sets the function to return false.
    When ran directly from Illustrator the error message fires but the try/catch doesn't seem to stop the script from exiting.
    The only difference I can see is when running the script from ESTK the dropdown menu next to the application target dropdown is always (and has only the option) "main".  Running the script directly from Illustrator, when the error is thrown this dropdown option is set to the value "transient".
    See this screenshot for an example what I mean
    Any help would be much appreciated.
    Thanks,
    /t

    Thanks Trevor.
    So it turns out that a script executed in Illustrator from ExtendScript has a different debug mode compared to a script that is opened directly by Illustrator.  Useful to know.

Maybe you are looking for

  • Can't remove Criteria box under find - Mavericks, CC

    I am trying to organize a large number of files using Bridge and keywords. it was working just fine when I would right click on a keyword and find that way. I typed a search term in the search box in the top right corner. Now when I right click a key

  • Ghost files (removing itunes?)

    Hi, I have shifted my music collection back and forth from a number of macs, and my library is all sorts of screwed up. I am curently using an old powerbook with a firewire hard drive which is storing my music. I had run itunes on this laptop in the

  • Cant connect iphone 4 to netgear router

    I am unable to connect my 2 new iphones to our Netgear Router. Even when I have NONE selected under wireless options on Netgear router it will still not let me join. I have a Netgear N300 Wireless ADSL2 + Modem Router DGN2200 I spent 90 mins on the p

  • Load balancing for Business Package iviews

    Hello Gurus,    we have installed SRM Business packages on our Portal system and accessing the SRM which has 2 application servers.How can we make the iviews to access any one of the application server as the link to ITS in iviews is static.What is t

  • Safari on ipad2 is not connecting to the internet, how can i make it work?

    since over 48 hours my safari on ipad2 has stopped connecting to the internet, lathough my pc does connect readily. I have tried clearing ipad2 of cookies and data an dhistory, switched off and restarted both ipad2 and modem, but with no results. can