|
Post by sarossell on Apr 22, 2020 13:50:34 GMT -5
Does LB have a way of handling files that are dropped onto windows or (even more) onto icons, specifically on Mac? I have a program in Xojo that does this to rename files dropped onto it and I would really prefer to use Liberty BASIC.
Thanks!
:@)
|
|
timur77
Junior Member
Someday I will tell my grandsons that I am older than the Internet. And it will blow their brain.
Posts: 79
|
Post by timur77 on Apr 23, 2020 0:40:51 GMT -5
Well, you have appetites too, it looks like exercism, apparently it can be done with a wider use of API functions, possibly DragQueryFile Here is a link to an example: example
|
|
|
Post by sarossell on Apr 23, 2020 8:15:06 GMT -5
Well, you have appetites too, it looks like exercism Oooh! I love Russian. I don't understand a word of it, but I love the fact that it exists, just to taunt the hell out of simpler languages - like Assembly language for a 1985 Hewlett-Packard scientific calculator.
Thank you very much for the link! I will give it my full attention.
:@)
|
|
|
Post by Rod on Apr 23, 2020 9:04:56 GMT -5
Well I know very little about the Mac. There are complex API routines to set up for an application to know something has been dropped on it. However here is an alternative. But it relies on .bat files, don't know if that will work for you on the Mac.
Process, set up a .bat file and place it on the desktop or wherever you are going to drop files.
The .bat file does two important things. It changes the working directory to the Liberty BASIC Applications directory. This allows the .exe to find the .tkn. But, we must also hide the path of the dropped file because Liberty gets confused and uses the last path in the CommandLine to search for the .tkn. I do this with a dirty fix by prepending "123" to the dropped file path.
This is the .bat file which is simply text stored in anyname.bat file. You use the path and the .exe name. The %1 is a Windows variable that holds the dropped file name.
cd c:\atemp\draganddrop drop.exe "123"%1
This is a little test program that just shows the file name can be passed. You need to make this drop.exe and be sure the .bat file points to it.
'check if there is something in CommandLine$ if CommandLine$<>"" then print CommandLine$ 'parse out the file name p=instr(CommandLine$,"123",1) f$=trim$(right$(CommandLine$,len(CommandLine$)-p-3)) print f$
'open the edited file name open f$ for input as #t 'read it in txt$ = input$(#t, lof(#t)) close #t 'print the contents of the file print "This is the contents of ";f$ print txt$ 'notice the CommandLine$ file name notice "Dropped File is ";f$ else notice "No file dropped!" end if end
Now the .bat file can sit on your desktop and you can drop say.txt files on it and it will fire up Liberty and know what file was dropped.
I can't for the life of me remember how to hide the cmd.exe window, it can be done. But first things first does it work on a Mac?
|
|
|
Post by sarossell on Apr 23, 2020 9:29:08 GMT -5
But first things first does it work on a Mac? Well, as far as I know, the latest v.5 alpha 350 doesn't yet have the ability to create .TKN files, so I'm stuck at the moment. :@(
|
|
|
Post by Carl Gundel on Apr 23, 2020 9:36:13 GMT -5
Liberty BASIC v5 will not use TKN files. Applications will be created in a .IM file which is not tokenized. This will be considerable larger than a TKN file, but it will also do away with whatever security risk people expressed concerns about related to TKNs being de-tokenized.
|
|
|
Post by Rod on Apr 23, 2020 9:37:07 GMT -5
Well the .bat file I showed started drop.exe, it could equally start liberty.exe but you would be in the IDE, the CommandLine$ variable should still be filled correctly. Usually when you get to this level you don't really want to see the inner workings of Liberty you just want to go straight to the app.
|
|
|
Post by sarossell on Apr 23, 2020 10:31:27 GMT -5
It looks like it should be possible eventually.
Thanks!
|
|
|
Post by Brandon Parker on Apr 24, 2020 22:33:52 GMT -5
I have very successfully used WMLiberty.dll on Windows to capture the WM_DROPFILES message for specific windows. I am not sure if whatever intermediary layer you are using between LB and Mac will handle it correctly, but it might be worth a try. I'm not sure if I have any stand-alone code for it, but I will dig around and see if I do.
Does nothing show up in the CommandLine$ variable when you drag a file onto a Liberty BASIC executable file? In Windows, you should get the file path of the file that you drug onto the executable file.
{:0)
Brandon Parker
|
|
|
Post by sarossell on Apr 24, 2020 23:47:50 GMT -5
Does nothing show up in the CommandLine$ variable when you drag a file onto a Liberty BASIC executable file? In Windows, you should get the file path of the file that you drug onto the executable file. Thank you for your suggestion. However, there are two barriers to resolving this for a Mac:
1) CommandLine$ cannot return a value if there is no app icon.
2) LB v5 does not yet provide a way to create an .im file to provide an icon on the Mac.
:@(
|
|
|
Post by Brandon Parker on Apr 28, 2020 19:20:45 GMT -5
Maybe post in the LB5 section so that Carl knows this is something specific to LB5 ... ?
{:0)
Brandon Parker
|
|