Sign in to follow this  
Followers 0
strate

Program just shuts down on its own

3 posts in this topic

Below is a part of my program. The first section of code is activated after the user clicks a "Print" button. The problem is when there are a large number of full pallets and the second set of code has to loop many times it will close itself down. If it has to loop only a couple times it will operate fine. I imagine if I was to change the way the "FileWriteLine" parts of the program worked it would be better and might fix my problems any other ideas?

Func ChoosePrintSet()
   Select
      Case $Label_Total = 1
         printset1()
      Case $Label_Total = 16
         printset4()
      Case $Label_Total = 256
         printset2()
      Case $Label_Total = 257
         printset3()
      Case $Label_Total = 272
         printset5()
      Case $Label_Total = 4096
         printset6()
      Case $Label_Total = 4097
         printset14()
      Case $Label_Total = 4112
         printset13()
      Case $Label_Total = 4352
         printset15()
      Case $Label_Total = 4353
         printset8()
      Case $Label_Total = 4368
         printset7()
      Case $Label_Total = 65536
         printset11()
      Case $Label_Total = 65537
         printset16()
      Case $Label_Total = 65552
         printset17()
      Case $Label_Total = 65792
         printset12()
      Case $Label_Total = 65793
         printset9()
      Case $Label_Total = 65808
         printset10()
   EndSelect
   Sleep(1000)
   FileCopy($Current_Print_Job_TXT, $Print_Job_Transfer_Name)
   FileDelete($Current_Print_Job_TXT)
EndFunc  ;==>ChoosePrintSet

Func printset5()
   For $CYCLES = 1 To $FULL_PALLETS
      Audit_Tag()
      NON_GM_Shipping_Labels()
      Sleep($Print_Pause)
   Next
   If $PARTIAL <> 0 Then
      $CYCLES = $CYCLES + 1
      Partial_Audit_Tag()
      $PER_Data = $PARTIAL
      NON_GM_Shipping_Labels()
   EndIf
EndFunc  ;==>printset5

Func Audit_Tag()
   FileWriteLine($Current_Print_Job_TXT, 'LABELNAME = "' & $Audit_Tag_Path & $Audit_Tag_Label_Name & '"')
   FileWriteLine($Current_Print_Job_TXT, 'Printer = "' & $AUDIT_TAG_PRINTER & '"')
   FileWriteLine($Current_Print_Job_TXT, 'SO = ' & '"' & $SO_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'Cust = ' & '"' & $CUST_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'text16 = ' & '"' & $TRW_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'Desc = ' & '"' & $DESC_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'Due = ' & '"' & $DUE_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'QOP = ' & '"' & $PER_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'QTY = ' & '"' & $QTY_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'PER = ' & '"' & $PER_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'Partial = ' & '"' & $PARTIAL & '"')
   FileWriteLine($Current_Print_Job_TXT, 'FP = ' & '"' & $FULL_PALLETS & '"')
   FileWriteLine($Current_Print_Job_TXT, 'LABELQUANTITY =1')
   FileWriteLine($Current_Print_Job_TXT, ' ')
EndFunc  ;==>Audit_Tag
Func Partial_Audit_Tag()
   FileWriteLine($Current_Print_Job_TXT, 'LABELNAME = "' & $Audit_Tag_Path & $Audit_Tag_Label_Name & '"')
   FileWriteLine($Current_Print_Job_TXT, 'Printer = "' & $AUDIT_TAG_PRINTER & '"')
   FileWriteLine($Current_Print_Job_TXT, 'SO = ' & '"' & $SO_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'Cust = ' & '"' & $CUST_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'text16 = ' & '"' & $TRW_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'Desc = ' & '"' & $DESC_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'Due = ' & '"' & $DUE_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'QOP = ' & '"' & $PARTIAL & '"')
   FileWriteLine($Current_Print_Job_TXT, 'QTY = ' & '"' & $QTY_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'PER = ' & '"' & $PER_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'Partial = ' & '"' & $PARTIAL & '"')
   FileWriteLine($Current_Print_Job_TXT, 'FP = ' & '"' & $FULL_PALLETS & '"')
   FileWriteLine($Current_Print_Job_TXT, 'LABELQUANTITY =1')
   FileWriteLine($Current_Print_Job_TXT, ' ')
