• Resolved hheyhey568

    (@hheyhey568)


    I have working “do while” loop. However the moment I erase one of its input field value, the whole calculation as well as page stop responding. I feel that it is due to loop not able to work or something else which I don’t know.

    Can we stop this happening by assigning some minimum value to the inputs or can we handle this error without killing the page/ calculation ?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @hheyhey568

    I don’t know the equation you have implemented, but if the page stop responding, this means your “do/while” loop becomes infinite, there is not a condition that stops it.

    Depending on your equation, probably the solution would be include the loop into a conditional statement, to evaluate the loop only if it is satisfied a previous condition.

    If you need additional support about this issue, you should provide the code of the equation, and what is the field that causes the infinite loop.

    Best regards.

    Thread Starter hheyhey568

    (@hheyhey568)

    Following is the equation : The moment I erase the fieldname2 or fieldname5 or fieldname10 , the page and calculation both stops responding.

    (function(){
    var idm=fieldname2*25.4/1000;
    var rgm=fieldname5/1000;
    var f=0.001,lhs,rhs;

    do{
    lhs=1/sqrt(f);
    rhs=-2*LOGAB(rgm/(3.7*idm)+2.51/(fieldname10*sqrt(f)),10);
    f=f+0.0001;
    }while(ABS(lhs-rhs)>0.1)

    return PREC(f,5);

    })();

    • This reply was modified 4 years, 10 months ago by hheyhey568.
    Plugin Author codepeople

    (@codepeople)

    Hello @hheyhey568

    As I told you in another thread, the plugin allows you to implement the equations, but it cannot solve the mathematic issues generated by your implementation of the equations.

    If you have as condition: ABS(lhs-rhs)>0.1

    and the difference ABS(lhs-rhs) grows the loop will never stop. Note the ABS –
    Absolute value, returns always a positive number.

    Which are the numbers for fieldname2, fieldname5, and fieldname10 that makes the difference grow? This is the question you should to answer, and include a conditional statement that contains the loop:

    
    (function(){
        if( /* The new condition here */)
        {
            var idm=fieldname2*25.4/1000;
            var rgm=fieldname5/1000;
            var f=0.001,lhs,rhs;
    
            do{
                lhs=1/sqrt(f);
                rhs=-2*LOGAB(rgm/(3.7*idm)+2.51/(fieldname10*sqrt(f)),10);
                f=f+0.0001;
            }while(ABS(lhs-rhs)>0.1)
    
            return PREC(f,5);
        }
    })();
    

    Best regards.

    Thread Starter hheyhey568

    (@hheyhey568)

    The issue is to handle the error when some one either delete or make the Fieldname2, fieldname5, and fieldname10 zero as an input.

    So is there a way where we can stop the user from deleting the input value which is predefined and also stop them make these fieldnames zero..so that do while loop always has some value to work with ?

    OR

    Can we have condition which bypass do while loop when some one delete or enter Zero to these fieldnames?

    Plugin Author codepeople

    (@codepeople)

    Hello @hheyhey568

    Yes of course:

    
    (function(){
        if(AND(fieldname2, fieldname5, fieldname10))
        {
            var idm=fieldname2*25.4/1000;
            var rgm=fieldname5/1000;
            var f=0.001,lhs,rhs;
    
            do{
                lhs=1/sqrt(f);
                rhs=-2*LOGAB(rgm/(3.7*idm)+2.51/(fieldname10*sqrt(f)),10);
                f=f+0.0001;
            }while(ABS(lhs-rhs)>0.1)
    
            return PREC(f,5);
        }
    })();
    

    Best regards.

    Thread Starter hheyhey568

    (@hheyhey568)

    Great. It worked perfectly. Thanks a lot

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘do while Loop kills the page’ is closed to new replies.