Author Topic: DragText & STDIN  (Read 260 times)

André Heldoorn

  • Hero Member
  • *****
  • Thank You
  • -Given: 113
  • -Receive: 19
  • Posts: 770
    • View Profile
DragText & STDIN
« on: September 02, 2019, 10:57:37 pm »
If text is dropped and the drop target is an app, then it's possible that the file created by the app will be saved in the directory of DragText. Not in the directory of the source of the text or, for example, in the desktop directory (i.e. the homre of the WPS).

Not supporting files in the the DragText directory is not a perfect option, and using <WP_DESKTOP> if the path of the output file would be DragText's may surprise an user.

Are there other options to exclude DragText input, or to avoid the use of the DragText directory? The dropped DragText file has got rather specific EAs. If the dropped file is located in DragText's directory, and the EAs may be DragText's, then use the <WP_DESKTOP>?

Rexx sample code won't be a surprise. Save, and use DragText to drop text of e.g. a CMD.EXE window on top of the icon of the sample:

Code: [Select]
/* Drop text */

PARSE ARG filename

data=CharIn(filename,1,Stream(filename,'C','QUERY SIZE'))
CALL CharOut filename

output=Reverse(filename)
IF Pos('.',output,1)>0 THEN PARSE VAR output . '.' output
output=Reverse('4PM.'||output)

CALL CharOut output,data
CALL CharOut output

SAY 'Input:' filename
SAY 'Output:' output
CALL CharOut '','Press <ENTER> to delete the output file... '
PULL .
'@DEL' output '> NUL'

EXIT

Rich Walsh

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 11
  • Posts: 96
  • ONU! (OS/2 is NOT Unix!)
    • View Profile
Re: DragText & STDIN
« Reply #1 on: September 03, 2019, 03:49:58 am »
If text is dropped and the drop target is an app, then it's possible that the file created by the app will be saved in the directory of DragText. Not in the directory of the source of the text or, for example, in the desktop directory (i.e. the homre of the WPS).

Not supporting files in the the DragText directory is not a perfect option, and using <WP_DESKTOP> if the path of the output file would be DragText's may surprise an user.

Are there other options to exclude DragText input, or to avoid the use of the DragText directory? The dropped DragText file has got rather specific EAs. If the dropped file is located in DragText's directory, and the EAs may be DragText's, then use the <WP_DESKTOP>?

Rather than making a simple task pointlessly complicated, have you ever considered using the target app's "Save as..." menu item? After all, it _is_ the accepted method for choosing the correct name and path for a file you wish to save.

FYI... the reason you're getting the filename 'DT_TEXT' is because your editor doesn't understand DragText's native methods for exchanging text. If it did, the text would just appear and have no effect on the filename. Instead, your editor is reading a temp file created specifically to enable d&d in more apps.

If that's unsatisfactory, you can disable creation of the temp file so the operation always fails ("Setup->Paths->Create temp files" in DT's Settings notebook). If instead you would like to have DT override the app's handling of d&d so DT's native text exchange works, try this (it may not work): open DT's notebook to Setup->Reenable. Look at the entry for 'e.exe', then create a new one for your app with the same checkboxes selected.

BTW... DT has nothing to do with 'stdin'.

André Heldoorn

  • Hero Member
  • *****
  • Thank You
  • -Given: 113
  • -Receive: 19
  • Posts: 770
    • View Profile
Re: DragText & STDIN
« Reply #2 on: September 03, 2019, 11:31:45 am »
Rather than making a simple task pointlessly complicated, ... try this (it may not work): open DT's notebook to Setup->Reenable. Look at the entry for 'e.exe', then create a new one for your app with the same checkboxes selected.
The assumed situation and solutions are more complicated, but you had to explain how something works. The answer is "no", which is fine.

I'm not going to ask for e.g. a hidden desktop directory-file used by DT, because it should work with all versions of DT. The desktop just is the place where the user is performing a simple task, and my starting point was an user instead of a task. If trying to avoid a minor issue is pointlessy complicated, then I may like to be pointlessly complicated.

IRL there's an alternative "Save as", which is one of the work-arounds I was hoping to avoid.

W.r.t. STDIN an user could expect that the dropped text becomes the "typed" input, albeit the UI components of DT rather clearly change to a text file icon instead of text being dropped.

There is no problem, and apparently there is no good way to make something even better. Less complicated.

roberto

  • Sr. Member
  • ****
  • Thank You
  • -Given: 16
  • -Receive: 10
  • Posts: 460
    • View Profile
Re: DragText & STDIN
« Reply #3 on: September 03, 2019, 03:37:06 pm »
If you need to use DT with rexx, I think you should use:
 If RxFuncQuery('Sys2LoadFuncs') Then Do

   Call RxFuncAdd 'Sys2LoadFuncs', 'RxUtilEx', 'Sys2LoadFuncs'
   Call Sys2LoadFuncs
  end
.....
rescu=res ' ' curline
rc=Sys2PutClipboardText(rescu,n)
say res "*-*" curline