patrickglass Posted May 29, 2007 Posted May 29, 2007 Hello, I am using FileMaker Advanced and have been having some problems with the Send Event Script command for windows xp. I am attempting to execute a program to parse a file into csv for importing. It is written in C# 2005. The problem is it is intermittent on wether it will throw an error. The program works perfect when i execute it manually. The problem is that after closing filemaker and openting up the script i have to redefine the file reference of the exe in order for it work work. if i skip that step then it will throw an error with my application. The EXE does not use the command line for extra configurations option so it cannot fail because some extra characters are coming in as arguments. The problem only happens if i don't newly make the file reference. What does the send event actually do when is is run. ie how does it open or execute the file. Any help would be greatly appreciated.
Vaughan Posted May 29, 2007 Posted May 29, 2007 "...parse a file into csv for importing" Can't this be done with XML?
patrickglass Posted May 30, 2007 Author Posted May 30, 2007 Well im not sure that i knew xml could be used for this. i need a solution to read a file with spaces and "|" delimiters. then it needs to delete the file it read after backing it up. here is my code for the ParsePartsControl.exe string sLine; string ControlID, PersonnelID, TransactionType, RequestorID, Value, Day, Month, Year, Hours, Minutes, Seconds, TimePostfix; string[] lineParsed = new string[20]; System.Console.WriteLine("Set Settings"); StreamWriter outputFile = new StreamWriter("ParsedPartsControl.csv"); System.Console.WriteLine("Done Outfile Linking"); StreamReader inputFile = new StreamReader("PartsControl.txt"); System.Console.WriteLine("Done InFile Linking"); System.Console.WriteLine("Created Writer References"); // Write header to file outputFile.WriteLine("BarcodeID,PersonnelID,TransactionType,RequestorID,Value,Timestamp"); System.Console.WriteLine("Wrote Header File"); while (!inputFile.EndOfStream) { sLine = inputFile.ReadLine(); sLine = sLine.Replace(" ", ""); lineParsed = sLine.Split('|'); ControlID = lineParsed[0]; PersonnelID = lineParsed[1]; TransactionType = lineParsed[2]; RequestorID = lineParsed[3]; Value = lineParsed[4]; Year = lineParsed[5].Substring(0, 4); Month = lineParsed[5].Substring(4, 2); Day = lineParsed[5].Substring(6, 2); Hours = lineParsed[5].Substring(8, 2); Minutes = lineParsed[5].Substring(10, 2); Seconds = lineParsed[5].Substring(12, 2); TimePostfix = "AM"; int intHours = Convert.ToInt32(Hours); if (intHours > 12) { intHours = intHours - 12; Hours = intHours.ToString(); TimePostfix = "PM"; } if (PersonnelID.Length != 3) PersonnelID = ""; if (RequestorID.Length != 3) RequestorID = ""; outputFile.WriteLine(ControlID + "," + PersonnelID + "," + TransactionType + "," + RequestorID + "," + Value + "," + Month + "/" + Day + "/" + Year + " " + Hours + ":" + Minutes + ":" + Seconds + " " + TimePostfix); } System.Console.WriteLine("End of loop"); inputFile.Close(); outputFile.Close(); System.Console.WriteLine("Completed Successfully - No Errors found"); } catch { System.Console.WriteLine("Error Processing functionnnNO SPACES ALLOWED IN FILENAMES"); System.Console.WriteLine("Error opening the inputfile PartsControl.txtn" + "Please Ensure that this file exists and is formatted correctly!"); System.Console.WriteLine("Please ensure file exists"); System.Console.Beep(); System.Console.Beep(); System.Console.Beep(); System.Console.WriteLine("nPlease press enter to exit."); System.Console.ReadLine(); I am not at all famillair with XML. if someone thinks this can be done i would appreaciate a pointer to a good information source. The data i have to get in is from a batch barcode scanner Control,UserID,TransactionType,RequestID,Value,Timestamp 260 |259|0|0 |1 |20070529111214 101 |259|0|0 |1 |20070529111215 101 |259|0|0 |1 |20070529111216 195 |259|0|0 |1 |20070529111218 195 |259|0|0 |1 |20070529111219 i just need to remove spaces and change| to , and then format the time somehow into a format that filemaker likes. Thanks for the time. Patrick Glass
comment Posted May 30, 2007 Posted May 30, 2007 You can't really use XML if your file is not an XML file to begin with. However, you could very easily import your raw data into Filemaker, and parse out the single imported field into 6 separate fields. It won't delete your original file, though.
patrickglass Posted May 30, 2007 Author Posted May 30, 2007 thanks comment, I think that may work and it would be good to eliminte the executable to create a better put together project. I have been trying to figure out the reason for the exe failing. i have come to the conclusion. I have the database frontend and back end in c:/Filemaker Databases and have two sub directories that the barcode scanner must use as c:/Filemaker Databases/ToPhaser and FromPhase both one level below the main database. i have an exe in both folders that have to be ran. one for exporting valid users and the other to receive and parse the data. I have found that if i have previously navigated to the folder from within filemaker using the open command the exe in that folder will run without problems. however since i have the exe's in seperate folders only one will work at a time. I have no idea why the autosaved path for filemaker would change the way it is run. everytime the exe will run but it will throw exceptions when not in the "current folder". I have tried making full paths as well as relative and seemed to make no differnece. If anyone could shed some light on what's happening it would be much appreciated. I hope i made myself clear. Patrick Glass
Recommended Posts
This topic is 6388 days old. Please don't post here. Open a new topic instead.
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 accountSign in
Already have an account? Sign in here.
Sign In Now