MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / CmdOutputRun

Function CmdOutputRun

source/Debugger/Debug.cpp:6750–6807  ·  view source on GitHub ↗

===========================================================================

Source from the content-addressed store, hash-verified

6748
6749//===========================================================================
6750Update_t CmdOutputRun (int nArgs)
6751{
6752 g_bScriptReadOk = false;
6753
6754 if (! nArgs)
6755 return Help_Arg_1( CMD_OUTPUT_RUN );
6756
6757 if (nArgs != 1)
6758 return Help_Arg_1( CMD_OUTPUT_RUN );
6759
6760 // Read in script
6761 // could be made global, to cache last run.
6762 // Opens up the possibility of:
6763 // CHEAT [ON | OFF] -> re-run script
6764 // with conditional logic
6765 // IF @ON ....
6766 MemoryTextFile_t script;
6767
6768 const std::string pFileName = g_aArgs[ 1 ].sArg;
6769 std::string sFileName;
6770
6771 if (pFileName[0] == PATH_SEPARATOR || pFileName[1] == ':') // NB. Any prefix quote has already been stripped
6772 {
6773 // Abs pathname
6774 sFileName = pFileName;
6775 }
6776 else
6777 {
6778 // Rel pathname
6779 sFileName = g_sCurrentDir + pFileName;
6780 }
6781
6782 if (script.Read( sFileName ))
6783 {
6784 g_bScriptReadOk = true;
6785
6786 ConsolePrintFormat("%sRun script: ", CHC_INFO);
6787 ConsolePrintFormat("%s%s", CHC_PATH, sFileName.c_str()); // Output pathname to console to indicate the script has been read
6788
6789 int nLine = script.GetNumLines();
6790
6791 Update_t bUpdateDisplay = UPDATE_NOTHING;
6792
6793 for ( int iLine = 0; iLine < nLine; iLine++ )
6794 {
6795 script.GetLine( iLine, g_pConsoleInput, CONSOLE_WIDTH-2 );
6796 g_nConsoleInputChars = (int) strlen( g_pConsoleInput );
6797 bUpdateDisplay |= DebuggerProcessCommand( false );
6798 }
6799 }
6800 else
6801 {
6802 ConsolePrintFormat("%sCouldn't load script:", CHC_WARNING);
6803 ConsolePrintFormat("%s%s", CHC_STRING, sFileName.c_str());
6804 }
6805
6806 return ConsoleUpdate();
6807}

Callers 1

DebugInitializeFunction · 0.85

Calls 7

Help_Arg_1Function · 0.85
ConsolePrintFormatFunction · 0.85
DebuggerProcessCommandFunction · 0.85
GetNumLinesMethod · 0.80
ConsoleUpdateFunction · 0.70
ReadMethod · 0.45
GetLineMethod · 0.45

Tested by

no test coverage detected