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 : Minitab >"; // // One Client ------------------------------------------------------------------------- iMinitab = 1; // Test_max_Isize = 1000; // 4000000 //vector size max // ok tested; mtb64 = 10.000.000 (=Minitab maxrows) ; mtb32 about 4.000.000 [string memory limit in Mtb32] Test_show_MsgBox = 1; // // - 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 ); 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] = 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( "as_Num", Numeric, Continuous, Set Values( jN_data ) ) ); // rnd_dt << New Column( "as_Date", Numeric, Continuous, Format( "d/m/y h:m" ), Set Values( jD_data ) ); rnd_dt << New Column( "as_Char", Character ); rnd_dt:as_Char << set each value( jS_data[Row()] ); // // - Start Client(s) ---------------------------------------------------- If( test_show_MsgBox, MessageBox_fn( Concat( "The table with ", c_Els, " Random Data is ready. Press Ok to start the Client" ), _%bt_Ok ) ); New_Client( meHost, iMinitab, "mte_CRT.exe", "mtb.application", _$as_view ); // // - Send Data to Client(s) ---------------------------------------------- If( test_show_MsgBox, MessageBox_fn( "Now send JMP Columns Data to the Client", _%bt_Ok ) ); jCol = Create_Numeric_Column_Ref( _%mtE_fmx_Long4, jN_data ); To_Client_As_Column_Num( _%mtE_fmx_Long4, jCol, iMinitab, 1 ); // C1 Clean_Column_Ref( jCol ); // jCol = Create_Datetime_Column_Ref( jD_data ); To_Client_As_Column_DT( jCol, iMinitab, 2 ); // C2 Clean_Column_Ref( jCol ); // jCol = Create_String_Column_Ref( jS_data ); To_Client_As_Column_String( jCol, iMinitab, 3 ); // C3 Clean_Column_Ref( jCol ); // // - Add new Client(s) Columns Data using Client macro code ---------------------------------------------- c_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 Client to create new columns Data :", _$crlf, _$crlf, c_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_mtbMacro_Code( iMinitab, c_code ); // // - Get Client(s) Data ---------------------------------------------- If( test_show_MsgBox, MessageBox_fn( "Now get Client new columns data and put them on JMP Table", _%bt_Ok ) ); cN_data = Get_Client_as_Numeric_Column( iMinitab, "C4" ); cD_data = Get_Client_as_DateTime_Column( iMinitab, "C5" ); cS_data = Get_Client_as_String_Column( iMinitab, "C6" ); // // - Put Data to Table -------------------------------------------- rnd_dt << New Column( "From_C_asNum", Numeric, Continuous, Set Values( cN_data ) ); // rnd_dt << New Column( "From_C_asDate", Numeric, Format( "d/m/y h:m" ), Set Values( cD_data ) ); // rnd_dt << New Column( "From_C_asChar", Character ); rnd_dt:From_C_asChar << set each value( cS_data[Row()] ); // // - Close Client(s) ---------------------------------------------- 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( iMinitab ); Close( rnd_dt, NoSave ); ); // Final_message( "Minitab 19[64]", 1 ); // 1 or 3 //