locked
Nested IF issue RRS feed

  • Question

  • Hi everyone,

    I have a little bit of a problem with a nested IF statement within a program I have been working on. Some data is passed to a subroutine that calls this nested IF statement.

    When the data contains the word "Reports" it then runs the nested IF statement if it can't find any other word located it just run the ELSE but it doesn't. If it was to find another word it would work find and call ELSE if something else doesn't match up. This issue seems to only be an issue with "Reports".

    Here is the IF statement I have removed all other code and restructured for easy reading.

    If Text.IsSubText(TicketDetails[i], "Synapse") And Text.IsSubText(TicketDetails[i], "CP FLS") Then
    	
    	If Text.IsSubText(TicketDetails[i], "Reports") Then
          		
    		If Text.IsSubText(TicketDetails[i], "Resend Request") Then
          		ElseIf Text.IsSubText(TicketDetails[i], "Change Conditional Recipient") Then
          		ElseIf Text.IsSubText(TicketDetails[i], "Change Unconditional Recipient") Then
         		EndIf
        
    	ElseIf Text.IsSubText(TicketDetails[i], "Data Change Request") Then
        	ElseIf Text.IsSubText(TicketDetails[i], "Medication management") Then
          	
    		If Text.IsSubText(TicketDetails[i], "Consignment Tracking Enquiry") then
    		ElseIf Text.IsSubText(TicketDetails[i], "Consignment Enquiry") Then
           		EndIf
        
    	ElseIf Text.IsSubText(TicketDetails[i], "Documentation Request") Then
     
      	ElseIf Text.IsSubText(TicketDetails[i], "Configuration") Then
          
    		If Text.IsSubText(TicketDetails[i], "Close Service") Then
          		ElseIf Text.IsSubText(TicketDetails[i], "Close Project") Then
    		EndIf
        	ElseIf Text.IsSubText(TicketDetails[i], "SUL - Single User Logon") Then
          
    		If Text.IsSubText(TicketDetails[i], "Close Service") Then
    		ElseIf Text.IsSubText(TicketDetails[i], "Using Functionality") Then
    		ElseIF Text.IsSubText(TicketDetails[i], "Access") Then
    		EndIf
    	ElseIf Text.IsSubText(TicketDetails[i], "Access") Then
          
    		If Text.IsSubText(TicketDetails[i], "Close Service") Then
    		ElseIf Text.IsSubText(TicketDetails[i], "Using Functionality") Then
     		ElseIf Text.IsSubText(TicketDetails[i], "Envelope Request") Then
    		EndIF
        
    	ElseIf Text.IsSubText(TicketDetails[i], "Alerts") Then
    	Else
    	'THIS ELSE IS NOT WORKING
        	EndIf
    Else
    EndIF

    Thursday, August 30, 2012 9:06 AM

