Skip to content

fb_name

mkraska edited this page Feb 19, 2024 · 3 revisions

[text, OK]: fb_name(n, i, lon)

  • OK boolean variable indicating pass of the test
  • text feedback text in case that the test is not passed.
  • n the meclib names list
  • i index of the object, which is replaced by the reaction
  • lon list of allowed names

If there are multiple reactions at object i the first one is checked.

fb_name(n,i,lon):=block([name,txt],
    name: none,
    if listp(n[i]) then
      if not emptyp(n[i]) then name: n[n[i][1]], 
    if member(name,lon) then return( ["",true]) else return([castext("\\({@name@} \\) ist kein passender Name für die Lagerreaktion."), false]) 
);

Feedback variables

Usage example: The reaction at object with index i_SB is checked. The only correct name is B.

obj: stackjson_parse(objects);
[text, isOK]: fb_unidir(obj, names, i_SB, "Pendelstütze B: ");
[textn, isOKn]: fb_name(names,i_SB,[B]);

Tryout Space

In order to try code snippets in jsfiddle,

  1. copy the code from the wiki page to the clipboard
  2. follow the link for the JSXGraph version you want to try
  3. Replace the code in the HTML section (contents of <p hidden id="init">) with the content of the clipboard
Clone this wiki locally