| %PGETPID | Index Level | %PUTENV |
| Syntax | pointer = (char*)%POPEN( command, type ) |
| Category | BASIC |
| Type | C Function |
| Description |
creates a pipe between the calling process and the command to be executed.
"command" Shell command line. "type" I/O mode, either "r" for reading or "w" for writing. "pointer" Stream pointer which directs a write to the standard input of the command if the I/O mode is "w", and reads from the standard output of the command if the type is "r". A stream opened by "%popen()" must be closed by "pclose()". The stream is closed automatically at FlashBASIC program termination. |
| Options | |
| See Also | c function %PCLOSE %FGETS %FPUTS EXECUTE (D3/Unix) CFUNCTION |
| Example |
char buffer[128]
ptr=(char*)%popen("ls -l","r") if ptr=0 then crt 'error'; stop loop n=(char*)%fgets(buffer,128,(char*)ptr) while n#0 do print field(buffer,char(0),1) repeat %pclose((char*)ptr) This example executes a C command, capturing the result. |
| Warnings | |
| Compatibility | D3/Unix |
| %PGETPID | Index Level | %PUTENV |