   /* ----------------------------------------------- */ 
   /* Functions for Print Screen                      */  
   /* Name space: printScreen                         */
   /* ----------------------------------------------- */ 

   printScreen :
   {
      // Window object
      win : "",

      run : function (){
        USERENV.printScreen.openWindow(
          USERENV.printScreen.win,
          USERENV.printScreen.getScreenData(), 
          USERENV.printScreen.printScreen
        );
      },


      /*
       * _CAO\ Open printer dialogue 
       * w... Window object
       */
      printScreen : function ( w ){
        w.print();
        w.close();
      },

      /*
       * WindowI[v֐ Open Window
       *   dspstr..... ʃf[^(sz) Display Data(Row Array)
       *   callback... R[obN֐ Callback function
       */
      openWindow : function ( w, dspstr, callback ){

        // Open window
        w = window.open( "", "printScreen", "scrollbars=yes,resizable=yes,width=924,height=400" );
        w.document.open();
  
        w.document.write("<html>");
        w.document.write("<head>");
        w.document.write("<title>aXesʈ</title>");
        w.document.write("</head>");
        w.document.write("<body>");
        w.document.write("<pre style='margin:0;padding:0;font-family:MS Gothic;font-size:14px;'>");
        for ( var i=0; i < 27; i++ ){
          w.document.write( dspstr[i] + "<br>" );
        }
        w.document.write("</pre>");
        w.document.write("</body>");
        w.document.write("</html>");
        w.document.close();
        callback(w);
      },

      /*
       * \Ăʂ̃eLXgf[^擾 Get current screen text data
       */
      getScreenData : function (){
        var ns = USERENV.printScreen;
        var lineBuf = "";
        var ary = [];
        for ( var i=1; i<=27; i++ ){
          /*
           * ʏsƂɏ
           */
          if ( AXES.currentForm.getElementsByRow(i) ){
            var aScreenElements = AXES.currentForm.getElementsByRow(i);
            /*
             * GgƂɏ
             */
            for ( var key in aScreenElements ) {
              var oElem = aScreenElements[key];
        
              lineBuf = lineBuf.replace(/\xA0/g," ");
              lineBuf = lineBuf.replace(/\s+$/,"");
              var len = ns.countLength( lineBuf );
        
              if ( oElem.getValue().trim() !== "" ){
                if ( len < oElem.column ){
                  for ( var j=0; j<(oElem.column - len ); j++ ){
                    lineBuf += " ";
                  }
                  lineBuf += oElem.getValue();
                }else if ( len >= oElem.column ){
                  // NOP(Column|WVœl݂ꍇ)XHRRPGTRNeʂŊmF\
                }else{
                  lineBuf += oElem.getValue();
                }
              }
            }
          }else{
            lineBuf = "";
          }
          //z1s̕push
          ary.push( lineBuf );
          lineBuf = "";
        }
        return( ary );
      },

      /*
       * oCgJEg Count byte length
       */
      countLength : function ( str ) { 
        var r = 0; 
        for (var i = 0; i < str.length; i++) { 
          var c = str.charCodeAt(i); 
          /*
           * Shift_JIS: 0x0 ` 0x80, 0xa0 , 0xa1 ` 0xdf , 0xfd ` 0xff 
           * Unicode : 0x0 ` 0x80, 0xf8f0, 0xff61 ` 0xff9f, 0xf8f1 ` 0xf8f3
           */ 
          if ( (c >= 0x0 && c < 0x81) || (c == 0xf8f0) || (c >= 0xff61 && c < 0xffa0) || (c >= 0xf8f1 && c < 0xf8f4)) { 
            r += 1; 
          } else { 
            r += 2; 
          } 
        } 
        return( r ); 
      },
   },

