7 Replies Latest reply on Oct 5, 2017 11:39 AM by Niko1024

    Cannot get script working (multiple conditions)

    Niko1024 Rookie

      Hi there,

       

      I kindly ask you for some help because I'm stuck on a script for a customer.

       

      My conditions work fine when alone, everytime I try to combine my conditions, i won't have any output when scanning (bulding the script returns no error).

      Do you have an idea of what I'm doing wrong please ?

       

      Device : MC92 CE, using TNCE v7.3.252

       

      Thank you,

      Nicolas

       

       

      Script( KE1_REC )

      String( sBarcode )

      String( NewString )

      Number( nBarcode )

      Activate( On_Input, sBarcode, nBarcode )

          Comment: :  If(Boolean_And( String_Equal( Get_Screen_Text( 1, 1 ), "KE1 REC", 7, FALSE ),String_Equal( Get_Screen_Text( 4, 1 ), "LPN:", 4, FALSE ),Number_Equal(nBarcode, Get_Scan_Type_Value("QR CODE"))))

         If( String_Equal( Get_Screen_Text( 1, 1 ), "KE1 REC", 7, FALSE ) )

          If( String_Equal( Get_Screen_Text( 4, 1 ), "LPN:", 4, FALSE ) )

           If( Number_Equal( nBarcode, Get_Scan_Type_Value( "QR CODE" ) ) )

              NewString = String_Middle( sBarcode, 2, 18 )

              Keypress_String( NewString )

              Keypress_Key( "VT100", "Enter" )

              NewString = String_Middle( sBarcode, 30, 6 )

              Keypress_String( NewString )

              Keypress_Key( "VT100", "Enter" )

              NewString = String_Middle( sBarcode, 38, 10 )

              Keypress_String( NewString )

              Keypress_Key( "VT100", "Enter" )

              NewString = String_Middle( sBarcode, 50, 5 )

              Keypress_String( NewString )

              Keypress_Key( "VT100", "Enter" )

      End_If

      End_If

          Else

              Scan_String( sBarcode, nBarcode )

          End_If

          Return

        • 1. Re: Cannot get script working (multiple conditions)
          nick.evans SupportEmployee

          Which product are you working with?

          This particular space tends to just get visibility for Community related website requests/questions. If you let me know which product you're working with, I can move this to the corresponding space so it gets some better visibility.

           

          Nick

          • 2. Re: Cannot get script working (multiple conditions)
            Niko1024 Rookie

            Hi Nick,

             

            Thank you for your reply.

             

            Here it is :

            Device : MC92 CE7, using TNCE v7.3.252

            • 5. Re: Cannot get script working (multiple conditions)
              Matt Dermody SSMMVPGroup

              I'm not sure if nested If statements work well in the scripting language or not. I know nested Switch Case statements have issues. I suggest moving your screen verification scripting into the Screen Reformatter and then assign that scan handling script to the particular screen.

               

              Move this into the Screen Verification section of the Screen Reformatter for that specific screen:

               

              • 6. Re: Cannot get script working (multiple conditions)
                Niko1024 Rookie

                Thanks Nick,

                I'm not used to the screen reformatter, so I'm not surprised it's not working...

                 

                I modified    Script

                Script( KE1_REC )

                String( sBarcode )

                String( NewString )

                Number( nBarcode )

                Activate( On_Input, sBarcode, nBarcode )

                If( Number_Equal( nBarcode, Get_Scan_Type_Value( "QR CODE" ) ) )

                        NewString = String_Middle( sBarcode, 2, 18 )

                        Keypress_String( NewString )

                        Keypress_Key( "VT100", "Enter" )

                        NewString = String_Middle( sBarcode, 30, 6 )

                        Keypress_String( NewString )

                        Keypress_Key( "VT100", "Enter" )

                        NewString = String_Middle( sBarcode, 38, 10 )

                        Keypress_String( NewString )

                        Keypress_Key( "VT100", "Enter" )

                        NewString = String_Middle( sBarcode, 50, 5 )

                        Keypress_String( NewString )

                        Keypress_Key( "VT100", "Enter" )

                    Else

                        Scan_String( sBarcode, nBarcode )

                End_If

                    Return

                 

                When I add a script to the screen I want, I get an error message.

                screenscript.png

                 

                Could you please tell me how should I integrate my script in the reformatter module  ?

                • 7. Re: Cannot get script working (multiple conditions)
                  Niko1024 Rookie

                  Hello,

                   

                  I simply missed to duplicate the Scan_String function...

                  So problem solved.

                   

                  Thank youfor your help !

                   

                  Script( KE1_REC )

                  String( sBarcode )

                  String( NewString )

                  Number( nBarcode )

                  Activate( On_Input, sBarcode, nBarcode )

                      If( String_Equal( Get_Screen_Text( 1, 1 ), "KE1 REC", 7, FALSE ) )

                  If( String_Equal( Get_Screen_Text( 4, 1 ), "LPN:", 4, FALSE ) )

                  If( Number_Equal( nBarcode, Get_Scan_Type_Value( "QR CODE" ) ) )

                  NewString = String_Middle( sBarcode, 2, 18 )

                  Keypress_String( NewString )

                  Keypress_Key( "VT100", "Enter" )

                  NewString = String_Middle( sBarcode, 30, 6 )

                  Keypress_String( NewString )

                  Keypress_Key( "VT100", "Enter" )

                  NewString = String_Middle( sBarcode, 38, 10 )

                    Keypress_String( NewString )

                  Keypress_Key( "VT100", "Enter" )

                  NewString = String_Middle( sBarcode, 50, 5 )

                  Keypress_String( NewString )

                  Keypress_Key( "VT100", "Enter" )

                  Else

                  Scan_String( sBarcode, nBarcode )

                  End_If

                  Else

                  Scan_String( sBarcode, nBarcode )

                  End_If

                      Else

                  Scan_String( sBarcode, nBarcode )

                      End_If

                   

                      Return