Graphics

 View Only
  • 1.  Scripting

    Posted 06-06-2013 15:59
    I have a simple stock report that I am airing.

    What I would like to do is have a script look in to a data file and if the stock is up

    I want to display an up arrow and so forth.

    How would I script this?

    The graphic in question is reading a text file through the datalinq server.


  • 2.  RE: Scripting

    Posted 06-06-2013 21:03
    Do you have a value that shows the change? For example, if the Dow is down from 10,000 to 9,000, is there a value that says "-1,000?" And on the opposite, if it goes from 10,000 to 11,000, a value saying "1,000?"

    I ask because then you could use that value as an integer for scripting purposes.

    Example:

    dim Arrow as xpBaseObject

    dim ChangeValue as xpTextObject

    dim ChangeValueInt as Integer

    Self.GetObjectByName("Arrow", Arrow)

    if Self.GetObjectByName("ChangeValue", ChangeValue) then

    ChangeValueInt=Cint(ChangeValue.Text)

    end if

    if ChangeValueInt > 0 then

    Arrow.ScaleY = Math.Abs(Arrow.ScaleY)

    elseif ChangeValueInt < 0 then

    Arrow.ScaleY = -(Arrow.ScaleY)

    elseif ChangeValueInt = 0 then

    Arrow.Alpha = 0

    end if


    This would point your object "Arrow" in a positive direction (absolute value of it's scale) if it's above zero, in a negative direction (scale * (-1)) if it's below zero, and make it invisible (removing all alpha) if it is equal to zero.

    Now that I look at the script, I could probably write it a little cleaner, but that's a good roughing.

    Without a "change value," it's a bit different to figure out, unless you have the previous amount to compare it against.

    #XPression


  • 3.  RE: Scripting

    Posted 06-07-2013 12:54
    I do have a "change value" field in my data file.

    How would I define the "change value" in the data file in order for the script to read it?

    Also, would I have to loop the if statement in order to display multiple stock quotes? For example, if I have 11 quotes

    do I need to loop the if statement 11 times and if so how do I script the loop?

    #XPression


  • 4.  RE: Scripting

    Posted 06-13-2013 15:34
    You would need to datalinq your change value into a text field in your scene. You can incorporate it into your graphics, or just turn the visibility off in order to hide it.

    You would need to loop it. So let's say you have 5 indexes on screen at once. You would need "Arrow1" through "Arrow5," and "ChangeVal1" through ChangeVal5." Then write your script:

    dim chng as xpTextObject

    dim arrow as xpBaseObject

    dim cv as Integer

    dim i as Integer

    for i = 1 to 5

    if Self.GetObjectByName("ChangeVal" & i, chng) then

    cv=Cint(chng.Text)

    end if

    Self.GetObjectByName("Arrow" & i, arrow)

    if cv > 0 then

    Arrow.ScaleY = Math.Abs(Arrow.ScaleY)

    elseif cv < 0 then

    Arrow.ScaleY = -(Arrow.ScaleY)

    elseif cv = 0 then

    Arrow.Alpha = 0

    end if

    next i


    EDIT: I accidentally a whole letter.

    #XPression


  • 5.  RE: Scripting

    Posted 06-20-2013 18:18
    thanks for your help on this! I used an Mix of code from this post and another post to achieve positive results!

    I'll post my scripting soon!

    Again Thanks!

    #XPression