Answers

  • Your code looks OK, this works:

    TicketDetails[1] = "Synapse CP FLS Something Else"
    i = 1
    If Text.IsSubText(TicketDetails[i], "Synapse") And Text.IsSubText(TicketDetails[i], "CP FLS") Then
      
      If Text.IsSubText(TicketDetails[i], "Reports") Then
        
        If Text.IsSubText(TicketDetails[i], "Resend Request") Then
        ElseIf Text.IsSubText(TicketDetails[i], "Change Conditional Recipient") Then
        ElseIf Text.IsSubText(TicketDetails[i], "Change Unconditional Recipient") Then
        EndIf
        
      ElseIf Text.IsSubText(TicketDetails[i], "Data Change Request") Then
      ElseIf Text.IsSubText(TicketDetails[i], "Medication management") Then
        
        If Text.IsSubText(TicketDetails[i], "Consignment Tracking Enquiry") then
        ElseIf Text.IsSubText(TicketDetails[i], "Consignment Enquiry") Then
        EndIf
        
      ElseIf Text.IsSubText(TicketDetails[i], "Documentation Request") Then
        
      ElseIf Text.IsSubText(TicketDetails[i], "Configuration") Then
        
        If Text.IsSubText(TicketDetails[i], "Close Service") Then
        ElseIf Text.IsSubText(TicketDetails[i], "Close Project") Then
        EndIf
      ElseIf Text.IsSubText(TicketDetails[i], "SUL - Single User Logon") Then
        
        If Text.IsSubText(TicketDetails[i], "Close Service") Then
        ElseIf Text.IsSubText(TicketDetails[i], "Using Functionality") Then
        ElseIF Text.IsSubText(TicketDetails[i], "Access") Then
        EndIf
      ElseIf Text.IsSubText(TicketDetails[i], "Access") Then
        
        If Text.IsSubText(TicketDetails[i], "Close Service") Then
        ElseIf Text.IsSubText(TicketDetails[i], "Using Functionality") Then
        ElseIf Text.IsSubText(TicketDetails[i], "Envelope Request") Then
        EndIF
        
      ElseIf Text.IsSubText(TicketDetails[i], "Alerts") Then
      Else
        TextWindow.WriteLine("HERE")
        'THIS ELSE IS NOT WORKING
      EndIf
    Else
    EndIF

    • Marked as answer by kirk_kaf Thursday, August 30, 2012 2:14 PM
    Thursday, August 30, 2012 11:49 AM

All replies

  • Your code looks OK, this works:

    TicketDetails[1] = "Synapse CP FLS Something Else"
    i = 1
    If Text.IsSubText(TicketDetails[i], "Synapse") And Text.IsSubText(TicketDetails[i], "CP FLS") Then
      
      If Text.IsSubText(TicketDetails[i], "Reports") Then
        
        If Text.IsSubText(TicketDetails[i], "Resend Request") Then
        ElseIf Text.IsSubText(TicketDetails[i], "Change Conditional Recipient") Then
        ElseIf Text.IsSubText(TicketDetails[i], "Change Unconditional Recipient") Then
        EndIf
        
      ElseIf Text.IsSubText(TicketDetails[i], "Data Change Request") Then
      ElseIf Text.IsSubText(TicketDetails[i], "Medication management") Then
        
        If Text.IsSubText(TicketDetails[i], "Consignment Tracking Enquiry") then
        ElseIf Text.IsSubText(TicketDetails[i], "Consignment Enquiry") Then
        EndIf
        
      ElseIf Text.IsSubText(TicketDetails[i], "Documentation Request") Then
        
      ElseIf Text.IsSubText(TicketDetails[i], "Configuration") Then
        
        If Text.IsSubText(TicketDetails[i], "Close Service") Then
        ElseIf Text.IsSubText(TicketDetails[i], "Close Project") Then
        EndIf
      ElseIf Text.IsSubText(TicketDetails[i], "SUL - Single User Logon") Then
        
        If Text.IsSubText(TicketDetails[i], "Close Service") Then
        ElseIf Text.IsSubText(TicketDetails[i], "Using Functionality") Then
        ElseIF Text.IsSubText(TicketDetails[i], "Access") Then
        EndIf
      ElseIf Text.IsSubText(TicketDetails[i], "Access") Then
        
        If Text.IsSubText(TicketDetails[i], "Close Service") Then
        ElseIf Text.IsSubText(TicketDetails[i], "Using Functionality") Then
        ElseIf Text.IsSubText(TicketDetails[i], "Envelope Request") Then
        EndIF
        
      ElseIf Text.IsSubText(TicketDetails[i], "Alerts") Then
      Else
        TextWindow.WriteLine("HERE")
        'THIS ELSE IS NOT WORKING
      EndIf
    Else
    EndIF

    • Marked as answer by kirk_kaf Thursday, August 30, 2012 2:14 PM
    Thursday, August 30, 2012 11:49 AM
  • Thanks for testing Litdev, I had the logic setup wrong for how I needed this to work.
    Thursday, August 30, 2012 2:14 PM