February 28, 201411 yr Hello I am trying to find out how to change scripts to execute conditional on if a certain text exists in the current field. so If the current field contains the word "list" then perform script A but If the current field does not contain the word "list" then perform script B NOt sure how to do this I just need a script like this that will check for the existence of a word in the current field and if the above conditions are met to perform the appropriate script. Thank you
February 28, 201411 yr Try Set Variable($wordlist ; Substitute(YourField; " "; "¶") Set Variable($wordcount; ValueCount(FilterValues("list"; $wordlist)) # using $wordcount as a boolean (0 or blank is false, anything else is true) If[$wordcount] Perform Script ["Script A"] Else Perform Script["Script B"] End If
February 28, 201411 yr If the current field contains the word "list" then perform script A You could probably use the PatternCount() function here. Unless you really mean a word as a word - which would make it more complicated - see: http://www.briandunning.com/cf/1390 It's also not quite clear what you mean by "current field". If it's the active field (one that contains the cursor), then try something like: PatternCount ( Get ( ActiveFieldContents ) ; "list" ) as the test to determine which script to perform.
February 28, 201411 yr Author I tried both I need to give you an exact example I have URLS which are videos from youtube I have a problem because some links are with a playlist and some are not So I have to Leave the ones with the word "list" included in the URL alone --- Nothing needs to be changed (perform Script A) But if the word "list" IS included then ----perform script B here are the two example urls #---
February 28, 201411 yr The following text: https://www.youtube.com/watch?v=onRKOcsf1J0&list=PL64500D4CD7B835A4 does NOT contain the word "list". It does, however, contain the pattern "list" and that's why you need to use PatternCount(0 function. Note that the the longer the pattern, the less chances there are for a false positive - so you'd probably want to use "&list=" as the searchString parameter. I tried both ... So I am not sure what I am doing wrong Well, you didn't a say how you tried, and what were your results...
February 28, 201411 yr This seems like an additional need to one of your earlier post(s) on the web viewer, or open URL, etc. If this should have been posted to one of them and not a new topic. Let me know which topic you want me to merge this with.
March 1, 201411 yr The example you presented makes me think you're not conceptualizing it quite right. One button can only do one script -- are we talking about clicking a button? -- so you'll either have to have a Script C that branches to Script A or Script B, or just have a single script that handles both scenarios. A single script should be fine. Also, as an alternative to PatternCount: If[ Position( yourURLfield ; "&list=" ; 1 ; 1 ) ] // do the Script A steps here Else // do nothing? Script B steps here End If
Create an account or sign in to comment