Sign in to follow this  
Followers 0
woof

2 questions: cmd line limit, directory junction loops

25 posts in this topic

#21 ·  Posted (edited)

Hello,

again: I take source code from post #18 here, save, double click, mark three files in explorer, drag and drop into edit form of the script window.

In edit form only one filename is listed, I close the window and get a popup, where also only one filename is in array, and this filename is shorten by one on the right.

I get no more than one filename in array, I get no @LF at the end of the only line I have.

If this works for you, why not for me? Have you tested your own code? What OS (mine is Win2000)?

Regards,

Thorsten

Addition: When I drop a second time, the first entry is replaced, only editing by hand leaves more than one filename/line in edit form.

Edited by woof

Share this post


Link to post
Share on other sites



If this works for you, why not for me? Have you tested your own code? What OS (mine is Win2000)?

Yes it works for me. Yes I tested my own code. My OS: WinXP - AutoIt 3.1.1.124 (Beta)

Maybe you should use a List control and not an Edit control. It could we a better use in your program.

Sample:

#include <Array.au3>
#include <GUIConstants.au3>
#Include <GuiList.au3>

$Form1 = GUICreate("Drop files in me", 620, 440, -1, -1, -1, $WS_EX_ACCEPTFILES)
$List=GUICtrlCreateList("",10, 10, 600, 400)
GUICtrlSetState($List, $GUI_ACCEPTFILES)

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_EVENT_DROPPED 
            _GUICtrlListAddItem($List, @GUI_DRAGFILE)
        Case Else
       ;;;;;;;
    EndSelect
WEnd

Mutiple files does not work. (don't know why)

Before the _GUICtrlListAddItem command you could implement your FileGetAttrib and subdir search routines.

Geert

Share this post


Link to post
Share on other sites

Hello,

Mutiple files does not work. (don't know why)

I strongly believe that is a bug. Because as I now updated to latest beta your former code (using edit form) now does as it should. So for that obviously the 3.1.1 is buggy ;-)

To confirm to you: For me the list example also does not do multiple files...

Regards,

Thorsten

Share this post


Link to post
Share on other sites

Hello,

after I was successful this way (after updating to latest beta version) I just want to add the solution to other problems of this code (in post #18). Replace

$cmdFilesArray = StringSplit(StringTrimRight(GUICtrlRead($Edit1), 1), @LF)

with this

$tmp = StringStripWS(StringStripCR(GUICtrlRead($Edit1)),2)
If StringInStr($tmp,@LF) Then
   $cmdFilesArray = StringSplit($tmp,@LF)
Else
   _ArrayAdd($cmdFilesArray,$tmp)
EndIf

On my system the dropped filelist included linebreak as @CRLF, so @CR must also be removed. And I think instead of just removing one char on the right using StringStripWS($String,2) is more safe. The biggest problem is that StringSplit() does not return a one-element-array if no splitter is in string. Why?

Regards,

Thorsten

Share this post


Link to post
Share on other sites

#25 ·  Posted (edited)

The sample in post #18 was just quick and dirty. Trim just a character is of course not save.

The biggest problem is that StringSplit() does not return a one-element-array if no splitter is in string. Why?

Why? Choise of a developer. From the help file:

StringSplit is very useful as an alternative to StringInStr and as a means to populate an array.

I think StringSplit can only do it's work if a delimiter is found.

To solve your 'problem' just add a delimiter at the end of the string and remove the last arrayvalue (always empty)

Every line in an edit control ends with CRLF which are 2 characters. To get a clean result I replaced them with the single pipe character: |

StringSplit does also split on a single character.

#include <Array.au3>
#include <GUIConstants.au3>

$Form1 = GUICreate("Drop files in me", 620, 440, -1, -1, -1, $WS_EX_ACCEPTFILES)
$Edit1 = GUICtrlCreateEdit("", 10, 10, 600, 400)
GUICtrlSetState($Edit1, $GUI_ACCEPTFILES)

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
      ;;;;;;;
    EndSelect
WEnd

$cmdFilesArray = StringSplit(StringReplace(StringReplace(GUICtrlRead($Edit1), @CRLF, "|") & "|", "||", "|"), "|")
_ArrayPop($cmdFilesArray)
$cmdFilesArray[0] -= 1

_ArrayDisplay($cmdFilesArray, "Here they are")
Exit

Geert

Edited by Geert

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0