|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
is there a way to call a VBScript function from a CF template and get the output?
thanks |
|
#2
|
|||
|
|||
|
The only way I could think of would be if you packaged the VB into a COM object and called the COM object. Or maybe you could use CFEXECUTE to call the VB script file as if you were calling it from the command line. I don't know if you'll be able to "capture" the output though...it depends on what the script is doing I suppose.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
||||
|
||||
|
Quote:
We have a VB app that we get results into ColdFusion from and use the COM object method. It works pretty well too. You can define functions in the VB file and call them using a COMName.functionName method. Or as mentioned by Kiteless, you could create a .vbs file and use cfexecute, although I don't think you can pass variables that way. |
|
#4
|
|||
|
|||
|
thanks people,
it's very vital capture the output. how about from java to cf? is it possible to capture the output of a java program? |
|
#5
|
|||
|
|||
|
It should be...Java returns everything as return statements since everything is a method call to an object. You can easily call methods on Java classes from CF using CFOBJECT or createObject().
|
|
#6
|
|||
|
|||
|
thanks Kiteless
i used <cfset newStr = CreateObject("Java", "GetUser")> <cfoutput>#newStr#</cfoutput> but it throws this error Object Instantiation Exception. Class not found: GetUser |
|
#7
|
|||
|
|||
|
The class must in the Java classpath. Check your OS environment variables and make sure that where every you've put your Java class, it's in one of the classpath directories.
|
|
#8
|
|||
|
|||
|
thanks kiteless,
i did add the .class file to the Java path. Now i get this error Method selection Exception. An exception occurred during method selection process for Method userName The cause of this exception was that either there are no methods with the the specified method name and argument types, or the method userName is overloaded with arguments types that Coldfusion can't decipher reliablly. Use javacast function to reduce ambiguity. this is my java program public class GetUser { public String userName() { String un = System.getProperty("user.name"); return un; } } and i call it by: <cfset newStr = CreateObject("Java", "GetUser")> <cfoutput>#newStr.userName()#</cfoutput> what am i doing wrong? |
|
#9
|
|||
|
|||
|
I think you must explicitly call the constructor...like this:
<cfset newStr = CreateObject("Java", "GetUser").init()> Does that help? |
|
#10
|
|||
|
|||
|
hmm, i guess we are getting closer.
i tried yours and it returns some values like GetUser@60315 GetUser@1cc2a8 GetUser@2fae6c ... everytime i refresh the page, i get a different value. i changed the java program to public class GetUser { public static void main(String args[]) { String un = gUser(); //System.out.println(un); } public static String gUser() { return System.getProperty("user.name"); } } if i take those // out, it displays the windows OS user name. so, what do i do to get my username instead of tens of different outputs? |
|
#11
|
|||
|
|||
|
Not sure on that one. I'm heading out for vacation for the next week, so if you still don't have it working by the time I return, I'll look at it again.
![]() Actually you don't need the main method. Just create a standard class that returns a string and call that one. Last edited by kiteless : November 5th, 2004 at 04:32 PM. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > VBScript to CF ? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|