George TOUBALIS Posted July 30, 2005 Posted July 30, 2005 I need Your Help... I a Table With CD Albums (the Father) I have Also A 2nd Table With Music Tracks (childs) I have made a portal to see the music tracks for every cd All Want Is to Have A text Field In CD Albums table with the related music tracks in it. For Example Artist Aerosmith (field) Title JUST PUSH PLAY (field) Tracks (field) Beyond Beautiful/Just Push Play/Jaded/Fly Away From Here/Trip Hoppin'/Sunshine/Under My Skin/Luv Lies/Outta Your Head/Drop Dead Gorgeous/Light Inside/Avant Garden I want This Delimiter "/" for export work. Can you Help me?
Fenton Posted July 30, 2005 Posted July 30, 2005 You need to create a Value List, using the portal's relationship, "only related values," starting from Albums. Remember the name, say "Album_Tracks". Create an Unstored (important) calculation field, in Albums, = Substitute ( ValueListItems (Get(FileName), "Album_Tracks");
George TOUBALIS Posted July 30, 2005 Author Posted July 30, 2005 Works in some way....what about but the sorting of tracks..? The 1,2,3... of tracks gives Beyond Beautiful/Just Push Play/Jaded/Fly Away From Here/Trip Hoppin'/Sunshine/Under My Skin/Luv Lies/Outta Your Head/Drop Dead Gorgeous/Light Inside/Avant Garden With the Value list Gives Avant Garden/Beyond Beautiful/Drop Dead Gorgeous/Fly Away From Here/Jaded/Just Push Play/Light Inside/Luv Lies/Outta Your Head/Sunshine/Trip Hoppin'/Under My Skin
Fenton Posted July 30, 2005 Posted July 30, 2005 Sort the value list by a Track# field (has to be an indexed field), by using "Also show values from field", then the radio button "Sort by 2nd field." BTW, while doing a test of this I discovered a bug in the ValueListItems (Get(FileName), "value list name") function. It fails if the file name has 2 periods, in other words a period besides the one before the extension. Strangely enough, Get(FileName) does not fail, but ValueListItems using it does. (P.S. I never use periods myself anyway; it was someone else's "versioned" file.) This is on Mac OS 10.3.8, Dev. 7
George TOUBALIS Posted August 3, 2005 Author Posted August 3, 2005 (edited) How About A script.... But I think I need A loop! Can you help with the loop Edited August 3, 2005 by Guest
PeterHW Posted August 3, 2005 Posted August 3, 2005 Hi, yes you definitely need a loop Also, you do not need the copy/paste steps. Create a new field in Albums, gCounter, Global, number The loop is exited if the "Exit Loop If" statement evaluates to true. This happens when gCounter is equal to the number of related records in Tracks (+1 because gCounter was initialized at 1 in stead of 0). Note that gCounter is increased by 1 after each loop. With the "Go To Portal Row" step, choose "by calculation" and insert Albums::gCounter in the calculation dialog box. The field Albums::Tracks II is set by the following calculation : Set Field [ Albums::gCounter; 1 ] Set Field [ Albums::Tracks II; "" ] Loop Exit Loop If [ Albums::gCounter = Count (Tracks::Track) + 1 ] Go to Portal Row [ Albums::gCounter ] [ No dialog ] Set Field [ Albums::Tracks II; Albums::Track II & "/" & Tracks::Track ] Set Field [ Albums::gCounter; Albums::gCounter + 1 ] Pause/Resume Script [ Indefinitely ] End Loop Set Field [ Albums::Tracks II ; Right (Albums::Tracks II;Length(Albums::Tracks II)-1) Note the following Albums::Tracks II & "/" & Tracks::Track I.e. the field is set to its own contents + "/" and the contents of the Tracks::Track field of the [color:red]currently selected portal row. See, no copy/paste or even "select" required. Note that the Pause/Resume script step is not really necessary here (because the script hopefully works first time (at least I tested it ) but it's always a good idea to include it at the end of a loop for testing purposes. Getting caught in an endless loop is a likely alternative. Since this is your first loop, it will also help you to see what is happening going through the loop each time. Click on "continue" (on the status area) to continue the script. The final Set Field [ Albums::Tracks II ; Right (Albums::Tracks II;Length(Albums::Tracks II)-1) is added to strip the first "/" from the field. There are other ways, but this works. Anyway, hope this helps, good luck with it. Regards, Peter
Søren Dyhr Posted August 3, 2005 Posted August 3, 2005 But I think I need A loop! I think you need quite a bit more, first Copy/Paste the way you do it is pure and simple a bad developer habit. What you try to do is collecting rows via the portal, which is possible, but a little clunky to say the least, and especially if you havn't discovered that an option in the Go To Portal Row is based on a calculation. Another way is to GTRR(SO) to a layout where only the titlefield is shown, make an attempt to save what's in clipboard in a global containerfield. Issue a Copy All Records[ scriptstep, paste the result to the recieving field in the parent record, regain the stuff saved from the clipboard. Back again the to maintables record, and make a substitute making the pilcros into the slashes you wished to have. checkout the attached file! --sd Records.zip
Søren Dyhr Posted August 3, 2005 Posted August 3, 2005 (edited) Meanwhile did I come up with a more contemporary solution: Commit Records/Requests [ Skip data entry validation; No dialog ] Go to Related Record [ From table: "PortalStuff"; Using layout: "PortalStuff" (PortalStuff) ] [ Show only related records ] If [ IsEmpty ( Get ( ScriptParameter ) ) ] Go to Record/Request/Page [ First ] Perform Script [ "New Script2"; Parameter: PortalStuff::SongTitle & "/" ] Else If [ Get ( RecordNumber ) <> Get ( FoundCount ) ] Go to Record/Request/Page [ Next ] Perform Script [ "New Script2"; Parameter: Get ( ScriptParameter ) & PortalStuff::SongTitle & "/" ] Else Set Field [ Records::recieverField; Get ( ScriptParameter ) ] Go to Layout [ "Records" (Records) ] End If Not involving the clipboard at all! --sd Edited August 3, 2005 by Guest If you forget to commit the record will the script only consider the record the cursor have reached and downwards!
Recommended Posts
This topic is 7038 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