[BLACKBOX] output with GP-CP

From: VDI <bernhardt.gunnar{([at]})nowhere.xy>
Date: Fri, 22 Oct 2010 11:51:01 +0200

----boundary-LibPST-iamunique-127378217_-_-
Content-type: text/plain

Dear all,

perhaps I'm overreacting but I find it rather hard to do string
 conversion and output in Gardens Point CP.

Here is what I wanted to do (please do not be offended by the C#
 source code):

/* -------- BEGIN example 1 --------- */
private class XmlValidationHandler
{
    public int intErr;
    public void ValidationCallBack(object sender, ValidationEventArgs
 args)
    {
        this.intErr += 1;
        XmlSchemaException excErr = args.Exception;
        System.Console.WriteLine("- ->{0} at {1} ({2},{3})",
 args.Severity, excErr.SourceUri, excErr.LineNumber,
 excErr.LinePosition); // the interesting part
        System.Console.WriteLine(" ->" + args.Message);
        System.Console.WriteLine("-------------------------------");
    }
}
/* -------- END example 1 --------- */


Please note that Console.WriteLine( string, object, object, object,
 object ) is an ordinary function in the .NET-library.
Since in .NET each "object" - even value types like int and char -
 posseses a .ToString() method, WriteLine() simply converts all
 parameters to string and maps them into the spots marked with {i}.

Note as well that for enumerations like args.Severity not the integer
 value will be displayed but the associated name (in this case "Error"
 instead of "0").

Calling WriteLine like this from CP does not work, perhaps since it
 does not regard INT as an "object"?

Creating an object by e.g. BOX(args.Severity) is not possible, since
 this can only be done for RECORDs.

The standard libraries that come with GP-CP do neither provide a
 mapping function for Strings (like BB) nor a conversion from INTEGER
 to ARRAY OF CHAR.

So what I ended up with was this:

(* -------- BEGIN example 2 --------- *)
IMPORT
  System := mscorlib_System,
  System_Xml := System_Xml_,
  System_Xml_Schema := System_Xml__Schema,
  Console;


PROCEDURE ( this: XmlValidationHandler ) HandleError( sender:
 System.Object; args: System_Xml_Schema.ValidationEventArgs ),NEW;
VAR
  excErr: System_Xml_Schema.XmlSchemaException;
BEGIN
  INC( this.ErrorCount );
  excErr := args.get_Exception();
  (* ---- BEGIN the ugly bit ---- *)
  Console.WriteString( "- ->" );
  IF args.get_Severity() = System_Xml_Schema.XmlSeverityType.Error
 THEN
    Console.WriteString( "Error" )
  ELSE
    Console.WriteString( "Warning" )
  END;
  Console.WriteString( " at " + excErr.get_SourceUri() + " (" );
  Console.WriteInt( excErr.get_LineNumber(), -1 );
  Console.WriteString( "," );
  Console.WriteInt( excErr.get_LinePosition(), -1 );
  Console.WriteString( ")" ); Console.WriteLn();
  (* ---- END the ugly bit ---- *)
  (* *)
  Console.WriteString( " ->" + args.get_Message() );
 Console.WriteLn();
  (* *)
  Console.WriteString( "-------------------------------" );
 Console.WriteLn();
END HandleError;
(* -------- END example 2 --------- *)

Apart from the additional space (which I would not mind) the output
 format "- ->{0} at {1} ({2},{3})" has here been split into several
 lines of code, which makes it a lot harder to read in my opinion.


Did I miss something obvious?
Can you perhaps think of a solution more elegant?


kind regards
gunnar


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-127378217_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIERlYXIgYWxsLFxwYXINClxwYXINCnBlcmhhcHMg
SSdtIG92ZXJyZWFjdGluZyBidXQgSSBmaW5kIGl0IHJhdGhlciBoYXJkIHRvIGRvIHN0cmluZ1xw
YXINCiBjb252ZXJzaW9uIGFuZCBvdXRwdXQgaW4gR2FyZGVucyBQb2ludCBDUC5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aCBJ
IHdvdWxkIG5vdCBtaW5kKSB0aGUgb3V0cHV0XHBhcg0KIGZvcm1hdCAiLSAtPlx7MFx9IGF0IFx7
MVx9IChcezJcfSxcezNcfSkiIGhhcyBoZXJlIGJlZW4gc3BsaXQgaW50byBzZXZlcmFsXHBhcg0K
IGxpbmVzIG9mIGNvZGUsIHdoaWNoIG1ha2VzIGl0IGEgbG90IGhhcmRlciB0byByZWFkIGluIG15
IG9waW5pb24uXHBhcg0KXHBhcg0KXHBhcg0KRGlkIEkgbWlzcyBzb21ldGhpbmcgb2J2aW91cz9c
cGFyDQpDYW4geW91IHBlcmhhcHMgdGhpbmsgb2YgYSBzb2x1dGlvbiBtb3JlIGVsZWdhbnQ/XHBh
cg0KXHBhcg0KXHBhcg0Ka2luZCByZWdhcmRzXHBhcg0KZ3VubmFyXHBhcg0KXHBhcg0KXHBhcg0K
LS0tLVxwYXINClRvIHVuc3Vic2NyaWJlLCBzZW5kIGEgbWVzc2FnZSB3aXRoIGJvZHkgIlNJR05P
RkYgQkxBQ0tCT1giIHRvIExJU1RTRVJWQExJU1RTLk9CRVJPTi5DSH19AFQuIEE=
----boundary-LibPST-iamunique-127378217_-_---
Received on Fri Oct 22 2010 - 11:51:01 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:29 UTC