fb_name - mkraska/meclib GitHub Wiki

[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]);