As an old neophyte trying to write my first class, I have finally succeeded but with several issues.
I found first that there is very little in the help or at ClarionLive that say much explicitly about return values. Things i learned:
In the .Inc file only the type of returned data is required - not a name.
In the .clw file the declaration requires nothing about the return value.
I did not know that each method could have its own local data - e.g., the returned value.
The oddest thing, however, is that in the .clw file building insisted that the definition should be
NameofMethod Procedure(ClassName, Real X, Real Y)
Without the ClassName errors occur telling me, “prototype is: Name(ClassName,Real,Real).” When I add the Class Name there no errors and it runs but there are warnings about, "Label duplicated, second used: ClassName.
What am I missing?
1 Like
You are missing SELF before the ClassName. In the .Clw you can declare a procedure 2 ways:
NameofMethod Procedure(ClassName SELF, Real X, Real Y) ! #1 <-- note SELF added
More common way.
ClassName.NameofMethod Procedure(Real X, Real Y) ! #2 <-- note "ClassName." added in column 1
Look at AB classes in LibSrc for examples, e.g. ABUtil.Inc and .Clw.
Note the Return value is not in the CLW. Its just the way the syntax works. Probably because it does not affect the “Procedure Signature” that makes it unique for overloading. It is somewhat of an annoyance as often I copy/paste that line and forget to remove the return type.
See the Class Name “FieldPairsClass” in column 1 plus Dot and Method name:
I’d suggest read the Help on Class and Module.
2 Likes
Ah ha! My failure to prefix the method name with the class name was a HUGE oversight. Thanks for very clearly and very rapidly correcting me.