@@ -93,8 +93,7 @@ UwxScripting::UwxScripting(QWidget *parent) : QDialog(parent), ui(new Ui::UwxScr
9393 // Create option menu items
9494 gpOptionsMenu = new QMenu (this );
9595 gpOptionsMenu->addAction (" Change Font" )->setData (MenuActionChangeFont);
96- gpSOptionsMenu1 = gpOptionsMenu->addMenu (" Export to" );
97- gpSOptionsMenu1->addAction (" String Player" )->setData (MenuActionExportStringPlayer);
96+ // gpSOptionsMenu1 = gpOptionsMenu->addMenu("Export to");
9897
9998 // Connect signals
10099 connect (gpOptionsMenu, SIGNAL (triggered (QAction*)), this , SLOT (MenuSelected (QAction*)));
@@ -136,7 +135,7 @@ UwxScripting::~UwxScripting(
136135 delete qaKeyShortcuts[0 ];
137136 delete mhlHighlighter;
138137 delete msbStatusBar;
139- delete gpSOptionsMenu1;
138+ // delete gpSOptionsMenu1;
140139 delete gpOptionsMenu;
141140 delete ui;
142141}
@@ -443,84 +442,6 @@ UwxScripting::on_btn_Stop_clicked(
443442 }
444443}
445444
446- // =============================================================================
447- // =============================================================================
448- void
449- UwxScripting::ExportToStringPlayer (
450- )
451- {
452- // Export to stringplayer
453- if (on_btn_Compile_clicked () == false )
454- {
455- // Compile successful
456- QString strSaveFile = QFileDialog::getSaveFileName (this , tr (" Save File" ), " " , " StringPlayer Files (*.sub)" );
457-
458- if (strSaveFile.length () > 1 )
459- {
460- // File was selected
461- QFile fileExport (strSaveFile);
462- if (fileExport.open (QFile::WriteOnly | QFile::Text))
463- {
464- // File opened for writing. Output the data to the file
465- QTextStream tsDataStream (&fileExport);
466-
467- // Output header
468- tsDataStream << " //Exported from AuTerm v" << mstrAuTermVersion << " Scripting on " << QDate::currentDate ().toString (" dd/MM/yyyy" ) << " @ " << QTime::currentTime ().toString (" hh:mm" ) << " \r\n\r\n SET vPort \" 0\" //Change to the port number to send/receive data on\r\n DECLARE vWaitTime\r\n SET vWaitTime \" 5000\" //Change to the desired maximum wait time for each receive event in ms\r\n\r\n " ;
469-
470- // Go through each block in the editor
471- QTextBlock tbCurrentBlock = ui->edit_Script ->document ()->firstBlock ();
472- while (tbCurrentBlock.isValid ())
473- {
474- if (tbCurrentBlock.text ().left (2 ) == ScriptingComment)
475- {
476- // Comment
477- tsDataStream << tbCurrentBlock.text () << " \r\n " ;
478- }
479- else if (tbCurrentBlock.text ().at (0 ) == ScriptingDataOut)
480- {
481- // Send out
482- tsDataStream << " SENDCMD [vPort] \" " << tbCurrentBlock.text ().right (tbCurrentBlock.text ().length ()-1 ) << " \"\r\n " ;
483- }
484- else if (tbCurrentBlock.text ().at (0 ) == ScriptingDataIn)
485- {
486- // Receive
487- tsDataStream << " WAITRESPEX [vWaitTime] [vPort] \" " << tbCurrentBlock.text ().right (tbCurrentBlock.text ().length ()-1 ) << " \"\r\n " ;
488- }
489- else if (tbCurrentBlock.text ().at (0 ) == ScriptingWaitTime)
490- {
491- // Wait for
492- tsDataStream << " DELAY \" " << tbCurrentBlock.text ().right (tbCurrentBlock.text ().length ()-1 ) << " \"\r\n " ;
493- }
494- else if (tbCurrentBlock.text ().length () == 0 )
495- {
496- // Newline
497- tsDataStream << " \r\n " ;
498- }
499- else if (QString (tbCurrentBlock.text ()).replace (" \t " , " " ).replace (" " , " " ).length () > 0 )
500- {
501- // Text present that isn't space/tab, just assume a newline
502- tsDataStream << " \r\n " ;
503- }
504-
505- // Progress to next block
506- tbCurrentBlock = tbCurrentBlock.next ();
507- }
508- fileExport.close ();
509-
510- // Show message
511- msbStatusBar->showMessage (" StringPlayer export successful!" );
512- }
513- else
514- {
515- // Failed to open file
516- QString strMessage = tr (" Error during Scripting StringPlayer file export: Access to selected file is denied: " ).append (strSaveFile);
517- mFormAuto ->SetMessage (&strMessage);
518- mFormAuto ->show ();
519- }
520- }
521- }
522- }
523-
524445// =============================================================================
525446// =============================================================================
526447void
@@ -581,12 +502,14 @@ UwxScripting::AdvanceLine(
581502 mbaMatchData = mtbExecutionBlock.text ().right (mtbExecutionBlock.text ().length ()-1 ).toUtf8 ();
582503 AutEscape::escape_characters (&mbaMatchData);
583504 ucLastAct = ScriptingActionDataIn;
505+
584506 if (!gtmrRecTimer.isValid ())
585507 {
586508 // Start timer
587509 gtmrRecTimer.start ();
588510 mtmrUpdateTimer.start (500 );
589511 }
512+
590513 if (CheckRecvMatchBuffers () == false )
591514 {
592515 // Waiting on a match
@@ -604,13 +527,6 @@ UwxScripting::AdvanceLine(
604527 UpdateStatusBar ();
605528 return ;
606529 }
607-
608- if (gtmrRecTimer.isValid ())
609- {
610- // Stop timer and invalidate it
611- gtmrRecTimer.invalidate ();
612- mtmrUpdateTimer.stop ();
613- }
614530 }
615531 else if (mtbExecutionBlock.text ().at (0 ) == ScriptingWaitTime)
616532 {
@@ -637,6 +553,13 @@ UwxScripting::AdvanceLine(
637553 UpdateStatusBar ();
638554 mtbExecutionBlock = mtbExecutionBlock.next ();
639555 ++mintCLine;
556+
557+ if (gtmrRecTimer.isValid ())
558+ {
559+ // Stop timer and invalidate it
560+ gtmrRecTimer.invalidate ();
561+ mtmrUpdateTimer.stop ();
562+ }
640563 }
641564
642565 // Means execution has finished
@@ -726,21 +649,13 @@ UwxScripting::CheckRecvMatchBuffers(
726649 {
727650 // Length of receive buffer is greater than or equal to the match string, perform search
728651 int intPos = mbaRecvData.indexOf (mbaMatchData);
729- if (intPos != -1 )
652+
653+ if (intPos != -1 && intPos < ui->spin_MaxRecBufSize ->value ())
730654 {
731- // Data found
732- if (intPos < ui->spin_MaxRecBufSize ->value ())
733- {
734- // Position OK: shift array and progress to next line
735- mbaRecvData = mbaRecvData.right (mbaRecvData.length () - intPos - mbaMatchData.length ());
736- mbWaitingForReceive = false ;
737- return true ;
738- }
739- else
740- {
741- // Text found but after buffer size limit, return failure
742- return false ;
743- }
655+ // Position OK: shift array and progress to next line
656+ mbaRecvData = mbaRecvData.right (mbaRecvData.length () - intPos - mbaMatchData.length ());
657+ mbWaitingForReceive = false ;
658+ return true ;
744659 }
745660 }
746661
@@ -923,11 +838,6 @@ UwxScripting::MenuSelected(
923838 // Change font
924839 ChangeFont ();
925840 }
926- else if (intItem == MenuActionExportStringPlayer)
927- {
928- // Export to string player
929- ExportToStringPlayer ();
930- }
931841}
932842
933843// =============================================================================
0 commit comments