Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Substitute / Delete values Feeded by List

Featured Replies

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

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.

  • Author

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 

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.

  • Author

thank you, but I think something is wrong because it doesn't stop looping ? 

here is the attached file

title_sub.fmp12

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 by comment

  • Author

it works perfectly well !! thank you Comment ☺️

  • Author

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

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?

  • Author

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

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?

  • Author

 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

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

 

  • Author

thank you Comment ,

Have a great day ! 😀

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.