Our Preferred 5 Star Hosting Provider - Award Winning FileMaker Pro Hosting
Results 1 to 6 of 6
  1. #1
    Forum Member
    Join Date
    Oct 2014
    Posts
    80
    Location
    Australia
    FileMaker Pro Software
    FM13 Adv, FM14 Server, FM15 Adv
    OS
    Windows & Mac
    Skill Level
    Novice
    Last Post
    06-01-2017
    Local Date
    07-29-2017
    Local Time
    04:49 AM
    Last Active
    07-25-2017

    Substituting a list using another list

    I have a variable $$headers which is a list of values
    valueone
    valuetwo
    valuethree
    valuefour
    valurfive

    etc

    I want to take multiple items out of the list that are not necessarily in the order they are in the list using substitute based on a list in a field.

    Let(
    [
    thelist =Substitute ( Table::Field; ; """;""""];[""")
    ;
    leftlist = Left ( thelist; length(thelist)-3)
    ;
    rightlist = right(leftlist;length(leftlist)-6)
    ]
    ;
    Substitute ( $$Headers; rightlist)
    )

    when I am testing, rightlist is as expected
    ["valueone";"""];["valuethree";""]

    but the substitute function errors...

    I essentially want my list ($$Headers)to stay in order, minus the list in Table::Field


    If I copy the results from Rightlist into the substitute function it works (yes I have extra lines that's a different issue), but passing it in from a let statement doesn't.

    Any ideas??

  2. #2
    Senior Moderator - FMT Preferred Trainer - Consultant: Australia, New Zealand, Japan & Pacific Rim David Head's Avatar
    Join Date
    Apr 2001
    Posts
    2,889
    Location
    Sydney, NSW Australia
    FileMaker Pro Software
    FileMaker Pro 15 Advanced
    OS
    Windows & Mac
    Skill Level
    Developer
    Last Post
    06-13-2017
    Local Date
    07-29-2017
    Local Time
    04:49 AM
    Last Active
    07-19-2017
    What are you trying to do with the Substitute function?

    You have: Substitute ( Table::Field; ; """;""""];[""")

    The function will do progressive substitution with [ ] but not as you have it.

    This would work for two pairs of subs:
    Substitute ( Table::Field; [ ; """ ] ; [ """" ; """ ] )

    If you explain more about what you are trying to do, I suspect a recursive custom function will do the job for you.
    Regards,
    David Head
    FileMaker 15 Certified Developer
    FBA Trainer
    LinkedIn Profile

    There is always a well-known solution to every human problem - neat, plausible, and wrong.
    H. L. Mencken, Prejudices: Second Series, 1920

  3. #3
    Forum Member
    Join Date
    Oct 2014
    Posts
    80
    Location
    Australia
    FileMaker Pro Software
    FM13 Adv, FM14 Server, FM15 Adv
    OS
    Windows & Mac
    Skill Level
    Novice
    Last Post
    06-01-2017
    Local Date
    07-29-2017
    Local Time
    04:49 AM
    Last Active
    07-25-2017
    Sorry I lost my reply...


    I have a variable $$Headers which I am using as part of a displayed report

    Customer
    Phone
    Address
    Suburb
    Postcode
    Product One
    Product Two
    etc.

    I have a field gHeader (global field) and gHidden (global field) gHeader gets loaded back into a variable to display with the report.
    The user can remove items from the list and gHeader and it is reflected in $$headers

    However when an item is added back, I can only put it at the bottom of the list

    Customer
    Suburb
    Postcode
    Product One
    Product Two
    Address

    So I was thinking if I used the data in field gHidden and used Substitute to set the data in gHeader it would be in the correct order as Substitute does not change the order when removing data.

  4. #4
    Forum Member
    Join Date
    Oct 2014
    Posts
    80
    Location
    Australia
    FileMaker Pro Software
    FM13 Adv, FM14 Server, FM15 Adv
    OS
    Windows & Mac
    Skill Level
    Novice
    Last Post
    06-01-2017
    Local Date
    07-29-2017
    Local Time
    04:49 AM
    Last Active
    07-25-2017
    Hi David,

    Your suggestion is backwards to what I am trying to achieve.

    Let me simplify it

    I have one main list

    $$VarList
    valueone
    valuetwo
    valuethree
    valuefour

    I have another list
    $$ListRemove
    ValueThree
    valuetwo

    And another List which has had values from $$ListRemove added back to it
    $$theList
    valuefour
    valueone


    I want to have $$TheList in the same order as $$VarList.
    What I was trying to do was substitute all list items from $$ListRemove from $$VarList, then replace $$TheList with the result in the corrected order.

    A combination of $$ListRemove and $$TheList will have all values in $$VarList, which is why I thought substitute would work.

    $$ListRemove does not have values in the same order as in $$VarList...

  5. #5
    Senior Moderator - FMT Preferred Developer Consultant - Netherlands, Europe, Asia, USA Maarten Witberg's Avatar
    Join Date
    Mar 2004
    Posts
    6,135
    Location
    netherlands
    FileMaker Pro Software
    version 11, 12, 13, 14, 15
    OS
    Windows & Mac
    Skill Level
    Developer
    Last Post
    06-29-2017
    Local Date
    07-28-2017
    Local Time
    08:49 PM
    Last Active
    07-16-2017
    If the order of the items in $$varlist is determined by the sort order of the related data (which I suspect to be the case judging from the example), I'd be looking at rebuilding the display variable $$theList from the related items and maybe some fixed header info (name address city etc) every time the background data changes (or at the moment of generating the reoport). iInstead of juggling with lists of variables. If a value is empty or zero and you don't want to include it or get an empty line, you can trap for that.

    Maybe you can clarify why you chose the approach with the three variables. Are $$varlist and $$listremove somehow dynamic, if so how?
    Stick to what you don't know.

    http://www.maartenwitberg.nl

    Filemaker 15 Certified Developer

    -------

  6. #6
    Senior Moderator - FMT Preferred Trainer - Consultant: Australia, New Zealand, Japan & Pacific Rim David Head's Avatar
    Join Date
    Apr 2001
    Posts
    2,889
    Location
    Sydney, NSW Australia
    FileMaker Pro Software
    FileMaker Pro 15 Advanced
    OS
    Windows & Mac
    Skill Level
    Developer
    Last Post
    06-13-2017
    Local Date
    07-29-2017
    Local Time
    04:49 AM
    Last Active
    07-19-2017

    Lightbulb

    This recursive custom function will do what you describe:

    If ( ValueCount ( listB ) < 1; listA;
    ListReduce ( Substitute ( listA & ; RightValues ( listB ; 1 ) ; "" ) ; LeftValues ( listB ; ValueCount ( listB ) - 1 ) )
    )


    Screen Shot 2017-05-18 at 10.56.15 am.png

    See how that goes for you.
    Regards,
    David Head
    FileMaker 15 Certified Developer
    FBA Trainer
    LinkedIn Profile

    There is always a well-known solution to every human problem - neat, plausible, and wrong.
    H. L. Mencken, Prejudices: Second Series, 1920

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 08-06-2012, 11:46 AM
  2. Replies: 0
    Last Post: 06-27-2012, 02:36 PM
  3. Replies: 6
    Last Post: 02-20-2008, 07:03 AM
  4. Populate a value list or drop down list with Field names
    By nsns1972 in forum FileMaker Pro 7.0
    Replies: 22
    Last Post: 12-28-2007, 11:36 AM
  5. Substituting a repetitive text variable in single expression
    By Norma_Snockurs in forum Calculations and Define Fields
    Replies: 5
    Last Post: 02-20-2007, 02:55 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Welcome to the Original FileMaker Forum
With designated forums for almost every FileMaker topic...FileMaker Today is a FREE to join community where you can boost your FileMaker expertise, build better apps & solutions and interact with over 42,000+ FileMaker Developers from all over the world. If you're building FileMaker solutions, this is the place for you.
Follow FMT
We Are FMT
FMT is home of The World's leading FileMaker News Site, Worldwide Developer Directory, FileMaker Connect Community and so much more.