fb_force_hvxy - mkraska/meclib GitHub Wiki
Detailled feedback for "force" names. The following checks are done until the first one fails:
- Basename consists of a single character?
- Is there a direction index?
- Is the index a single character?
- Is the index one of x, y, h(orizontal), v(ertical)?
- Does the index match the actual direction?
The function is used by fb_fix123_names()
, see Feedback for "fix123"
Example question: FBD Tutorial Einspannung (I) at abacus.aalto.fi/develop/4.4beta
[txt, isOK]: fb_force_hvxy(o,i):
-
txt
feedback text -
isOK
boolean to indicate all checks passed -
o
list of objects -
i
index of the force in the list of objects
fb_force_hvxy(o,i):=block([dir, name, nl, base, idx],
name: o[i][2], nl: split(name,"_"),
/* base name single character? */
if slength(first(nl)) > 1
then return([sconcat("\\(", name, "\\): Physikalische Größen immer nur mit einem Buchstabe und eventuell Index schreiben, z.B. <code>F_1</code>." ),false]),
/* is there an index? */
if length(nl) # 2
then return([sconcat("\\(", name, "\\) sollte einen Richtungsindex (x, y, h, v) haben."),false]),
/* are name and index just a single character? */
idx: last(nl),
if slength(idx) > 1
then return([sconcat("\\(", name, "\\): Ein Buchstabe sollte für den Index reichen." ),false]),
/* is the index known? */
if not member(sdowncase(idx), ["h","v","x","y"])
then return([sconcat("\\(", name, "\\): Der Richtungsindex sollte h, v, x oder y sein"),false]),
/* check directions */
dir: direction(o[i]),
if (sdowncase(idx)="h" and abs(dir[2]) > 0.01) then
return([sconcat("\\(", name, "\\) müsste eine horizontale Kraft bezeichnen."),false]),
if (sdowncase(idx)="v" and abs(dir[1]) > 0.01) then
return([sconcat("\\(", name, "\\) müsste eine vertikale Kraft bezeichnen."),false]),
if (sdowncase(idx)="x" and (abs(dir[2]) > 0.01 or dir[1] <0) ) then
return([sconcat("\\(", name, "\\) müsste eine Kraft in positive x-Richtung (nach rechts) bezeichnen."),false]),
if (sdowncase(idx)="y" and (abs(dir[1]) > 0.01 or dir[2] <0) ) then
return([sconcat("\\(", name, "\\) müsste eine Kraft in positive y-Richtung (nach oben) bezeichnen."),false]),
/* Name is ok */
return(["",true])
);