Forum Discussion

royd's avatar
royd
Regular Contributor
8 years ago

Help needed with DDT script, error - "While is not defined"!

Hi every one,

 

Trying to create new patients from Excel sheet. It is not complaining about .xlsx  file (did some research and fixed it, I think). What I am getting now is "While is not defined"! I have no clue why?! Here is my script -

 

function ddtD(){

  try
    {
      DDT.ExcelDriver("c:\\newPatients.xlsx", "femaileE");

      
      While (!DDT.CurrentDriver.EOF())
	    {
	      if (DDT.CurrentDriver.Value("Name") == "Lizzie Hari")
	        {
	          New_Patients.createPatients();
	        } 
	      DDT.CurrentDriver.Next();
	    } 
    } 
    
    
    catch(exception)
    {
    Log.Error(exception.message);
    }

  DDT.CloseDriver(DDT.CurrentDriver.Name);
}

Appreciate any help from the pros.

 

Dave

  • Hi,

     

    It is pretty common mistake. While should be while

    I hope New_Patients is a Unit name. if not that will also say undefined.

     

    function ddtD(){
    
      try
        {
          DDT.ExcelDriver("c:\\newPatients.xlsx", "femaileE");
    
          
          while (!DDT.CurrentDriver.EOF())
    	    {
    	      if (DDT.CurrentDriver.Value("Name") == "Lizzie Hari")
    	        {
    	          New_Patients.createPatients();
    	        } 
    	      DDT.CurrentDriver.Next();
    	    } 
        } 
        
        
        catch(exception)
        {
        Log.Error(exception.message);
        }
    
      DDT.CloseDriver(DDT.CurrentDriver.Name);
    }

     ref:https://www.w3schools.com/js/js_loop_while.asp

  • shankar_r's avatar
    shankar_r
    Community Hero

    Hi,

     

    It is pretty common mistake. While should be while

    I hope New_Patients is a Unit name. if not that will also say undefined.

     

    function ddtD(){
    
      try
        {
          DDT.ExcelDriver("c:\\newPatients.xlsx", "femaileE");
    
          
          while (!DDT.CurrentDriver.EOF())
    	    {
    	      if (DDT.CurrentDriver.Value("Name") == "Lizzie Hari")
    	        {
    	          New_Patients.createPatients();
    	        } 
    	      DDT.CurrentDriver.Next();
    	    } 
        } 
        
        
        catch(exception)
        {
        Log.Error(exception.message);
        }
    
      DDT.CloseDriver(DDT.CurrentDriver.Name);
    }

     ref:https://www.w3schools.com/js/js_loop_while.asp

    • royd's avatar
      royd
      Regular Contributor

      Thank you Sankar!

       

      Wow, it has been a long day, I missed that! Thank you pointing out.

       

      Dave