|
David, Here is the "RUNCMD" method out of my AS/400 CL Command Line Window. If you download my HOST SOURCE TRANSFER from my web site WWW.RPGDEV.NET it allows you to run a CL command. This code is the code behind the dialog box's "Run Command" button. void CCmdLine::OnRunCommand() { char lpszMsgID[9]; char szSysName[64]; char szMsgText[1025]; UINT wMsgLen = sizeof(szMsgText)-1; UINT wSevCode = 0; WORD wRtnCode = 0; UpdateData(TRUE); // Retrieve the command to run. clear(szMsgText); clear(szSysName); clear(lpszMsgID); memset(m_szCmdBuffer,'\0',CMDBUFFER); memset(m_szCPFMsgBuffer,'\0',CPFMSGBUFFER); strcpy(szSysName, (LPCSTR) m_szSysName); if (m_szCmdLine.IsEmpty()) return; m_Messages.ResetContent(); strcpy(m_szCmdBuffer,(LPCSTR) m_szCmdLine); if (IsValid(GetApp()->m_pfnSubmitCommand)) { wRtnCode = GetApp()->m_pfnSubmitCommand(GetSafeHwnd(), (LPSTR) szSysName, /* System name */ (LPSTR) m_szCmdBuffer, /* Command Entry Line buffer */ (LPSTR) m_szCPFMsgBuffer, /* Return CPF message text buffer */ (WORD) CPFMSGBUFFER, /* Length of the message buffer */ NULL); /* Pointer to CALLBACK function */ } if (wRtnCode >= EHNSR_SEVEREERROR) { sprintf(m_szMsg,">>SbmRmtCmd() Error. Return code x\'%X\'.",(UINT) wRtnCode); GetApp()->WriteJoblog(m_szMsg); m_Messages.InsertString(0,m_szMsg); } else { // Store the command for later retrieval m_PriorCmd.InsertString(0,m_szCmdLine); m_PriorCmd.SetCurSel(0); GetApp()->m_szPriorCmds.AddHead(m_szCmdLine); } GetApp()->WriteJoblog("---- Recording result messages in joblog."); GetApp()->WriteJoblog("MSGID Sev Message Text"); if (IsValid(GetApp()->m_pfnGetMessage)) { do { clear(szMsgText); // ::EHNSR_GetMessage(GetSafeHwnd(), wRtnCode = GetApp()->m_pfnGetMessage(GetSafeHwnd(), (LPSTR) szSysName, // System name (LPWORD) &wSevCode, (LPSTR) lpszMsgID, (LPSTR) szMsgText, (WORD) wMsgLen, (LPSTR) m_szCPFMsgBuffer, (WORD) CPFMSGBUFFER); if ((wRtnCode == EHNSR_OK) && strlen(szMsgText)>0) { sprintf(m_szMsg,"%s (%02d) %s",lpszMsgID, wSevCode, szMsgText); GetApp()->WriteJoblog(m_szMsg); m_Messages.AddString(m_szMsg); } } while (strlen(szMsgText)>0); } m_CmdLine.SetFocus(); } * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This is the Midrange System Mailing List! To submit a new message, * * send your mail to "MIDRANGE-L@midrange.com". To unsubscribe from * * this list send email to MAJORDOMO@midrange.com and specify * * 'unsubscribe MIDRANGE-L' in the body of your message. Questions * * should be directed to the list owner / operator: david@midrange.com * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.