Feature Update – *progress, *chart, *repeat, and more!
ChartsCharts provide eye candy for your users. Here’s a sample of how they currently look: 1. *chart: You’ll need to type in the *chart keyword and optionally provide a title (e.g. “*chart: My Chart”). 2. *type: You’ll need to define what kind of chart you’d like to plot. For now, we’ll only have “bar“, but we envision adding many other types in the future. 3. *data: You’ll need to provide the data to chart. The data you enter will always be in [square brackets]. Now let’s talk about this square brackets business. Anything in [square brackets] is considered a “collection” and is simply a collection of multiple smaller things. Collections in GuidedTrack are defined as a list of numbers, strings, variables, other collections between square brackets, or a combination of these things. Basic Way to Add DataTo illustrate a collection and how to use it we’ll start with the most basic way you can add data to your chart. The above program will display a bar chart that looks like this: Let’s return to the GuidedTrack code so we can take a look at how collections are used.
Using Simple Variables with *dataLook how our previous code could change if we instead used a couple variables in our data.
For a refresher on variables, check out Introduction to GuidedTrack. Using a Variable of a Collection with *dataWe could also use more complex variables in our data. Check out this example now. It produces the exact same chart. Using a Variable of a Collection of Collections with *dataOne final example: Now you’ve seen three ways to use variables with the *data keyword. You can mix and match all different types of variables or non-variables to produce your charts in a way that is most convenient for you. |
The *while KeywordThe *while keyword is the same as *repeat, except that it allows the author to determine how many times to execute the code dynamically. So, instead of repeating something a specified number of times, it repeats it eternally *while a given condition is being met. Let’s illustrate that with an example:
As soon as the user guesses “Rumpelstiltskin” (with appropriate caps and spelling), they will finally break free from this cycle and will at last be told they won the money. So how does this work? The program will execute the code indented beneath *while so long as the variable “answer” is still being defined as the string “wrong”. As an editor, you must create some kind of condition in which the value of that variable could potentially change so the user can continue on with the program. Remember that with *type: text questions, the user is presented with a box in which to write an answer, but as an editor you can also create customized content for specific answers they could potentially write. We created customized content for the answer “Rumpelstiltskin” as well as anything *other than “Rumpelstiltskin”. Only if the user writes “Rumpelstiltskin” would the content >>answer = “correct” be activated by the user. Once that happens, this would change the variable “answer” from “wrong” to “correct”. Only while “answer” is “wrong” would the question repeat. (Note: instead of re-defining “answer” as “correct” we could have also written “you got it”, “bingo” “183847438”. So long as “answer” was anything other than “wrong”, the cycle of questions would end). We’ll illustrate another example in the next section on the *clear keyword. |
Upgrades for the *clear KeywordPreviously, a *clear keyword cleared the screen of maintained text (text that is held constant at the top of the page with the *maintain keyword). Whenever a *clear keyword was used, there was also some sort of page break, and the clear occurred on the new screen. For example, when there was a question preceding the *clear keyword, the question caused a page break and the new screen was cleared of the maintained text. When there was text preceding a *clear keyword, then the *clear keyword also created a button that said “Next.” The button produced a page break and the very next screen was cleared of the maintained text. Now, the *clear keyword NO LONGER produces a button that says “Next” when preceded by text. Program writers now have to manually create a “Next” button by adding the code: “*button: Next” before any *clear keywords that are preceded by text. This code is not necessary for *clear keywords preceded by questions. In other words, the *clear keyword no longer forces a button to occur. This change was made to allow for exciting new elements in GuidedTrack. You are now able to *clear the entire screen of anything on it, not just maintained text! For example, you can have a program like this:
In this sample program, once the timer is up the instructions and the image is cleared from the screen and the user only sees the question, “Where was the cow?” With this new change, the user does not have to click any “Next” buttons in order to see the question.
Note: Without the *wait keyword in place in this sample program, the user would not ever see the instructions and image as the clear would occur immediately. The user would only see the question. Similarly, maintained text will be cleared as soon as the user reaches a screen with a *clear keyword (assuming there’s no *wait keyword). In most cases when you need to clear maintained text, you’ll want the *clear keyword to be the first thing on a new screen, by preceding it with a *question or a *button. Now here’s another example, using the *wait keyword:
In the last section, we talked about how the *while keyword works. Here, *while the variable “seconds” is greater than the number 0, the indented content will repeat indefinitely. We know the content won’t repeat indefinitely though, because the “seconds” variable is slowly decreasing by 1 each time the program passes this line: >>seconds = seconds – 1. And it passes this line exactly 10 times, until “seconds” = 0 and the *while keyword no longer kicks in. That’s when users will see “Blast off!”. Here’s how the *clear keyword comes into play. Without it, the user’s screen would begin to look something like this: |