Variables - Save as Library Object - Is This Possible

txlady
txlady Community Member Posts: 101 ☆ Roadie ☆
Is is possible to save a Variable as a library object to use across multiple titles?  I can't seem to find where I can do that.  I keep having to create the same variable over and over.

Comments

  • klaatu
    klaatu Community Member Posts: 988
    I don't think it's possible with a library object per se, however,  if you find that you have multiple variables that you use a lot I can think of 2 ways to get them into a new project without having to go through the Tools interface.

    Method 1. Create all the variables and then save the project as a template.

    Method 2. Edit the .awt file to add your own pre-built variables in Lectora's xml format. Explained below. Before you say it's too difficult, try it, it's easier than it seems and will save you a ton of time of you do not want to go the template route.

    Create the XML for the variables in something like notepad.  Note in the example below I explained the tags in parentheses, do not include the explanations. It follows this format:

    <variabledata> (This is the opening tag)
    <variable id="901"> (This is the opening variable tag and includes the id attribute. Every variable needs a unique id. I suggest starting at 900)
    <name>student1</name> (The variable names goes between the name tags)
    <initialvalue>Brad Pitt</initialvalue> (The initial Value)
    </variable> (This closes the variable)
    <variable id="902">
    <name>student2</name>
    <initialvalue>Angelina Jolie</initialvalue>
    </variable>
    <variable id="903">
    <name>student3</name>
    <initialvalue>Blake Lively</initialvalue>
    </variable>
    <variable id="904">
    <name>student4</name>
    <initialvalue>Ryan Reynolds</initialvalue>
    </variable>
    </variabledata>

    1. Open a new project do nothing but name it, save and close. Open the .awt file with a text editor (like notepad).
    2. Normally variables are found between <variabledata> & </ variabledata> tags however since this project does not have any variables yet you will only find a single tag <variabledata /> (Notice the slash / is after the word variabledata in this empty tag).
    3. Copy your xml, highlight the <variabledata /> line and paste your code over it. Save the .awt and close.
    4. If you followed these steps correctly, when you open the .awt in lectora and look in Tools - Variables you should see all your newly added variables. Use normally.

    DRS
  • ssneg
    ssneg Community Member Posts: 1,466 ☆ Roadie ☆
    I think if you create an External HTML Object and attach variables to it (make them required), you can save the Ext HTML object as a library object and it will carry the variables with it.
  • sirwise23
    sirwise23 Community Member Posts: 442 ☆ Roadie ☆
    Sergey is correct from what I recall.

    If you create an empty text block and attach actions to it that touch that variable, you can save that object to the library.

    If you insert that object it will create all the variables it touches as well.
  • klaatu
    klaatu Community Member Posts: 988
    If either of you can get that to work, please post an example. I've tried many variations with no success.
  • txlady
    txlady Community Member Posts: 101 ☆ Roadie ☆
    Wow!  I got the experts on this one.  I'm impressed.  I will try the object with the variables attached first as it will be easiest.  I will be using it today and see if it works.  If not - I'll go with the XML version.  In reading it, I can see it's not difficult - just looks worse than it is.

    Thank you everyone who weighed in!
  • sirwise23
    sirwise23 Community Member Posts: 442 ☆ Roadie ☆
    Attached is a video of this working.
  • txlady
    txlady Community Member Posts: 101 ☆ Roadie ☆
    Well I'll be darned.  Great idea!  I had just opened Lectora to start my project and try it.  I watched your video.  Wonderful!  There are so many really smart people out here to help people like me look better than we really are.  Thank you so much!  I love this community!!
  • klaatu
    klaatu Community Member Posts: 988
    Awesome, Lazaro! Thank you so much for the post. When I copied what yo did it worked perfectly. LOL, I spent about two hours trying different combos of html extension objects, text boxes, required variables, etc.. nothing worked. I still have no idea what I was doing wrong but with your (and credit to Sergey too) help all is good.