ibobo Posted November 29, 2018 Posted November 29, 2018 Hello, I m trying to set up a script the goal is to delete or substitute some words form a Title (field) feeded by a $list (list of word located in different table) exemple I Have a title in table A : - Memory drive flash pen stick 8gb 16gb 32gb 64 gb And I have a list of words in table B : 8go 16 go 32 go 64 gb Output, what I would like to get is : "Memory drive flash pen stick" Each title will have his own list with same reference, there is also a trick because as you can see Gb could mean Go, so I think the best is delete all words matched (8, 16, 32, 64 ...) then I have another script who will delete duplicate words in the field (title) Thank you title_sub.fmp12
comment Posted November 29, 2018 Posted November 29, 2018 I don't understand your example. "16gb" is not the same as "16 go". We can ignore the case, but not the difference between "b" and "o", or the space in the middle . Especially not the space in the middle, since your list is space-delimited. You need to give us some clear-cut rules regarding what you want to consider a match - and be careful not to make them too wide, or you'll end up deleting things you want to keep. Computers have no common sense; they follow the instructions given to them literally.
ibobo Posted November 29, 2018 Author Posted November 29, 2018 I see, it s difficult to choose >< how to do it better, so I think the best way will be : separate word with space, for exemple make a list from the list for words with space : 8go then, 16, then "go", then 32 ... delete them from the title. You re absolutely right about getting wide ))) if I see that it delete word unwanted I can always go back and limit to the first list. thank you Comment
comment Posted November 29, 2018 Posted November 29, 2018 Well, that should be easy enough to do with a script like: Set Variable [ $blacklist; Value:List ( Child::Value ) ] Set Variable [ $n; Value:WordCount ( Parent::Words ) ] Loop Set Variable [ $i; Value:$i + 1 ] Exit Loop If [ $i > $n ] Set Variable [ $word; Value:MiddleWords ( Parent::Words ; $i ; 1 ) ] If [ IsEmpty ( FilterValues ( $word ; $blacklist ) ) ] Set Variable [ $output; Value:List ( $output ; $word ) ] End If End Loop Set Field [ Parent::Result; Substitute ( $output ; ¶ ; " " ) ] I have used Parent::Words as the name of the field that contains the space-separated words, and Child::Value as the name of the field that contains a word to be removed.
ibobo Posted November 29, 2018 Author Posted November 29, 2018 thank you, but I think something is wrong because it doesn't stop looping ? here is the attached file title_sub.fmp12
comment Posted November 29, 2018 Posted November 29, 2018 (edited) For some reason, your counter $i does not increase, and I cannot figure out why. I have disabled your: Set Variable [ $i; Value:$i + 1 ] and replaced it with my own, and that got the script out of the infinite loop. But I am unable to detect the difference between them. You also selected the wrong field when setting the $word variable. -- P.S. You have the Advanced version; use the debugger with Data Viewer to de-bug your scripts. title_sub2.fmp12 Edited November 29, 2018 by comment
ibobo Posted November 29, 2018 Author Posted November 29, 2018 it works perfectly well !! thank you Comment ☺️
ibobo Posted November 29, 2018 Author Posted November 29, 2018 did you ever get this issu : when I run : GetAsNumber ( List ( field::field ) ) I don't have a liste, I have numbers after numbers without space :726956483624 instead of : 72 69 56 48 36 24
comment Posted November 29, 2018 Posted November 29, 2018 That is the expected result. GetAsNumber() converts any string to a single number consisting of the digits contained in the string. Your list is just another string for this purpose. What exactly are you trying to accomplish here?
ibobo Posted November 30, 2018 Author Posted November 30, 2018 well you see it gave me numbers one after one "726956483624" instead I need it like a list like this : 72 69 56 48 36 24
comment Posted November 30, 2018 Posted November 30, 2018 I am afraid you're not being clear. What is your input for this? And is this related to your original question in this thread?
ibobo Posted November 30, 2018 Author Posted November 30, 2018 input : 72LDs 69LDs 56LDs 48LDs 36LDs 24LDs output with Getasnumber "GetAsNumber ( List ( variante::taille ) ) " : 726956483624 what I would like is a list : 72 69 56 48 36 24 it s partly related, it s better if I open a new topic ? with a project file for exemple ? here is an exemple getasnumber.fmp12
comment Posted November 30, 2018 Posted November 30, 2018 If you want to apply GetAsNumber() to every item in the list individually, you must do exactly that: loop over the list, and convert each item to a number in turn. In a script, that would look like something like (untested, pseudocode): Set Variable [ $input ; List ( variante::taille ) ] Set Variable [ $n ; ValueCount ( $input ) ] Loop Set Variable [ $i ; $i + 1 ] Exit Loop If [ $i > $n ] Set Variable [ $output ; List ( $output ; GetAsNumber ( GetValue ( $input ; $i ) ) ) ] End Loop
ibobo Posted November 30, 2018 Author Posted November 30, 2018 thank you Comment , Have a great day ! 😀
Recommended Posts
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