EndFunc  ;==>Partial_Audit_Tag
Func NON_GM_Shipping_Labels()
   FileWriteLine($Current_Print_Job_TXT, 'LABELNAME = "' & $Address_Labels_Path & $Non_GM_Address_Label_Name & '"')
   FileWriteLine($Current_Print_Job_TXT, 'Printer = "' & $ADDRESS_LABELS_PRINTER & '"')
   FileWriteLine($Current_Print_Job_TXT, 'Text19 = ' & '"' & $SO_Data & '"')
   $PREVIOUS_NUMBER = IniRead($GUI_Label_Entry_INI, "Serial Number", "Serial", "ERROR")
   If $PREVIOUS_NUMBER >= 99999995 Then
      MsgBox(0, "NOTICE", 'Address label "Serial Alpha" needs changed.')
      IniWrite($GUI_Label_Entry_INI, "Serial Number", "Serial", "1")
      $PREVIOUS_NUMBER = IniRead($GUI_Label_Entry_INI, "Serial Number", "Serial", "ERROR")
   EndIf
   $SERIAL_NUMBER = $PREVIOUS_NUMBER + 1
   Serial_Num_LEN()
   IniWrite($GUI_Label_Entry_INI, "Serial Number", "Serial", $SERIAL_NUMBER)
   FileWriteLine($Current_Print_Job_TXT, 'Serial = ' & '"' & $SERIAL_NUMBER & '"')
   FileWriteLine($Current_Print_Job_TXT, 'Part = ' & '"' & $CUST_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'kit = ' & '"' & $TRW_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'text14 = ' & '"' & $DESC_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'QTY = ' & '"' & $PER_Data & '"')
   FileWriteLine($Current_Print_Job_TXT, 'LABELQUANTITY =1')
EndFunc  ;==>NON_GM_Shipping_Labels

INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites



Would this way be faster, less CPU, better than the way I have it currently:

FileWriteLine($Current_Print_Job_TXT, 'LABELNAME = "' & $Audit_Tag_Path & $Audit_Tag_Label_Name & '"'&@CR&'Printer = "' & $AUDIT_TAG_PRINTER & '"')


INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites

I have changed all of the functions to use the least number of FileWriteLines:

Func Audit_Tag()
   FileWriteLine($Current_Print_Job_TXT, 'LABELNAME = "' & $Audit_Tag_Path & $Audit_Tag_Label_Name & '"'&@CRLF&'Printer = "' & $AUDIT_TAG_PRINTER & '"'&@CRLF&'SO = ' & '"' & $SO_Data & '"'&@CRLF&'Cust = ' & '"' & $CUST_Data & '"'&@CRLF&'text16 = ' & '"' & $TRW_Data & '"'&@CRLF&'Desc = ' & '"' & $DESC_Data & '"'&@CRLF&'Due = ' & '"' & $DUE_Data & '"'&@CRLF&'QOP = ' & '"' & $PER_Data & '"'&@CRLF&'QTY = ' & '"' & $QTY_Data & '"'&@CRLF&'PER = ' & '"' & $PER_Data & '"'&@CRLF&'Partial = ' & '"' & $PARTIAL & '"'&@CRLF&'FP = ' & '"' & $FULL_PALLETS & '"'&@CRLF&'LABELQUANTITY =1')
EndFunc  ;==>Audit_Tag
Func NON_GM_Shipping_Labels()
   FileWriteLine($Current_Print_Job_TXT, 'LABELNAME = "' & $Address_Labels_Path & $Non_GM_Address_Label_Name & '"'&@CRLF&'Printer = "' & $ADDRESS_LABELS_PRINTER & '"'&@CRLF&'Text19 = ' & '"' & $SO_Data & '"')
   $PREVIOUS_NUMBER = IniRead($GUI_Label_Entry_INI, "Serial Number", "Serial", "ERROR")
   If $PREVIOUS_NUMBER >= 99999995 Then
      MsgBox(0, "NOTICE", 'Address label "Serial Alpha" needs changed.')
      IniWrite($GUI_Label_Entry_INI, "Serial Number", "Serial", "1")
      $PREVIOUS_NUMBER = IniRead($GUI_Label_Entry_INI, "Serial Number", "Serial", "ERROR")
   EndIf
   $SERIAL_NUMBER = $PREVIOUS_NUMBER + 1
   Serial_Num_LEN()
   IniWrite($GUI_Label_Entry_INI, "Serial Number", "Serial", $SERIAL_NUMBER)
   FileWriteLine($Current_Print_Job_TXT, 'Serial = ' & '"' & $SERIAL_NUMBER & '"'&@CRLF&'Part = ' & '"' & $CUST_Data & '"'&@CRLF&'kit = ' & '"' & $TRW_Data & '"'&@CRLF&'text14 = ' & '"' & $DESC_Data & '"'&@CRLF&'QTY = ' & '"' & $PER_Data & '"'&@CRLF&'LABELQUANTITY =1')
EndFunc  ;==>NON_GM_Shipping_Labels
The program still shuts itself down. This is unreliable as one might expect and I would like some thoughts about.

INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0