Peter Bloeme Posted November 8, 2005 Posted November 8, 2005 (edited) I'm not a wiz on scripting so I was hoping that someone might be able to help me find the solution to my problem. I have a number of records and want to output fields with html coding to format in a specific way. I have been able to export fields so that I get the proper html code by creating fields with html in each record and then exporting them in the proper order along with the data fields. Works great. However, for formatting purposes (look on the web) I only want to include the State field in the first record of each State that I have records for. In other words if I have one record from California I want it to show up... (first record) "CA" + rest of the record If there are more than one records within the State I would like them to show up without the State field as... (first record) CA + rest of the record (second record) rest of the record (third record) rest of the record I suspect it has something to do with finding all records, sorting by state, then creating some sort of script to go from the top of the list to the bottom and setting a field to mark the uniqueness of the records and then run an if statement to go through the list and export one format if this and the other format if that for each record. TIA Edited November 8, 2005 by Guest
T-Square Posted November 8, 2005 Posted November 8, 2005 If you're searching for a particular single value before you run your output routine, you could create a calculation field: If(Get(RecordNumber)=1; State; "") Put that formula in a calculated field for the table (make sure that the result is selected to be text!), and it should give you the result you seek. It works by checking where you are in the current found set, so it won't work on an unsearched table, nor will it work if your search returns more than 1 value in state. HTH, David
Peter Bloeme Posted November 8, 2005 Author Posted November 8, 2005 I'm not sure what you suggested is what I need to do, or I'm not following you. My found set may contain 30 unique States with 100 records total. Each State can have from 1 to many city listings (like a database of health clubs). I want to be able to mark the first record in each found State so that I can format it differently than the other cities, yet show them all. So, what I need to do is, each time I run the calculation, have the program mark the first record for each State in a separate field with some sort of flag. Thanks,
T-Square Posted November 9, 2005 Posted November 9, 2005 Well, in that case, try this: Add a Showstate field to the file (Number field). Add a global LastState field. Change the calc field from before to: If[showState; State; ""] Write a script: # State Markup Go To Layout[MyLayout] // Provide your own Enter Find Mode[] Set Field[searchField; SearchCriteria] // Use your own Perform Find[] Sort Records[Restore] Replace Contents[showState; ""] // Note, don't know the syntax for sure Set Field[LastState; ""] Go To Record/Request[First] Loop If[LastState<>State] Set Field[showState; 1] End If Go To Record/Request[Next; Exit After Last] End Loop That should get you further along the happy trail... David
Peter Bloeme Posted November 11, 2005 Author Posted November 11, 2005 David: I couldn't get it to work your way, but you led me to the following which I think is working. What do you think? Hyperflite Retailer Script Go to Layout [ “Form View” (Contacts) ] Perform Find [ Specified Find Requests: Find Records; Criteria: Contacts::State: “>1” AND Contacts::Database: “Hyperflite Database” ] [ Restore ] Sort Records [ Specified Sort Order: Contacts::State; ascending Contacts::City 1; ascending ] [ Restore; No dialog ] # Go to Record/Request/Page [ First ] Copy [ Contacts::State ] [ Select ] Paste [ Contacts::_LastState ] [ Select ] Insert Text [ Contacts::_ShowState; “1” ] [ Select ] Go to Record/Request/Page [ Next ] # Loop If [ Contacts::State = Contacts::_LastState ] Go to Record/Request/Page [ Next; Exit after last ] Else Copy [ Contacts::State ] [ Select ] Paste [ Contacts::_LastState ] [ Select ] Insert Text [ Contacts::_ShowState; “1” ] [ Select ] Go to Record/Request/Page [ Next; Exit after last ] End If End Loop # Go to Record/Request/Page [ First ]
Recommended Posts
This topic is 6954 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