Announcement

Collapse
No announcement yet.

Editor problem on blank application "On Execute" matching brackets turn red

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Editor problem on blank application "On Execute" matching brackets turn red

    I have a program that has been working fine until now where it is about 15 pages long and had no problem until last weekend.
    The code is executed under a main "While Loop that reads a database" and process all records selected.
    The while loop (see below) has a start bracket and an end bracket, all the code is in side of the 2 brackets.
    I have removed all the code and started pasting and compiling chances of code to make sure my brackets match
    They all match but for some reason and no good reason at all at about 5th page the end bracket for the while loop turns red when I click on it to make sure it highlights as when matching brackets are found on the code. Does anyone have this problem and is this an error that returns problems as I am now getting duplicate inserts and was not doing this before…?????

    while (!feof($file_handle) ) { ---------------------------- >>> start bracket
    $row = fgetcsv($file_handle, 1024);
    $listcnt++;
    $lis_id = $row[0];
    $entry_date = $row[1];
    $modify_date = $row[2];
    $status = $row[3];

    … more code goes here
    .. more code goes here
    .. eventually the "end" bracket simply turns red as if there was no matching brackets but there is.

    } --- >>> End bracket for while loop - this bracket turns red like when there is no matching bracket but there is

  • #2
    Are there if statements in there without brackets?
    if (something) do_something; can cause sc to parse badly and basically make wrong code.
    The basic rule to avoid is to always use { } so in this case if (something) {do_something};
    or better
    if (something) {
    do_something
    };

    Comment


    • #3
      Yep you must use brackets for every statement otherwise strange things could(and it would) happen

      Comment


      • #4
        Sure there is multiple "if" statements all of them have matching brackets that is not the problem, the code has been stripped completely off and rebuilt one block of code at a time to see where it breaks but each and every "if" statement has the matching brackets. I have taken out all of the empty lines to see if there is a problem with them but makes no difference.
        I have also created a new blank application and have pasted one if statement at a time inside of the while look pair of brackets and still get the problem after several "if" statements are embedded within the while loop. The last part where it breaks is not even an "IF" statement it contains a bunch of print lines all of which are correctly coded. I can copy and paste a few without the break but after an "X" number of display lines it does break so is not the print lines

        Comment


        • #5
          We have had some weird errors as well. And as odd as it sounds sometimes we remove some fields and links generate it, and put them back then suddenly things work again. Dont ask me why, it is problably some bug.
          Anyway apart from that, you may have used a reserved php word for a variable name or something else which causes the parser to react badly. That also happens (not a lot but luckily).
          In that case just work from the ouside in in pasting it back until you find the specific line that causes the 'redness'. Possibly in the you use a reserved word or something else that causes the parser to become weird.
          Alternatively past your code in a good php editor with color highlighting and reserved word highlighting. Maybe you can see it then..

          Comment


          • #6
            Thank you for the reply "rr" I tried to check for the "php reserved word" and I can't see nothing.
            My problem happens where I have a block of "print lines" (using to display values on input record), there are some 30 print lines, about the middle of it starts to mess up.
            I pasted everything up to all the print lines. deleted one by one starting from the bottom and when I hit the 15th print line I start to see the error.
            This is what is happening:
            I see no "php reserved word being used"
            When I take the 15th line out the bracket goes black, when I put it back in the bracket goes red.
            When I leave the 15th line but I comment it with 2 slashes in front of it, the bracket remains red, example: (// print "field 15th is: ".$field15."<br/>";
            When I leave the 15th line but I comment the 14th and 15th print lines the same way the bracket stays red.
            Taking the 15th print line out the bracket goes back to black. IM LOST !!!,,, I have attached the code up to that point if you care to try it and see if you get the same
            results let me know.
            P.S. which editor you suggest to use to see reserved words and highlights??
            Attached Files

            Comment


            • #7
              I dont get the header in your file that is some rtf header, thus not just plain php code... And all those \ on the end of the line.. Kinda odd.. Is that what you see in your scriptcase code edit screen? Or am I missing something here?
              I usually use ultraedit and notepad++ would suffice and crimson editor.

              Comment


              • #8
                u-wrote: I dont get the header in your file that is some rtf header
                I don't see back slashes on my code anywhere I don't use them.

                Commented code in php can be done 2 ways
                This way, a "/*" marking the beginning of a block of code to be commented out and at the end of the block, "*\", see below:

                Option-1:
                /*
                line1 commented code
                line2 commented code
                line3 commented code
                */

                Option-2: 2 forward slashes at the beginning of each line of code to be commented out
                Or this way, where each line of code has 2 forward slashes commenting a specific line of code
                // line1 commented code
                // line2 commented code
                // line3 commented code

                Option-3: Or this way, 2 forward slashes and the "*" which is the same as the 2nd option above.
                //* line1 commented code
                //* line2 commented code
                //* line3 commented code


                If you see back slashes I am not sure what line you are looking at.

                Thank you.

                Comment


                • #9
                  Your BadCodeSc.txt looks like this (just downloaded it again):
                  Code:
                  {\rtf1\ansi\ansicpg1252\cocoartf1265\cocoasubrtf190
                  {\fonttbl\f0\fswiss\fcharset0 Helvetica;}
                  {\colortbl;\red255\green255\blue255;}
                  \margl1440\margr1440\vieww16520\viewh10480\viewkind0
                  \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
                  
                  \f0\fs24 \cf0 //*************************************************************************************\
                  //*                      -*- Change Log  -*-                                    \
                  //*************************************************************************************\
                  .....
                  That is the header for rtf files...

                  I never use option 3 for commenting.
                  I know that the parser sometimes gets confused in the comments. Namely if you put [myvariable] stuff in there... The general advice is to NOT use any [....] in your comments. It was a bug and I dont know if they have ever fixed it.
                  Anyway I opened it in wordpad where you aparently pasted it in. Then copied the text to ultraedit.
                  That looked good to me. So I pasted it in scriptcase under some event and that looks good except for the last commentline, that last line is of course wrong.
                  End of while loop ??? probably meant as comment... so I dont see any strange text IF i use your code as text. The point that you saved your file with a txt extension doesnt make it txt.
                  Code:
                  //*************************************************************************************
                  //*                      -*- Change Log  -*-                                    
                  //*************************************************************************************
                  //* changeid    date    who        what changed 
                  //* --------   -------- ------ --------------------------------
                  //* cr00001    20131000 javx    
                  //* cr00001    20131124 javx   added user_group at end of table inputdex_list_ventas 
                  //* cr00001    20131124 javx   removed insert into customer_products (might not need table bad key error)   
                  //* cr00001    20131127 javx   removed agents_activity edits and inserts 
                  //*************************************************************************************
                  $listcnt     = 0;
                  $ventascnt   = 0; 
                  $bypassedcnt = 0;
                  $addresscnt  = 0;
                  $cardscnt    = 0;
                  $defaultx    = " ";
                  $default0    = 0;
                  $default6    = 6;      
                  $defaultMexico = 151; 
                  $productscnt = 0;
                  $campaignscnt = 0;
                  
                  //*****************************************************************
                  //* Read the csv file created by process1 
                  //***************************************************************** 
                  $file1 = [global_folder];
                  print "blank app2 - carpeta es: ".[global_folder]."<br/>";
                  
                  $file2 = "inputdex_list_load_to_intelix";
                  $myFile = $file1.$file2; 
                  $file_handle = fopen($myFile, "r");
                  
                  while (!feof($file_handle) ) 
                  {	
                  $listcnt++;
                  $input_id                     = $row[0];
                  $inputentry_date              = $row[1];
                  $inputmodify_date             = $row[2];
                  $inputstatus                  = $row[3];
                  $inputuser                    = $row[4];
                  $inputvendor_code             = $row[5]; // has birthdate
                  $inputsource_id               = $row[6];
                  $inputlst_id                  = $row[7];
                  $input_offset                 = $row[8];
                  $input_reset                  = $row[9];
                  $inputphone_code              = $row[10];
                  $inputphone_number            = $row[11];
                  $inputtitle                   = $row[12];
                  $inputfirst_name              = $row[13]; // full name
                  $inputmiddle_initial          = $row[14]; // product code
                  $inputlast_name               = $row[15]; // has the RFC 
                  $inputaddress1                = $row[16]; // complete address
                  $inputaddress2                = $row[17]; // has TDC      not used for duplicates more than 1 person can use same card 
                  $inputaddress3                = $row[18]; // has TDC date not used for duplicates more than 1 person can use same card  
                  $inputcity                    = $row[19]; // has TDC verify code no se usa para duplicates see above  
                  $inputstate                   = $row[20];
                  $inputprovince                = $row[21]; // has nombre en TDC
                  $inputpostal_code             = $row[22]; // has company name 
                  $inputcountry_code            = $row[23];
                  $inputgender                  = $row[24];
                  $inputdate_of_birth           = $row[25];  // no se usa 
                  $inputalt_phone               = $row[26];
                  $inputemail                   = $row[27];
                  $inputsecurity                = $row[28];
                  $inputcomments                = $row[29];
                  $input_count                  = $row[30];
                  $inputlast_time               = $row[31];
                  $inputrank                    = $row[32];
                  $inputowner                   = $row[33];  
                  $ventac0mpany_id              = $row[34]; // from 1rst process
                  $ventacompany_name            = $row[35]; // from 1rst process 
                  $start_time                   = $row[36]; // from 1rst process recording log s time 
                  $end_time                     = $row[37]; // from 1rst process
                  $len_seconds                  = $row[38]; // from 1rst process
                  $len_minutes                  = $row[39]; // from 1rst process
                  $filename                     = $row[40]; // from 1rst process
                  $location                     = $row[41]; // from 1rst process 	
                  $user_group                   = $row[42]; // from 1rst process 
                  $user_full_name               = $row[43];
                  $user_group_name              = $row[44];	
                  //*
                  //* remove single quotes from string breaks the program code (abends before ending)  
                  //*		
                  $string          = $inputaddress1;
                  $inputaddress1    = str_replace("'", '', $string);
                  $string          = $inputpostal_code;
                  $inputpostal_code = str_replace("'", '', $string);
                  $string          = $inputcomments;
                  $inputcomments = str_replace("'", '', $string);	
                  //* 
                  //* Exit this process when there are no records to process on input file 
                  //*	
                  if (empty($inputlead_id)) 
                  {
                      echo 'NO REGISTROS ARCHIVO ESTA VACIO, EMPTY, AT END OF FILE O NO EXISTE';
                  	flush();
                      exit;	
                  }	
                  //*****************************************************************
                  //* Remove double quotes and single quotes from status, user, phone_code, phone_number
                  //*****************************************************************
                  $inputstatus     = preg_replace("/[^a-zA-Z0-9]+/", "", html_entity_decode($inputstatus, ENT_QUOTES));
                  $inputstatus     = preg_replace("/[^a-zA-Z0-9]+/", "", $inputstatus);
                  $inputuser       = preg_replace("/[^a-zA-Z0-9]+/", "", html_entity_decode($inputuser, ENT_QUOTES));
                  $inputuser       = preg_replace("/[^a-zA-Z0-9]+/", "", $inputuser);
                  $inputphone_code = preg_replace("/[^a-zA-Z0-9]+/", "", html_entity_decode($inputphone_code, ENT_QUOTES));
                  $inputphone_code = preg_replace("/[^a-zA-Z0-9]+/", "", $inputphone_code);
                  $inputphone_number = preg_replace("/[^a-zA-Z0-9]+/", "", html_entity_decode($inputphone_number, ENT_QUOTES));
                  $inputphone_number = preg_replace("/[^a-zA-Z0-9]+/", "", $inputphone_number);
                  $inputfirst_name   = trim($inputfirst_name ,'"');	   
                  $inputmiddle_initial = preg_replace("/[^a-zA-Z0-9]+/", "", html_entity_decode($inputmiddle_initial, ENT_QUOTES));
                  $inputmiddle_initial = preg_replace("/[^a-zA-Z0-9]+/", "", $inputmiddle_initial);
                  $inputaddress2  = preg_replace("/[^a-zA-Z0-9]+/", "", html_entity_decode($inputaddress2, ENT_QUOTES));
                  $inputaddress2  = preg_replace("/[^a-zA-Z0-9]+/", "", $inputaddress2);	    	  
                  //****************************************************************
                  //* Display input inputdex list record
                  //****************************************************************
                      print "==============================================" . "<br/>"; 
                  	print "=== inputdex record ====" .$input_id.             "<br/>"; 
                  	print "input_id                " .$input_id.             "<br/>";
                  	print "dateentered             " .$inputentry_date.      "<br/>";
                  	print "datemod                 " .$inputmodify_date.     "<br/>";
                  	print "status                  " .$inputstatus.          "<br/>";
                  	print "user                    " .$inputuser.            "<br/>";
                  	print "vendor_code             " .$inputvendor_code.     "<br/>";
                  	print "source_id               " .$inputsource_id.       "<br/>";
                  	print "list_id                 " .$inputlst_id.          "<br/>";
                  	print "offset                  " .$input_offset.         "<br/>";
                  	print "reset                   " .$inputcalled_reset.    "<br/>";
                  	print "phone_code              " .$inputphone_code.      "<br/>";
                  	print "phone_number            " .$inputphone_number.    "<br/>";
                  	print "title                   " .$inputtitle.           "<br/>";
                      print "first name              " .$inputfirst_name.      "<br/>";
                  }	 End of while loop

                  Comment


                  • #10
                    Ok thanks so we still don't know what the problem is because there are no [..] in commented lines that I can see, and yes the last line should have been sent to you as } // End of while loop which is how it is in the code itself.

                    I don't user "rtf" files, I am using a MAC p.c. and copied the code to send to you into a tool they have called "Text Edit" so no I don't have any "rtf" stuff on the code used in ScriptCase.
                    Thank you for looking I will keep trying to see if I can discover the what the problem is.

                    Comment


                    • #11
                      Hello,

                      I will verify the issue with our bugs team.

                      regards,
                      Bernhard Bernsmann

                      Comment

                      Working...
                      X