Convert some simple .net code to progress code

Den Duze

Member
Hi,

I would like to convert this simple .net code to progress code but I can't make it working.
Maybe someone of you know how to do this in Progress.
C#:
Private Sub Form1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
     Dim files() As String = e.Data.GetData(DataFormats.FileDrop)
     For Each filePath In files
          MsgBox(filePath)
     Next
End Sub
 

Osborne

Active Member
I have not worked with System.Windows.Forms.DragEventArgs so a rough translation only but hope it points you in the right direction:
Code:
PROCEDURE Form1_DragDrop:  // or if a class METHOD PUBLIC VOID Form1_DragDrop (INPUT sender AS System.Object, INPUT e AS System.Windows.Forms.DragEventArgs):
   DEFINE INPUT PARAMETER sender AS System.Object NO-UNDO.
   DEFINE INPUT PARAMETER e AS System.Windows.Forms.DragEventArgs NO-UNDO.

   DEFINE VARIABLE files AS "System.String[]" NO-UNDO.
   DEFINE VARIABLE vLength AS INTEGER NO-UNDO.
   DEFINE VARIABLE vCount AS INTEGER NO-UNDO.
   DEFINE VARIABLE vValue AS CHARACTER NO-UNDO.

   files = CAST(e:Data:GetData(System.Windows.Forms.DataFormats:FileDrop),"System.String[]").
   vLength = files:Length - 1.
   DO vCount = 0 TO vLength:
      vValue = files:GetValue(vCount).
      MESSAGE vValue VIEW-AS ALERT-BOX.
   END.
END PROCEDURE.
 

Den Duze

Member
Hi,

Yes, thanks ... this does the trick.
The thing that I could not find is the "System.String[]".
I wonder how you come to that ... this is a problem that I frequently have when trying to convert some .net code.
Does there exists some conversion list of .net objects to Progress object?
 

Osborne

Active Member
I came to the solution with a bit of trial and error. In most cases you can normally assign directly as in this example:

Code:
DEFINE VARIABLE oStartInfo AS System.Diagnostics.ProcessStartInfo NO-UNDO.
DEFINE VARIABLE oVerbs AS "System.String[]" NO-UNDO.

oStartInfo = NEW System.Diagnostics.ProcessStartInfo("C:\Temp\PDFFile.pdf").
oVerbs = oStartInfo:Verbs.

But trying that with this code was not allowed:

Code:
files = e:Data:GetData(System.Windows.Forms.DataFormats:FileDrop).

1650357711106.png

So then tried using CAST and with this compiling okay presumed this was the solution.

I do not know if there exists some conversion list of .NET objects to Progress objects, but a bit of information can be found here:

 
Top