Announcement

Collapse
No announcement yet.

Printing an object (not the properties)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Printing an object (not the properties)

    L.S.,

    For testing purposes I want to print an object to the formula output window by the following code. I need to test this since I use several objects created by the same constructor function. It seems not possible to print the variable (the object); printing it's properties is no problem though.

    PHP Code:
    function Print(a) {
         
    debugPrintln("******************************************" "\n");
         for(
    i=0i<a.lengthi++) {
             
    debugPrintln("nieuwe Array " "[" "] : " a[i].Label1 " & "a[i].Label2 " & " a[i].Label3 " & " a[i].Dag() + " om " a[i].Tijd() + "\n");
         }

    Has anyone a solution for this? Or is it only possible by enlarging my constructor function with the line this.name = string? See code below.

    PHP Code:

    var = new Array();

    function 
    Object(..., string, ...) {
    ...
    this.name string
    ...
    }

    function 
    main() {
    ...
    var 
    temp = new Object(..., a, ...); //string = a
    a.unshift(temp); 
    ...


    Regards,
    Bart

  • #2
    a little help....

    The use of defining objects and using them in arrays is standard stuff.

    The string variables within your object should be dynamic - meaning they can/will hold strings of variant length. You should not need to re-define your object in order to accomplish this..

    for purposes of debugging, I suggest using the debugPrintln as you have shown. There is nothing yet that will beat it in efs.

    I do know others have used the trace functions for debugging - but I have not.

    When I use objects, I define them "on the fly" in the code...

    var vMyObj = new Object;
    debugPrintln("Added to Array = "+GBarIndex);
    // CheckForExistingLines();
    vMyObj .lBarNumber = BLBarOffset+GBarIndex;
    vMyObj .lActive = true;
    vMyObj .lType = "HIGH";
    vMyObj .lBase = high(GBarIndex);
    vMyObj .lLine1LevelOnOff = false;
    vMyObj .lLine2LevelOnOff = true;
    vMyObj .lLine3LevelOnOff = true;
    vLineArray.push(vMyObj );

    You appear to be defining the object in your code, thus potentially restricting the definition size. Try creating a generic OBJECT variable, then defining the contents of the object like I do.

    Best regards,

    B
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Brad,

      Thanks for your reply. What are "the trace functions"? Are those standard functions of which I am not aware of the existence?

      I already do use a generic object variable by addressing a constructor function. By calling this function in my code I fill it with the necessary properties. It is, however, not dynamic: every array has the same number of properties.

      Regards,
      Bart

      Comment


      • #4
        dynamic...

        correct... arrays or objects are not dynamic - I may have stated that wrong.

        But the information contained within the object is dynamic in the sense that you can store different length values in each container (item).

        for more info on TRACE - review this thread...

        Trace Debug Thread

        B
        Brad Matheny
        eSignal Solution Provider since 2000

        Comment


        • #5
          I thought that Javascript always allowed the storage of data with variable length in object properties and 'regular' variables (although there must be some kind of maximum in characters)?

          This trace.efs seems like a useful efs. I'll take a look at it. Thanks for the tip. This might also reduce some cpu usage, I guess.

          Bart

          Comment

          Working...
          X