Active Forums => QB64 Discussion => Topic started by: doppler on October 06, 2020, 01:50:47 pm
Title: Opinion, insite, idea's wanted for shell out pass back through the clipboard
Post by: doppler on October 06, 2020, 01:50:47 pm
Basically I am looking for a better way to pass back clipboard content from a shell out.
Start with: "shell "dir *.* | clip", not what I am going to do. But you get the idea. What comes back is line by line content in the clipboard where the lines are separated by (cr/lf). ie:line1(cr/lf)line2(cr/lf),line3(cr/lf)....
I can only think of "a$=_clipboard$" then using instr a$ taking the lines content with mid$'s. Tedious and time consuming. An alternate way would be shell "dir *.* > somefile.txt" and reading the file back with line inputs. Also time consuming.
All input and out devices are considered block devices on windows. Some are read only (keyboard), some are r/w (display). The clip board is no different to windows. And its a block device that is r/w. The open command does not support many block devices in QB64. So the question is the clipboard a "open-able" device on windows. And how to do it? I happen to be using the alternate way now.
Title: Re: Opinion, insite, idea's wanted for shell out pass back through the clipboard
Post by: SpriggsySpriggs on October 06, 2020, 01:56:44 pm
I'd say if you aren't wanting to split everything up line by line or read in contents (which I think is quite quick in most scenarios I've dealt with) then you should look at this: https://docs.microsoft.com/en-us/windows/win32/dataxchg/clipboard-functions (https://docs.microsoft.com/en-us/windows/win32/dataxchg/clipboard-functions)
I can't guarantee that this will work for you. I haven't looked at this portion of the WinAPI yet.
Title: Re: Opinion, insite, idea's wanted for shell out pass back through the clipboard
Post by: doppler on October 06, 2020, 02:16:00 pm
Yea, I saw that on google search results. Using the windows api's are not the easiest things to do inside qb64. I played a long time ago the string method, it was very slow and complex. That's why I went with file re-direction method. A really long time ago, when qb45 was still king. I saw and used a way to take clipboard content and directly pump it in to an array using pointers and such. This is not the dos age anymore. So that nice way is gone now. Unless memory arrays can be directly adjusted in QB64 ????
Title: Re: Opinion, insite, idea's wanted for shell out pass back through the clipboard
Post by: SpriggsySpriggs on October 06, 2020, 02:22:30 pm
The same results would be given if I sent the results to a file... "dir /b C:\tmp-copy-qb64bas\*.wav>junk.txt"
If I want to remove the print characters like carriage return, I think the only way to do so is to parse them out where a$ = _clipboard$ and then parse a$.
Title: Re: Opinion, insite, idea's wanted for shell out pass back through the clipboard
Post by: doppler on October 06, 2020, 02:55:32 pm
My original idea is I need a list of files quickly from a directory passed back to my qb64 program. Output re-direction is messy and leaves behind file(s) that need to be cleaned up later. I thought the clipboard being ram would be faster than opening a list from a re-directed output. The clipboard leads to special handling of a string to parse out the needed content. If the clipboard was an open-able device I could use an "line input" to take the lines out of the clipboard one by one since (cr/lf) is the delimiter for line input.
I am just thinking about a more elegant way of doing it. Doing the mid$ thing seems clunky (maybe the only real way). I know the piping works, I was looking for a "elegant,generic" way of getting the data.
Title: Re: Opinion, insite, idea's wanted for shell out pass back through the clipboard
Post by: jack on October 06, 2020, 03:00:07 pm
how about using the WinAPI FindFirstFile, FindNextFile and FindClose ? https://stackoverflow.com/questions/612097/how-can-i-get-the-list-of-files-in-a-directory-using-c-or-c
Title: Re: Opinion, insite, idea's wanted for shell out pass back through the clipboard
Post by: doppler on October 06, 2020, 03:04:37 pm
Title: Re: Opinion, insite, idea's wanted for shell out pass back through the clipboard
Post by: SpriggsySpriggs on October 06, 2020, 03:28:58 pm
Doppler, I'm away from home right now but I've got the clipboard API almost done being written. Also, for the FindNextFile, there is a post from 2018, I think, that does what Pete mentioned. I downloaded the code and was going to put it in my API collection (with credit, of course).