Protour Travel Posted November 30, 2013 Posted November 30, 2013 I may be asking this in the wrong place since it pertains to the printed page instead of a GUI layout. Please forgive me if I have. Â My question has to do with text parsing. I would like to have to individual city names to print without the comma or state name or airport code. Â In other words, show only the words to the left of the comma. Please see the attached image. Â The formula I am using to get the text block is; Â List ( TextStyleAdd (Â Origin_1&" to "& Destination_1 & " -- " &Left ( DayName ( Date_1 ); 3) & ", " &Left ( MonthName ( Date_1 ); 3) & " " & Day ( Date_1 ); Bold); Airline_1 & If (not IsEmpty ( Flight_1 ); " #" & Flight_1; "" )&If (not IsEmpty ( Departure_1 ); "Â Â Â Â Â Â Â Â Â Departs; " & Departure_1; "")& If (not IsEmpty ( Arrival_1); "Â Â Â Â Â Arrives: "&Arrival_1; ""); If (not IsEmpty ( LayoverLocation_1 ); "Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Layover in " & RightWords ( LayoverLocation_1; 1) & " for " & Hour ( Layover_1) & "h" & Minute ( Layover_1) & "m";"") ) Â Thank you in advance for any advice given. By the way, you guys are amazing. I can only hope to be half as good as some of you are.
Lee Smith Posted November 30, 2013 Posted November 30, 2013 (edited) Automatic message This topic has been moved from "Eye Candy" to "Calculation Engine (Define Fields)". An attachment of text would have been easier for us to work with and I’m confused by your description as to what you have now and what the result should be. i.e. Los Angles, CA Denver, CO or Los Angles CA LAX mon xxxxx Nov 11 Denver CO ? I removed my suggested link, as it didn’t match your requested need as I understood it. Edited November 30, 2013 by Lee Smith Edited
Protour Travel Posted December 1, 2013 Author Posted December 1, 2013 Sorry Lee. I should have been more concise. I am wanting the first line of text to read as follows; Los Angeles to Denver -- Mon, Nov 11. and not Los Angeles, CA (LAX) to Denver, CO (DEN) -- Mon, Nov 11. I am wanting to lose everything to the right of the comma including the comma (ie: , CA (LAX)).
LaRetta Posted December 1, 2013 Posted December 1, 2013 If we can assume there is always a From and a To and we can assume that 'to' separates them then you can try this: Let ( string = Substitute ( table::Field ; [ "," ; ¶ ] ; [ " to " ; ¶ ] ; [ "--" ; ¶ ] ) ; GetValue ( string ; 1 ) & " to " & GetValue ( string ; 3 ) & " --" & GetValue ( string ; 5 ) & GetValue ( string ; 6 ) ) Now that's lazy of me! It must be residual from the turkey! Edited: Removed an unnecessary space
Matthew F Posted December 1, 2013 Posted December 1, 2013 I gather that your airport data fields (Origin_1, Destination_1, etc.) contain City, State, and Airport Code, but you just want to list the City. Is that correct? If so, then I'm guessing that you want to extract the text left of the comma in that data field. Left (Airport, Position ( Airport ; "," ; 1 ; 1 ) -1 ) You could wrap this step around each airport field in your calculation. Alternatively, since you're on FM Pro Advanced, you could create a custom function to do the same, and then use this to make your calculation a bit more concise.
Protour Travel Posted December 1, 2013 Author Posted December 1, 2013 That's perfect Matthew! Thank you for understanding how I don't explain things. Now if I can just figure out how you came up with this...
LaRetta Posted December 1, 2013 Posted December 1, 2013 I am wanting the first line of text to read as follows; Los Angeles to Denver -- Mon, Nov 11. and not Los Angeles, CA (LAX) to Denver, CO (DEN) -- Mon, Nov 11. LOL, I was giving you a way to parse this: Los Angeles, CA (LAX) to Denver, CO (DEN) -- Mon, Nov 11. to this: Los Angeles to Denver -- Mon, Nov 11.
Lee Smith Posted December 1, 2013 Posted December 1, 2013 (edited) Hi LaRetta, After all of my teeth pulling, I guess we still didn’t understand the need. @ProTour LaRetta’s calculation does what you asked. AND: If not, than you didn’t present an accurate copy of the text, which can be different when you are copying stuff from a site Edited December 1, 2013 by Lee Smith Corrected a typo and added AND:
LaRetta Posted December 1, 2013 Posted December 1, 2013 I confess that I only read the final post by ProTour and responded accordingly in quite a hurry ... not my usual technique of due diligence. When I came home and read the entire thread, I realised I was off.
Matthew F Posted December 2, 2013 Posted December 2, 2013 ProtTour: Now if I can just figure out how you came up with this... It was sort of a guess based on your complicated List formula and the output that you gave. I really wasn't sure what was the contents of your Airport data fields. On a related note, it might help clarify complicated calculations like that by breaking them into several components. If its part of a script then you might use several variables to build up towards the final output. That might make troubleshooting or future changes easier. I also mentioned the use of custom functions for the same reason. In regards to parsing text, it is common to require that some sort of data be extracted out of a larger string. The Left, Right, and Middle functions are useful to this end, if you are able to identify a definite start and finish point for the substring of interest. In your case the comma serves as a handy delimiter, marking the end of the City name. Position ( Airport ; "," ; 1 ; 1 ) gives the position of the comma. Left (Airport, x - 1 ) gives everything left of the comma (where x is the comma position, as above)
Protour Travel Posted December 3, 2013 Author Posted December 3, 2013 Okay, first off, thanks to everyone for your advise and input. @ Lee - I honestly thought I was giving you everything you needed. Contained in the original post was the List calculation that gave me the printed result shown in the top pane of the attachment. What I wanted to do was to have a printed result as was shown in the bottom pane (which was a PDF document with the unwanted parts edited out). I admit I wasn't clear on this. My wife was screaming at me to get off the computer and 'do something useful'. I thought I was doing something useful. @ LaRetta - Your example was great except something else I forgot to mention. There are fields for up to 10 flight entries. the way I see it as the way yours was written, If I didn't use all 10 flight entries and for example only used two flights (outbound and returning), the printout was going to have the word 'to' and the symbol '--' in flights 3-10 therefore prohibiting the sliding/reducing action to work properly. Since I am very particular about the way my printouts look and since parts and portals don't resize correctly, I try to use calculation fields for my printing there for allowing me to only use the body part without a header. The footer usually contains the page number. Therefore using Matthew's example was what worked best for me. Once again, thanks to everyone for your response and advise. Charlie
Lee Smith Posted December 3, 2013 Posted December 3, 2013 No Problem Charlie, I wanted to ensure that we had an accurate picture of the raw data and a clearer understanding of what you wanted as a result of the parse calculation. In fact, I started to supple a calculation for just the Los Angles portion, but after I reread your original post, it seemed like you wanted something along the lines of what LaRetta provided. Los Angeles to Denver -- Mon, Nov 11. and not Los Angeles, CA (LAX) to Denver, CO (DEN) -- Mon, Nov 11 Lee
Recommended Posts
This topic is 4065 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