How to return data from a function written as a simplescript?
Public Function Open_Img(imgFilePath As String) As SimpleScript
Open_Img = New SimpleScript
Open_Img.SaveUndoSteps = False
Dim docList
Dim image
Dim doc
With Application.DocumentCommands.Open(Open_Img)
.Filenames = New String() {imgFilePath}
.Run(docList)
End With
With Application.DocumentCommands.ActiveImage(Open_Img)
.Run(image)
End With
With Application.DocumentCommands.Active(Open_Img)
.Run(doc)
End With
'Return doc??
'Return image??
How can I get anything out of this function?
End Function
0
Best Answer
-
In this case the variable is passed byref so it will be returned from the function.
That said, the main reason for using this syntax is to keep the code compatible with the interactive macro designer. If you are going to code your macros manually you can use a much simpler syntax without needing a SimpleScript object.Public Function GetImageDocument() As IMcDocument Dim docList1 As System.Collections.IList With Application.DocumentCommands.Open(Nothing) .Filenames = New String() {ThisApplication.Path(mcPathType.mcptSampleImages) & "Count and Size\micro_etch.tif"} .Run(docList1) End With Return docList1(0) End Function
PIerre
0
Answers
-
You could do something like this:
Public Function NewMacro(ByRef doc) As SimpleScript NewMacro = New SimpleScript Dim docList1 = New List(1), doc1 With Application.DocumentCommands.Open(NewMacro) .Filenames = New String() {ThisApplication.Path(mcPathType.mcptSampleImages) & "Count and Size\micro_etch.tif"} .Run(docList1) End With With Application.DocumentCommands.Activate(NewMacro) .Run(docList1(0), doc1) End With With Automate.ScriptingCommands.CodeCommand(NewMacro) If .Run() Then ' User Code Here doc = doc1 End If End With End Function
0 -
Pierre, thanks for the help. I've been working with IPP for 10 yrs but now trying to make the switch to 9.1 is painful. So from your code, it looks like the "doc" variable can be passed in, how to get the information contained in doc1 out to use in a calling subroutine like a normal function would be used. I guess I'm not getting it
.
0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions