Stupid user mistakes - HiStructClient/femcad-doc GitHub Wiki
This extraordinary article describes the most commonly did mistakes in the code that took me SOOOOOOO long to debug. Blame me and my blind eyes:-) However, there might me someone who - based on reading this - can avoid doing the same stupid mistakes...
Chapter one: unwanted space
Quite often, there is a stupid typo of writing far too extra space in parser. The worst thing is that this can be hardly spotted when reading the code. And FemCad keeps writing you that there is some bracket missing, for example. Until you realise that the problém lies in something "invisible". Try to find the problem on the first sight in the following code (lucky you that you know you can expect it there)
ColumnSegments := [
{profile = "base", count := 1, isPrismatic := [True], minL := anyLength, maxL:= noLimit},
{profile := "rectangle", count := 2, isPrismatic := [True, False], minL := 2, maxL := noLimit },
{profile := "hot rolled", count: = 1, isPrismatic := [True], minL := anyLength, maxL := noLimit}
]
Yes, it is in the last row -> "count : = 1"
But could someone told me this to save my half an hour? :-)
Chapter two: missing comma
Another frequent error is missing comma separating array items. This happens usualy when I add extra indented row in undater of something. FemCad expect some bracket, again. But adding this silly timy character solves the problem right away.
ColumnAssy := res.f.EnumerableRange(columnCount).Select( eb =>
__res.comp.simpleBeamClass{
____Parts := [res.comp.simpleBeamPartClass{
____Section := columnSectionFront,
____Length := columnEdges[eb].length,
____Alignment := CssAlignment.None
____dEndCutAngle := {Ry := cutAngleColumn[eb], Rz := 0},
____dOverlapEnd := overlapEndColumn[eb]}],
__Lcs := (columnEdges[eb].Lcs)#.Rx(lcsRotation[eb])
})
Praise you! The missing one is in "Alignment" row. Stupid one, isn't it?
Chapter three: brackets
Well known and repeated problem is, of course, brackets of any types. However, my scripting suffer from such mistakes especially when using ternary operator. Can someone easily orientate in the following example?
overlapEndColumn := colPositionsX.Select (oc =>
(roofType == 0)?(-rafterSectionFront.h/2/Cos(Abs(slopeLeft)))
:((oc < widthToRidge)?(-rafterSectionFront.h/2/Cos(Abs(slopeLeft))):(-rafterSectionFront.h/2/Cos(Abs(slopeRight))))
)
Good bless Notepad++ which can highlight the couple of brackets that belong to each other! Note: there is no missing bracket in the above code lines, unexpectedly ;-)
Chapter four: updated or not updated inputs?
One of the key features of FemCad is updater - I mean that you use another *.fcs file, update inputs and take some outputs in return. It happens, time to time, that I make mistake in what is updated or not and expect results from with updated inputs. But I receive result for the defaults.
Example - the input of geometry in Edge.fcs:
#### GEOMETRY
coorsHead := [ 0, 0, 0 ]
vertexHead := res.f.coorsToVertex( coorsHead )
pointHead := vertexHead.Point
Sometimes I requested coordinates from Edges and expected that they are updated. But intead, vertexes were used for update and I received just the defaults 0,0,0.
Chapter five - comma at the end of parser
This mistake rarely happens when you type new code, but is likely to appear in case you copy-paste a line, from updater for example. Basically, in case there is a comma at the end of parser line, FemCad takes this as TupleObject - something like one item of a dynamic object wihtout any specification. You can identify it when you print the variable:
a := [0,1,2,3,4],
print a = {[0,1,2,3,4]}
print a.GetType() = FCS.Core.Runtime.TupleObject
Such array is therefore not an array any more. Conclusion - pay attention when you copy-paste!