Author Topic: Pipecom conversion to BAS only (MAJOR UPDATE!)  (Read 14447 times)

0 Members and 1 Guest are viewing this topic.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Pipecom conversion to BAS only (SOLVED!)
« Reply #15 on: February 11, 2021, 03:16:00 pm »
The "di" is intentional. I wanted to show getting the error of supplying it with a wrong command. As for any extra characters, did you grab my latest code? Also, feel free to diagnose any bugs!
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Pipecom conversion to BAS only (SOLVED!)
« Reply #16 on: February 11, 2021, 03:46:15 pm »
The "di" is intentional. I wanted to show getting the error of supplying it with a wrong command. As for any extra characters, did you grab my latest code? Also, feel free to diagnose any bugs!

I think I did, your last edit was 12++ PM, my post when checking it 3+PM

I cant follow(understand) your code, do you tell it to use a 1 or 2 char delimiter between (dir) lines for returned string from pipecom function?

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Pipecom conversion to BAS only (SOLVED!)
« Reply #17 on: February 11, 2021, 06:48:45 pm »
@bplus @STxAxTIC

Just pasted in my latest code (in the best answer post) that seems to behave the way the old one did. Please redownload and run at your convenience. Let me know your results. Fellippe and I tested it ourselves and have compared it to the original header version.

bplus, as for understanding the code:
Windows uses a carriage-return & line-feed combination. This causes an extra line to be displayed in the window if you leave it like that. So, in order to avoid that, I'm removing all instances of CHR$(13). It's the same way I did it in the header file I had. CHR$(10) is the way that matches how Linux would display line endings and is the absolute best way.
« Last Edit: February 11, 2021, 06:51:22 pm by SpriggsySpriggs »
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Pipecom conversion to BAS only (SOLVED!)
« Reply #18 on: February 11, 2021, 07:33:22 pm »
@bplus @STxAxTIC

Just pasted in my latest code (in the best answer post) that seems to behave the way the old one did. Please redownload and run at your convenience. Let me know your results. Fellippe and I tested it ourselves and have compared it to the original header version.

bplus, as for understanding the code:
Windows uses a carriage-return & line-feed combination. This causes an extra line to be displayed in the window if you leave it like that. So, in order to avoid that, I'm removing all instances of CHR$(13). It's the same way I did it in the header file I had. CHR$(10) is the way that matches how Linux would display line endings and is the absolute best way.

@SpriggsySpriggs

It looks good now, tried different switches on Dir, thanks for this!

Is pipecome your own name for this method? I could not find anything strongly related to that name on Internet.

This is nice as alternate to Shell for some Windows OS reports, I think.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Pipecom conversion to BAS only (SOLVED!)
« Reply #19 on: February 11, 2021, 07:36:41 pm »
@bplus
Yes, pipecom is my own name for it. I came up with it because the action of reading in commands like that is called opening a pipe. And, since it's running a command, I decided to put the two together. Pipecom. Opening a pipe to a command.
Shuwatch!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Pipecom conversion to BAS only (SOLVED!)
« Reply #20 on: February 11, 2021, 07:42:32 pm »
I tried to submit a text server to Linux Red Hat, once; but the CEO had a problem with the name Linux ASCII-Hat. Oh well.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Pipecom conversion to BAS only (SOLVED!)
« Reply #21 on: February 11, 2021, 08:22:44 pm »
Trying to understand what the complier directives do. It looks like 4 bytes are added  Does data get stored in padding and padding2   ?

  $If 64BIT Then
                padding As Long
            $End If

$If 64BIT Then
                padding2 As Long
            $End If

example
Quote
cb As Long
            $If 64BIT Then
             padding As Long   
            $End If

is cb now the  LSB dword and is "padding"  the MSB dword?




Quote
Type STARTUPINFO
            cb As Long
            $If 64BIT Then
                padding As Long
            $End If
            lpReserved As _Offset
            lpDesktop As _Offset
            lpTitle As _Offset
            dwX As Long
            dwY As Long
            dwXSize As Long
            dwYSize As Long
            dwXCountChars As Long
            dwYCountChars As Long
            dwFillAttribute As Long
            dwFlags As Long
            wShowWindow As Integer
            cbReserved2 As Integer
            $If 64BIT Then
                padding2 As Long
            $End If
            lpReserved2 As _Offset
            hStdInput As _Offset
            hStdOutput As _Offset
            hStdError As _Offset
        End Type
