AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Embedded Windows Scripting (VBScript & JScript) and COM
Goto page Previous  1, 2, 3 ... 9, 10, 11, 12, 13  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
free2code



Joined: 19 Oct 2008
Posts: 12

PostPosted: Mon Nov 24, 2008 2:08 am    Post subject: Reply with quote

Erictheturtle, here's what I've discovered. What you advised only works with a Sub and not a Function, for some reason. So it works for:
Code:

WS_Exec("CSUpdate " . VBStr(Val) )


but not

Code:

WS_Eval(Success, "CSUpdate " . VBStr(Val) )


Any ideas as to why this is the case?

I still am yet to try passing several variables...
Back to top
View user's profile Send private message
erictheturtle



Joined: 27 Jun 2007
Posts: 90
Location: California

PostPosted: Mon Nov 24, 2008 6:11 pm    Post subject: Reply with quote

free2code wrote:
WS_Eval(Success, "CSUpdate VBStr(Var1), VBStr(Var2), VBStr(Var3), VBStr(Var4), VBStr(Var5), VBStr(Var6), VBStr(Var7)")


Ah free2code, you need to work on recognizing strings and concatenation. ;)

Code:
WS_Eval(Success, "CSUpdate " . VBStr(Var1) . "," . VBStr(Var2) . "," . VBStr(Var3) . "," . VBStr(Var4) . "," . VBStr(Var5) . "," . VBStr(Var6) . "," . VBStr(Var7) )

A good syntax highlighter might help with that.
_________________
-m35
Back to top
View user's profile Send private message
erictheturtle



Joined: 27 Jun 2007
Posts: 90
Location: California

PostPosted: Tue Nov 25, 2008 5:38 am    Post subject: Reply with quote

free2code wrote:
Erictheturtle, here's what I've discovered. What you advised only works with a Sub and not a Function, for some reason. So it works for:
Code:

WS_Exec("CSUpdate " . VBStr(Val) )


but not

Code:

WS_Eval(Success, "CSUpdate " . VBStr(Val) )


Any ideas as to why this is the case?

I still am yet to try passing several variables...


Oh sorry free2code, I missed this followup post. The problem here seems to be that you're using incorrect VBScript syntax. In VBS, to call a function with a return value, you use this syntax.
Code:
result = CSUpdate(Val)


So the AHK code should pass a similar formatted string to be evaluated.
Code:
WS_Eval(Success, "CSUpdate(" . VBStr(Val) . ")")
I wasn't paying close enough attention to your previous post to notice it had the same problem. I'm pretty sure if you had checked ErrorLevel it would have mentioned something about this.

In the next version release of ws4ahk, I think by default I may have it display a message when there is an error.
Back to top
View user's profile Send private message
free2code



Joined: 19 Oct 2008
Posts: 12

PostPosted: Wed Nov 26, 2008 10:07 pm    Post subject: Reply with quote

Thanks again, Erictheturtle, that was very helpful Smile
Back to top
View user's profile Send private message
e.miranda
Guest





PostPosted: Wed Jan 28, 2009 5:49 pm    Post subject: scriptcontrol.timeout Reply with quote

It there a way to adjust the scriptcontrol timout duration in ws4ahk.ahk?

I currently am trying to query an Oracle database via SQL in a vbscript using ws4ahk. But when querying large datasets, I get a script control message stating that "The script you are executing is taking longer than expected..." after it's been executing longer than 10 seconds.

Thanks in advance.
Back to top
erictheturtle



Joined: 27 Jun 2007
Posts: 90
Location: California

PostPosted: Wed Jan 28, 2009 9:38 pm    Post subject: Re: scriptcontrol.timeout Reply with quote

e.miranda wrote:
It there a way to adjust the scriptcontrol timout duration in ws4ahk.ahk?

I currently am trying to query an Oracle database via SQL in a vbscript using ws4ahk. But when querying large datasets, I get a script control message stating that "The script you are executing is taking longer than expected..." after it's been executing longer than 10 seconds.

Thanks in advance.

I was wondering when someone was going to need this. ;)
The functionality will be added to ws4ahk.ahk soon. For now, you can use this SetTimeout function.

Code:
; Set timeout in milliseconds
SetTimeout(iTimeout)
{
   global __WS_iScriptControlObj__
   iErr := DllCall(__WS_VTable(__WS_iScriptControlObj__, 14), "UInt", __WS_iScriptControlObj__
            , "Int", iTimeout
            , "Int")
}


; ------  Test -----------

#include ws4ahk.ahk

WS_Initialize()

SetTimeout(20 * 1000) ; 20 seconds

; Loop for a long time
sCode =
(
For i = 1 to 100000
   For j = 1 to 10000
   Next
Next
)

WS_Exec(sCode)

_________________
-m35
Back to top
View user's profile Send private message
e.miranda
Guest





PostPosted: Thu Jan 29, 2009 12:36 pm    Post subject: Reply with quote

Thanks. Now I have another issue.

In my search to not use a 3rd party app, and not create a temp file, I've been experimenting with vbscript using the ws4ahk.ahk function. I've been able to execute SQL and pass the results into ahk variables with it. But queries that result in large datasets are failing. Whereas the same query processed with T4eSQL will execute results fine.

