Explore the community Forums Lectora Lectora Questions & Answers Adding numeric variables in Lectora

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #390736 Score: 0
    Profile photo of Jeffry Gordon
    Jeffry Gordon
    Member
    beginner
    intermediate
    lab member
    LUC16
    LUC16 Attendee
    LUC17 Attendee
    curious george
    wise owl
    1 pt
    @tekprof

    I must be missing something simple. I have two variables I want to add to generate the contents of a 3rd variable….. so I have V1, V2, and V3. I want V3=V1+V2   I can see how to add constants, I don’t see how to add numeric variables. I assume all variables are string, do I have to convert them some way to numeric?

    #390745 Score: 0
    Profile photo of Erica Hunter
    Erica Hunter
    Member
    beginner
    intermediate
    verified member
    contributor
    curious george
    wise owl
    LUC16 Attendee
    LUC16
    3 pts
    @beeps

    Using the examples you have…

    Under modify variable, set target as V3

    type: set equal to

    value: VAR(v1) + VAR(v2)

    So when V3 is modified, it will take the value of V1 and V2 added together.

    In the Value field, click on the little grey box with an arrow in the right lower corner. This will open a window that will let you put the formula you want together quickly.

    Hope that helps!

    #390760 Score: 0
    Profile photo of Jeffry Gordon
    Jeffry Gordon
    Member
    beginner
    intermediate
    lab member
    LUC16
    LUC16 Attendee
    LUC17 Attendee
    curious george
    wise owl
    1 pt
    @tekprof

    That is getting me very close thank you……but if v1=2 and v2=5 instead of giving me 7 it displays 2+5 …so somehow I need to convert that from string to numeric.

    #390784 Score: 0
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    355 pts
    @timk

    You can try the classical way:

    Action: Modify variable

    Target: v3

    Type: Set equal to

    Value: VAR(v1)

    <hr />

    Action: Modify variable

    Target: v3

    Type: Add to variable

    Value: VAR(v2)

    #390823 Score: 0
    Profile photo of Erica Hunter
    Erica Hunter
    Member
    beginner
    intermediate
    verified member
    contributor
    curious george
    wise owl
    LUC16 Attendee
    LUC16
    3 pts
    @beeps

    Ha! Sorry–totally spaced on that. Good that Tim knows what’s up for reals.

    On a positive note, if you ever need to string things together now you know how 🙂

    #390867 Score: 0
    Profile photo of Jeffry Gordon
    Jeffry Gordon
    Member
    beginner
    intermediate
    lab member
    LUC16
    LUC16 Attendee
    LUC17 Attendee
    curious george
    wise owl
    1 pt
    @tekprof

    Thank you, both of you, Erica and Tim, that did it. I forgot that all math ops are binary and must be done in individual actions. I had hoped I could do a math op in the value box but evidently you cannot.

    This is kind of sucky though..my actual formula was nastier, something like A+B*C+D*E, and I didn’t want the original results of A, C, and E destroyed.  I then had to create 2 new variables: prodBC and prodDE.

    Now I had to create an action to make prodBC=C and another action to make prodDE=E

    Then I had to create a new action to make prodBC*B and another to make prodDE*D

    I then had to add things two at a time. I created a new variable TOTALscore and then created an action that made that equal to A. I then created a new action to take TOTALscore and add to it prodBC. I then had to make a final action to take TOTALscore and add it to prodDE.

    This is just nasty.  I ought to have a single line where I can put  in the var names (surrounded each by VAR and parens and have it then interpret that result.

    #390871 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    209 pts
    @Klaatu

    Why not just use JavaScript?

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.