« Last Edit: February 11, 2021, 08:29:25 pm by NOVARSEG »

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Pipecom conversion to BAS only (SOLVED!)
« Reply #22 on: February 11, 2021, 08:27:55 pm »
@NOVARSEG
The $IF64 BIT is just so I can check if it is 64 bit and then add an extra 4 bytes to make the struct aligned properly. Like you mentioned with your 16 vs 32 bit.

As for LSB and MSB, yes (I think)
« Last Edit: February 11, 2021, 09:01:58 pm by SpriggsySpriggs »
Shuwatch!

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Pipecom conversion to BAS only (SOLVED!)
« Reply #23 on: February 11, 2021, 09:40:00 pm »

OK

Quote
TYPE STARTUPINFO
    cb AS _INTEGER64
    lpReserved AS _OFFSET
    lpDesktop AS _OFFSET
    lpTitle AS _OFFSET
    dwX AS LONG
    dwY AS LONG
    dwXSize AS LONG
    dwYSize AS LONG
    dwXCountChars AS LONG
    dwYCountChars AS LONG
    dwFillAttribute AS LONG
    dwFlags AS LONG
    wShowWindow AS LONG
    cbReserved2 AS LONG
    lpReserved2 AS _OFFSET
    hStdInput AS _OFFSET
    hStdOutput AS _OFFSET
    hStdError AS _OFFSET
END TYPE
« Last Edit: February 11, 2021, 09:58:32 pm by NOVARSEG »

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Pipecom conversion to BAS only (SOLVED!)
« Reply #24 on: February 11, 2021, 09:43:56 pm »
@NOVARSEG
It might work but it is incorrect. You don't want to make cb into an 8 byte variable just to
fill the space. You would want to leave it as is.
« Last Edit: February 11, 2021, 09:47:53 pm by SpriggsySpriggs »
Shuwatch!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Pipecom conversion to BAS only (SOLVED!)
« Reply #25 on: February 11, 2021, 09:55:01 pm »
@NOVARSEG
It might work but it is incorrect. You don't want to make cb into an 8 byte variable just to
fill the space. You would want to leave it as is.

It won’t work.  The 2 integers are merged into a single long, giving one a massive value while the other remains 0.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Pipecom conversion to BAS only (SOLVED!)
« Reply #26 on: February 11, 2021, 09:55:55 pm »
@SMcNeill
I was only referring to cb. I didn't even bother to read the rest haha
Shuwatch!

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Pipecom conversion to BAS only (SOLVED!)
« Reply #27 on: February 11, 2021, 10:06:43 pm »
This should work for 64 bit compiler but will it work for 32 bit

Quote
TYPE STARTUPINFO
    cb AS LONG
    pad1 AS LONG
    lpReserved AS _OFFSET
    lpDesktop AS _OFFSET
    lpTitle AS _OFFSET
    dwX AS LONG
    dwY AS LONG
    dwXSize AS LONG
    dwYSize AS LONG
    dwXCountChars AS LONG
    dwYCountChars AS LONG
    dwFillAttribute AS LONG
    dwFlags AS LONG
    wShowWindow AS INTEGER
    cbReserved2 AS INTEGER
    pad2 AS LONG
    lpReserved2 AS _OFFSET
    hStdInput AS _OFFSET
    hStdOutput AS _OFFSET
    hStdError AS _OFFSET
END TYPE

For 32 bit the total is 68 bytes but with pad1 and pad2  it's 72 bytes. It looks like these TYPES are very strict on number of bytes. 

« Last Edit: February 11, 2021, 10:30:30 pm by NOVARSEG »

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Pipecom conversion to BAS only (SOLVED!)
« Reply #28 on: February 11, 2021, 10:07:25 pm »
No
Shuwatch!

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Pipecom conversion to BAS only (SOLVED!)
« Reply #29 on: February 11, 2021, 10:32:04 pm »
So it works for 64 bit and not for 32 bit.  I'm trying to figure out a way without the compiler directives.

Even with the compiler directives will 64 bit EXE work on 32 bit computer?
***

Found a pointer to STARTUPINFO



Quote
BOOL CreateProcessA(
  LPCSTR                lpApplicationName,
  LPSTR                 lpCommandLine,
  LPSECURITY_ATTRIBUTES lpProcessAttributes,
  LPSECURITY_ATTRIBUTES lpThreadAttributes,
  BOOL                  bInheritHandles,
  DWORD                 dwCreationFlags,
  LPVOID                lpEnvironment,
  LPCSTR                lpCurrentDirectory,
  LPSTARTUPINFOA        lpStartupInfo,
  LPPROCESS_INFORMATION lpProcessInformation
);

windows calls them pointers.  a pointer is an memory address.
« Last Edit: February 11, 2021, 11:16:50 pm by NOVARSEG »