Names Default To Here( 1 ); Clear Log(); Clear Globals(); Clear Symbols(); If( Host is( "Windows" ), , Throw() ); // (jmp for windows only) // Include( "j2f_Include.jsl" ); // Contains WINAPI & j2fAPI definitions // june 2020 version (c) 2020 Franco Anzani - SixSigmaIn Team snc Include( "j2f_Demo_msg.jsl" ); // Contains this demo txt messages Title = "< Vector Data Exchange : more Clients >"; // // More Clients Example --------------------------------------------------------------------------------- Test_max_Isize = 1000; // 1.000.000 vector size Excel limit iExcel = 1; // first Client iMinitab = 2; // second Client Test_show_MsgBox = 1; // 0 or 1 Test_Client_as_hide = 0; // client in hidden mode // // - Start Host --------------------------------------------- If( Init_message( Title ) == 2, Stop() ); meHost = Create_Me(); If( meHost == _%false, Throw() ); // create jsl (jmp) as host , exit on error // // - Create data --------------------------------------------- c_Els = Char( Test_max_Isize ); d_Base = 0; jN_data = J( Test_max_Isize, 1, Random Integer( 1, 2147483646 ) ); jD_data = J( Test_max_Isize, 1, ); jS_data = {}; For( iLoop = 1, iLoop <= Test_max_Isize, iLoop++, jD_data[iLoop] = d_base + 3600 * (iLoop - 1); //60 or 3600 // Note: Minitab has a limit managing datetime > 31/12/4000, therefore date higher than this value will be transformed into missing values jS_data[iLoop] = "char_" || Char( iLoop ); ); // // - Create a table ----------------------------------------------------- rnd_dt = New Table( "Temp", New Column( "asNum", Numeric, Continuous, Set Values( jN_data ) ) ); rnd_dt << New Column( "asDate", Numeric, Continuous, Format( "d/m/y h:m" ), Set Values( jD_data ) ); rnd_dt << New Column( "asChar", Character ); rnd_dt:asChar << set each value( jS_data[Row()] ); // // - Start Client(s) ---------------------------------------------------- If( Test_Client_as_hide, c_mode = _$as_hide; test_show_MsgBox = 0; , c_mode = _$as_view ); MessageBox_fn( Concat( "The table with ", c_Els, " Random Data is ready. Press Ok to start the Clients." ), _%bt_Ok ); New_Client( meHost, iExcel, "mte_CRT.exe", "excel.application", c_mode ); New_Client( meHost, iMinitab, "mte_CRT.exe", "mtb.application", c_mode ); // // - Send Data to Client(s) ---------------------------------------------- If( test_show_MsgBox, MessageBox_fn( "Now send JMP Columns Data to the Clients", _%bt_Ok ) ); jCol = Create_Numeric_Column_Ref( _%mtE_fmx_Long4, jN_data ); To_Client_As_Column_Num( _%mtE_fmx_Long4, jCol, iExcel, 1 ); // 1=A To_Client_As_Column_Num( _%mtE_fmx_Long4, jCol, iMinitab, 1 ); // 1=C1 Clean_Column_Ref( jCol ); // jCol = Create_Datetime_Column_Ref( jD_data ); To_Client_As_Column_DT( jCol, iExcel, 2 ); // 2=B To_Client_As_Column_DT( jCol, iMinitab, 2 ); // 2=C2 Clean_Column_Ref( jCol ); // jCol = Create_String_Column_Ref( jS_data ); To_Client_As_Column_String( jCol, iExcel, 3 ); // 3=C To_Client_As_Column_String( jCol, iMinitab, 3 ); // 3=C3 Clean_Column_Ref( jCol ); // // - Add new Columns Data to Client(s) --------------------------------------------- n_RC = "=-RC[-3]"; d_RC = "=RC[-3] + 3600"; s_RC = "=PROPER(RC[-3])"; x_code = Concat( "With ", _$ObjApp, _$crlf, // ------------------------------------------------ ".Range(", _$dq, "D1:D", c_Els, _$dq, ").FormulaR1C1 = ", _$dq, n_RC, _$dq, _$crlf, //-------------------------------------------------- ".Range(", _$dq, "E1:E", c_Els, _$dq, ").FormulaR1C1 = ", _$dq, d_RC, _$dq, _$crlf, ".Columns(", _$dq, "E:E", _$dq, ").EntireColumn.AutoFit", _$crlf, //-------------------------------------- ".Range(", _$dq, "F1:F", c_Els, _$dq, ").FormulaR1C1 = ", _$dq, s_RC, _$dq, _$crlf, //---------------------------------- "End With" ); m_code = Concat( "Let C4 = C1 -1", _$crlf, "Let C5 = C2 +1800. Date C5 C5.FDate/Time C5;Format(1dt", _$dq, "dd/mm/yyyy hh:mm", _$Dq, ").", _$crlf, "Let C6 = UPPER(C3)" ); // If( test_show_MsgBox, MessageBox_fn( Concat( "Send these commands to Clients to create new columns Data :", _$crlf, _$crlf, x_code, _$crlf, _$crlf, "and ..", _$crlf, _$crlf, m_code, _$crlf, _$crlf, _$crlf, "[ That is, it is equivalent to simulating a calculation, an operation, a model, .. which must necessarily be performed only in the Client environment, outside JMP/jsl environment. ]", ), _%bt_Ok ) ); To_Client_As_Client_Code( iExcel, x_code ); To_Client_As_Client_Code( iMinitab, m_code ); // // - Get Client(s) new Columns Data ---------------------------------------------- If( test_show_MsgBox, MessageBox_fn( "Now get Clients new columns data and put them on JMP Table", _%bt_Ok ) ); x_cN_data = Get_Client_as_Numeric_Column( iExcel, "D1:D" || c_Els ); x_cD_data = Get_Client_as_DateTime_Column( iExcel, "E1:E" || c_Els ); x_cS_data = Get_Client_as_String_Column( iExcel, "F1:F" || c_Els ); // m_cN_data = Get_Client_as_Numeric_Column( iMinitab, "C4" ); m_cD_data = Get_Client_as_DateTime_Column( iMinitab, "C5" ); m_cS_data = Get_Client_as_String_Column( iMinitab, "C6" ); // // - Put new Columns Data to Table -------------------------------------------- rnd_dt << New Column( "From_X_asNum", Numeric, Continuous, Set Values( x_cN_data ) ); // rnd_dt << New Column( "From_X_asDate", Numeric, Format( "d/m/y h:m" ), Set Values( x_cD_data ) ); // rnd_dt << New Column( "From_X_asChar", Character ); rnd_dt:From_X_asChar << set each value( x_cS_data[Row()] ); // rnd_dt << New Column( "From_M_asNum", Numeric, Continuous, Set Values( M_cN_data ) ); // rnd_dt << New Column( "From_M_asDate", Numeric, Format( "d/m/y h:m" ), Set Values( M_cD_data ) ); // rnd_dt << New Column( "From_M_asChar", Character ); rnd_dt:From_M_asChar << set each value( M_cS_data[Row()] ); // // - show Client(s) ---------------------------------------------- If( Test_Client_as_hide, To_Client_Show( iExcel, _$mtE_c_show ); To_Client_Show( iMinitab, _$mtE_c_show ); ); // - Close Client(s) ---------------------------------------------- Client_Close( iExcel ); Client_Close( iMinitab ); If( MessageBox_fn( Concat( "All done with just few lines of jsl code.", _$crlf, _$crlf, "Press Ok to closedown Client and JMP Table or Cancel to leave them open .." ), _%bt_OkCancel ) == 1, Client_CloseDown( iExcel ); Client_CloseDown( iMinitab ); Close( rnd_dt, NoSave ); ); // Final_message( "Excel 2013[32] +Minitab 19[64]", 1 ); // 1 or 3 //