Open kth8384 opened 3 months ago
Hi! The documentation says:
* command_line: diagon Math -- 1+1/2
* file : diagon Math < filename
* stdin : diagon Math
So, you are missing the --
before your command line string.
You can try:
diagon Sequence -- "
Browser -> Network: URLRequest()
Browser <- Network: URLResponse()
Browser <- Network: URLResponse()
Renderer <- Browser: CommitNavigation()
Renderer -> Browser: DidCommitNavigation()
"
or with a file inputed using <<EOF
diagon Sequence <<EOF
Browser -> Network: URLRequest()
Browser <- Network: URLResponse()
Browser <- Network: URLResponse()
Renderer <- Browser: CommitNavigation()
Renderer -> Browser: DidCommitNavigation()
EOF
Output:
┌───────┐ ┌───────┐┌────────┐
│Browser│ │Network││Renderer│
└───┬───┘ └───┬───┘└───┬────┘
│ │ │
│URLRequest() │ │
│────────────>│ │
│ │ │
│URLResponse()│ │
│<────────────│ │
│ │ │
│URLResponse()│ │
│<────────────│ │
│ │ │
│ CommitNavigation() │
│─────────────────────>│
│ │ │
│DidCommitNavigation() │
│<─────────────────────│
┌───┴───┐ ┌───┴───┐┌───┴────┐
│Browser│ │Network││Renderer│
└───────┘ └───────┘└────────┘
the -- aren't missing.
Thank you very much! Can you help me to check my source? I have try my best but cann't find the error of my program.
`#include
void cmdSystem(const std::string& cmd) { system(cmd.c_str()); }
std::string cmdPopen(const std::string& cmd) { char buffer[1024] = { '\0' }; FILE* pf = NULL; pf = _popen(cmd.c_str(), "r"); if (NULL == pf) { std::cout << "open pipe failed" << std::endl; return std::string(""); } std::string ret; while (fgets(buffer, sizeof(buffer), pf)) { ret += buffer; } _pclose(pf); return ret; }
void cmdPopen(const char cmd, char result) { char buf_ps[1024]; char ps[1024] { 0 }; FILE *pf; strcpy(ps, cmd); if ((pf = popen(ps, "r")) != NULL) { while (fgets(buf_ps, 1024, pf) != NULL) { // every line of output //std::cout << buf_ps << std::endl; std::cout<< buf_ps<< std::endl; strcat(result, buf_ps); if (strlen(result) > 1024) break; } pclose(pf); pf = NULL; } else { std::cout << "popen " << ps << " error" << std::endl; } }
int main() { //std::string cmdLine(R"("echo Hello, World!")");
std::string cmdLine = "diagon Sequence -style=Ascii -- \"";
cmdLine.append(" Renderer -> Browser: BeginNavigation()\n");
cmdLine.append(" Browser -> Network: URLRequest()\n");
cmdLine.append(" Browser <- Network: URLResponse()\n");
cmdLine.append(" Browser <- Network: URLResponse()\n");
cmdLine.append(" Renderer <- Browser: CommitNavigation()\n");
cmdLine.append(" Renderer -> Browser: DidCommitNavigation()\n");
cmdLine.append("\"");
//cmdLine = { R"AAA(diagon Sequence < "seq.txt" )AAA" };
//cmdSystem("chcp 936"); // no return value
cmdSystem("chcp 65001"); // no return value
std::string result = cmdPopen(cmdLine);
std::cout << result << std::endl;
system("pause");
return 0;
}
`
the result is
` Active code page: 65001 ┌────────┐ ┌───────┐ │Renderer│ │Browser│ └───┬────┘ └───┬───┘ │ │ │BeginNavigation()│ │────────────────>│ ┌───┴────┐ ┌───┴───┐ │Renderer│ │Browser│ └────────┘ └───────┘
Press any key to continue . . .
`
Read from file ok.
But make the command in my application, then call _popen, the command string like this "diagon Sequence -style=Unicode -- \"Renderer -> Browser: BeginNavigation()\" -- \"Browser -> Network: URLRequest()\" -- \"Browser <- Network: URLResponse()\" -- \"Browser <- Network: URLResponse()\" -- \"Renderer <- Browser: CommitNavigation()\" -- \"Renderer -> Browser: DidCommitNavigation()\"", cannot work?
How to make the command string?