Hi,
Module m = current
OleAutoObj objCD = null
OleAutoArgs args = create
//array dynamically resizes, set it low to start
Array arrFiles = create (2, 2)
OleAutoObj objFSO = oleCreateAutoObject ("Scripting.FileSystemObject")
bool doSave = false
string strResult = ""
string strLocalFiles = ""
int intResult = 0
int intAns = 0
// Prompt user for file selection
objCD = oleCreateAutoObject("userAccounts.CommonDialog")
//display all files in the folder
strResult = olePut(objCD, "filter", "All files|*.*")
if (strResult != "") then ack "filter failed: " strResult "\n"
strResult = olePut(objCD, "InitialDir", "C:\\")
if (strResult != "") then ack "InitalDir failed: " strResult " \n"
int hexnum = 0X0200 | 0X80000 //200 = multi-select, 80000 = Explorer dialog box
strResult = olePut(objCD, "Flags", hexnum)
if (strResult != "") then ack "Flags failed: " strResult " \n"
// strResult = olePut(objCD, "MaxFileSize", 256)
// if (strResult != "") then ack "MaxFileSize failed: " strResult " \n"
//display dialog box
strResult = oleMethod (objCD, "showOpen", null, intAns)
if (strResult != "") {
ack "showOpen failed: " strResult " \n"
halt
}
if (intAns != 1) {
ack "No file selected \n"
halt
}
//retrieve list of filenames
strResult = oleGet(objCD, "Filename", strLocalFiles)
if (strResult != "") {
ack "FileName failed: " strResult " \n"
halt
}
print strLocalFiles "\n"
dasilvaa - Wed Oct 06 17:12:19 EDT 2010 |
Re: Parsing variable containing strings delimited by null character
|
Re: Parsing variable containing strings delimited by null character
Interesting question! Unfortunately you are out of luck with parsing, since COM will not copy the result over a null-character. Appending the below to your code, shows the tragedy.
print "Files:" strLocalFiles "\n"
print "Parsing:"
int *ptr = addr_ strLocalFiles
while (*ptr & 0x255 > 0) {
print charOf(*ptr)
ptr ++
}; ptr ++ // Skip the 0 character ...
print "\n" // get the second string ...
while (*ptr & 0x255 > 0) {
print charOf(*ptr)
ptr ++
}; ptr ++
... int hexnum = 0X0200 // don't use fancy dialogs ... ...
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Parsing variable containing strings delimited by null character Mathias Mamsch - Wed Oct 06 19:03:44 EDT 2010
Interesting question! Unfortunately you are out of luck with parsing, since COM will not copy the result over a null-character. Appending the below to your code, shows the tragedy.
print "Files:" strLocalFiles "\n"
print "Parsing:"
int *ptr = addr_ strLocalFiles
while (*ptr & 0x255 > 0) {
print charOf(*ptr)
ptr ++
}; ptr ++ // Skip the 0 character ...
print "\n" // get the second string ...
while (*ptr & 0x255 > 0) {
print charOf(*ptr)
ptr ++
}; ptr ++
... int hexnum = 0X0200 // don't use fancy dialogs ... ...
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Unfortunately I specifically need a multi-select dialog box, which the DBE doesn't do. Mathias: I was originally using the old Win3.1 dialog but the clients complained that it's rather clunky, and not very pretty :) Plus you can only see the short filenames, which sometimes makes it difficult to determine if you're selecting the correct files. By the way, were you able to get the MaxFileSize property to work (it's commented out in the code above)? I've tried but I keep getting an error: Problem with OLE Argument names. Any thoughts? |
Re: Parsing variable containing strings delimited by null character dasilvaa - Thu Oct 07 08:44:44 EDT 2010 Regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: Parsing variable containing strings delimited by null character Mathias Mamsch - Fri Oct 08 07:23:40 EDT 2010 Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS Agustine |
Re: Parsing variable containing strings delimited by null character dasilvaa - Fri Oct 08 10:30:04 EDT 2010
Hmm ... then it might be the best, if you help yourself another way, for example, doing a select one file dialog, coupled with an "add" button and a listview.
Function ChooseFile()
ChooseFile = ""
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = False
IE.Navigate ("about:blank")
Do Until IE.ReadyState = 4
Loop
IE.Document.Write "<HTML><BODY><INPUT ID=""Fil"" name=""files[]"" Type=""file"" multiple=""""></BODY></HTML>"
IE.Height = "0"
IE.Width = "0"
IE.Visible = True
With IE.Document.all.Fil
.Focus
.Click
ChooseFile = .Value
End With
IE.Quit
Set IE = Nothing
End Function
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Parsing variable containing strings delimited by null character Mathias Mamsch - Sat Oct 09 14:05:23 EDT 2010
Hmm ... then it might be the best, if you help yourself another way, for example, doing a select one file dialog, coupled with an "add" button and a listview.
Function ChooseFile()
ChooseFile = ""
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = False
IE.Navigate ("about:blank")
Do Until IE.ReadyState = 4
Loop
IE.Document.Write "<HTML><BODY><INPUT ID=""Fil"" name=""files[]"" Type=""file"" multiple=""""></BODY></HTML>"
IE.Height = "0"
IE.Width = "0"
IE.Visible = True
With IE.Document.all.Fil
.Focus
.Click
ChooseFile = .Value
End With
IE.Quit
Set IE = Nothing
End Function
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Thanks Mathias. |