Your BadCodeSc.txt looks like this (just downloaded it again):
{\rtf1\ansi\ansicpg1252\cocoartf1265\cocoasubrtf190
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww16520\viewh10480\viewkind0
\pard x720 x1440 x2160 x2880 x3600 x4320 x5040 x5760 x6480 x7200 x7920 x8640\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.
//*************************************************************************************
//* -*- 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