3.2.3 MAIN

The MAIN section contains the codes for installing software automatically. In this section, you can use all statements other than data type declarations.

You can also code this section to notify the agent of the return code for the result of installation.

Organization of this subsection
(1) Example of coding

(1) Example of coding

MAIN
{
   AIT_SetDefaultWaitTimeout(1.0);
   AIT_DMPSTRC();
   DM_RTN = NG_END;
   AIT_InitLog(InstallerName);
   bRtn= AIT_Exec(InstallerName,SW_SHOWNORMAL);
   if(bRtn == false)
       iErrorNo = AIT_GetLastError();
       strErrorTxt = AIT_GetErrorText(iErrorNo);
       AIT_LogMessage(strErrorTxt);
       iLoopCount = iLoopMax;
   else
       AIT_LogMessage("Recorder File started");
   Endif;
   while(iLoopCount < iLoopMax)
       if(AIT_FocusWindow("check", "#32770") > 0)
           AIT_LogMessage("Window - Caption: check, Class Name: #32770");
           AIT_CtrlSetFocus("check box(&C)",CHECKBOX_CTRL);
           AIT_Sleep(SLEEP_TIME_EVENTS);
           AIT_LogMessage("AIT_CtrlSetFocus('"check box(&C)'",CHECKBOX_CTRL);");
           AIT_PlayKey("{ENTER}");
           AIT_Sleep(SLEEP_TIME_EVENTS);
           AIT_LogMessage("AIT_PlayKey('"{ENTER}'");");
           iLoopCount = iLoopMax;
           DM_RTN = OK_END;
           continue;
       Endif;
       iLoopCount = iLoopCount + 1;
       AIT_Sleep(SLEEP_TIME);
   loop;
   if(DM_RTN == OK_END)
       AIT_LogMessage("Recorder File ended normally");
   else
       AIT_LogMessage("Recorder File ended Abnormally");
   Endif;
   WINH = AIT_RegisterWindowMessage("ITM_REC_QUIT");
   if(WINH != 0)
       AIT_PostMessage(HWND_BROADCAST,WINH,DM_RTN,0);
   Endif;
}