How to set a piece of data to a variable

Is there a way to extract a piece of data from a website and then set it as a variable?
Ie grab a patients name or weight and then insert the name throughout a snipet. Or better yet, insert a weight into calculations?
I understand how to grab these pieces of info from the website, but how do I set them as usable variables?

Hi Geoff, it sounds like you are familiar with our {site} command.

To put the result of a {site} command in a variable, you can use a formula.

For example if you have:

{site: title}

And you want to put it in the variable title, you could use:

{title={site: title}}

These kinds of examples are largely missing from the documentation. The docs sort of explain what features exist, but they could really benefit from really basic examples. Such as this case, for working with variables:

  • What are the naming rules for variables?

  • Is there typing? If yes, which ones and how to assign variables of a certain type. If not, what are the gotchas (assigning '01' for instance)

  • How do variables interplay with the output of functions? (i.e. assign function return value to a variable)

  • Scoping rules

Really, the basics of language syntax found in any halfway decent starter book for any programming language in the first chapter on variables. Corresponding chapters typically are branching and looping (again, please with full syntax definition and copious examples of single, multiple and all kind of other variations of use). Ditto for lists: multiple ways to assign values to a lists in one go; syntax to add to ordered and unordered lists. Bits and pieces are documented, but there are lots of holes.

(possibly as an alternative, document what the underlying technology stack is, so you could maybe point to existing documentation for the particular language you seem to be wrapping)

Hi Peter,

Let me answer the specific questions you raise.

  • Basic variables names must start with a letter and then can contain any mixture of letters, numbers and underscores. If you have a variable that violates theses rules (e.g. it contains spaces) you can use it by enclosing it in backticks (e.g. "1 + `Variable with spaces`").
  • There are effectively no types, values are converted between types as necessary (e.g. 1 + "2" will evaluate to 3 where as 1 & "2" will evaluate to "12").
  • I don't understand this function question could you please expand on it?
  • In general there is one global scope. Exceptions to this include the {repeat} command which creates a separate scope for each iteration of the repeat, lambda functions which create a local scope for their parameters, and also some behavior of code blocks which are documented on the code blocks reference.

I hope this helps, we'll add some more documentation on these items. Let me know if you have other questions.