I'm new to vbscript so maybe there is an issue with my code:
Code:
WS_Initialize("VBScript")
SetTimeout(1000 * 1000)
vbcode =
(
Option Explicit

'CONNECTION CODE
   Dim sCS
   Dim CON
   sCS  = "Driver={Oracle in OraHome92};Dbq=diamprod;Uid=emiranda;Pwd=jlsjdfslfsd"
   Set CON = CreateObject( "ADODB.Connection" )
   CON.Open sCS

'SQL STATEMENT
   Dim sSQL     
   sSQL = "%MsearchSQL%"

   'RECORDSET CREATION   
   Dim RS
   Set RS = CON.Execute( sSQL )
   'Set rs = createobject("ADODB.recordset")
   'rs.open sSQL
 
   dim details
   dim field
   while not RS.eof
   for each field in RS.fields
   details = details & field & "|"
   next
   details = details & vbcr
   RS.movenext
   wend
   set RS = nothing 'Clear up memory used
   CON.close
)

WS_Exec(vbcode)
WS_Eval(MsearchFile,"details")
WS_Uninitialize()
Back to top
erictheturtle



Joined: 27 Jun 2007
Posts: 90
Location: California

PostPosted: Thu Jan 29, 2009 4:48 pm    Post subject: Reply with quote

You might try checking what error is occurring like this
Code:
WS_Exec(vbcode)
Msgbox % ErrorLevel
WS_Eval(MsearchFile,"details")
Msgbox % ErrorLevel


Also try putting your VB code into a .vbs file and running it to see if it fails there as well.
_________________
-m35
Back to top
View user's profile Send private message
e.miranda
Guest





PostPosted: Thu Jan 29, 2009 6:31 pm    Post subject: Reply with quote

Thanks.

I now don't think it is an issue with ws4ahk. It looks like the query is running fine, except for large datasets it is taking an inordinate amount of time to run. That's why I was getting the timeout errors initially.

So I think it has to do with how I'm query ORACLE with vbs. I'll have research it more. Thanks.
Back to top
webber



Joined: 25 Aug 2005
Posts: 129

PostPosted: Tue Feb 17, 2009 8:06 pm    Post subject: VbScript Call statement is not supported ? Reply with quote

Seems the vbscript call statement is not supported:

Code:


#include ws4ahk.ahk
WS_Initialize()
SomeVBCode =
(
Sub DisplayValue(value)
  Msgbox value
End Sub
)
WS_Exec(SomeVBCode) ; add the VB function to the script environment

ahkVariable := "(hello AHK string)"
WS_Exec("Call DisplayValue """ . ahkVariable . """")
WS_Uninitialize()
Back to top
View user's profile Send private message
erictheturtle



Joined: 27 Jun 2007
Posts: 90
Location: California

PostPosted: Tue Feb 17, 2009 9:23 pm    Post subject: Re: VbScript Call statement is not supported ? Reply with quote

webber wrote:
Seems the vbscript call statement is not supported

It is when you use proper synax ;)

Code:
WS_Exec("Call DisplayValue(""" . ahkVariable . """)")

_________________
-m35
Back to top
View user's profile Send private message
webber



Joined: 25 Aug 2005
Posts: 129

PostPosted: Wed Feb 18, 2009 12:43 am    Post subject: Reply with quote

thanks

mine should have been:

Code:

ahkVariable := "(""hello AHK string"")"


will this system allow for making the vbscript portion as an include file ? something like:

Code:

....
[
SomeVBCode=
(
#include vbs.txt
)

...
Back to top
View user's profile Send private message
erictheturtle



Joined: 27 Jun 2007
Posts: 90
Location: California

PostPosted: Wed Feb 18, 2009 3:20 am    Post subject: Reply with quote

webber wrote:
will this system allow for making the vbscript portion as an include file ?

No, ws4ahk, and the underlying Windows Scripting Control don't have any kind of include functionality.

However it should be fairly easy to do with just a little Autohotkey.
Code:
FileRead, SomeVBCode, vbs.txt

_________________
-m35
Back to top
View user's profile Send private message
webber



Joined: 25 Aug 2005
Posts: 129

PostPosted: Wed Feb 18, 2009 6:28 am    Post subject: Reply with quote

that works, and using the AHK include seems to work also.

This is a good thing.

thanks for making AHK a world better Very Happy
Back to top
View user's profile Send private message
webber



Joined: 25 Aug 2005
Posts: 129

PostPosted: Sun Feb 22, 2009 6:23 am    Post subject: need a bot more help on ws_eval Reply with quote

cannot retrieve a value from this vbs function

Code:

   Function GetClipboard()   
   
      Set WshShell = CreateObject("WScript.Shell")

       ' create IE instance - used for clipboard access
      '------------------------------------------------
      Set oIE = CreateObject("InternetExplorer.Application")
      oIE.navigate "about:blank"   ' empty document
      oIE.visible = 0              ' hidden

      Do While (oIE.Busy)          ' wait till IE ready
         WshShell.Sleep 50
      Loop   

       ' Read text from clipboard ...
      '------------------------------
      clipboard = oIE.document.parentWindow.clipboarddata.getData("text")
        clipboard = "clipboard result from vbs : " & clipboard
        msgbox clipboard
        GetClipboard = clipboard
        
      oIE.Quit
      WshShell.quit
      
   End Function



The vbs msgbox reports result correctly but nothing is returned to the ahk file using

Code:


   WS_Eval(Ret, "GetClipboard()")
   Msgbox % Ret



other functions from the same vbs source file are working correctly.

what am I missing
Question
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3 ... 9, 10, 11, 12, 13  Next
Page 10 of 13

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group