hartmut Posted February 28, 2014 Posted February 28, 2014 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
doughemi Posted February 28, 2014 Posted February 28, 2014 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
comment Posted February 28, 2014 Posted February 28, 2014 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.
hartmut Posted February 28, 2014 Author Posted February 28, 2014 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 #---
comment Posted February 28, 2014 Posted February 28, 2014 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...
Lee Smith Posted February 28, 2014 Posted February 28, 2014 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.
Fitch Posted March 1, 2014 Posted March 1, 2014 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
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