Graphics

 View Only
  • 1.  Small scripting question

    Posted 02-14-2013 16:53
    I'm pulling headlines from an RSS feed for crawl. Almost all of the headlines have an image tag at the beginning of them, so I've set up a hidden text object to split the text and send just the headline info to a text object that's visible. The script is on the hidden text object and looks like this

    dim line as string

    dim segments(2) as string

    dim textobj as xpTextObject

    line = Replace(text, ">", ";")

    segments = Split(line, ";", 2)

    if Scene.GetObjectByName("Headline", textobj) then

    textobj.text = segments(1)

    end if

    How can I make this script conditional? If the headline has an image tag then it splits and if it doesn't have an image tag then it doesn't?


  • 2.  RE: Small scripting question

    Posted 02-14-2013 17:42
    Hi WDAY,

    You could check first if there is an image tag and only then execute your code. Otherwise it will take the entire string as a headline:

    dim line as string

    dim segments(2) as string

    dim textobj as xpTextObject

    If InStr(1, text, "") > 0 Then

    line = Replace(text, ">", ";")

    segments = Split(line, ";", 2)

    line = segments(1)

    else

    line = text

    end if

    if Scene.GetObjectByName("Headline", textobj) then

    textobj.text = line

    end if

    Ofcourse you need to replace the "" with your imagetag which is in the string.

    Is this what you were looking for?

    Best regards,

    Kenneth

    #XPression


  • 3.  RE: Small scripting question

    Posted 02-14-2013 17:55
    That was exactly what I was trying to do! Works like a charm. Thanks so much.

    #XPression


  • 4.  RE: Small scripting question

    Posted 02-14-2013 19:24
    You're most welcome!

    Is there a reason actually why you replace the > with ; ?

    Because otherwise you could split it directly on the > ?

    Best regards,

    Kenneth

    #XPression


  • 5.  RE: Small scripting question

    Posted 02-14-2013 22:38
    No, there wasn't a particular reason. I was just using a bit of script from another scene and just kept the format the same since I knew it worked. Thanks for the tip!

    #XPression