AutoHotkey Community

It is currently May 26th, 2012, 1:26 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 232 posts ]  Go to page Previous  1 ... 7, 8, 9, 10, 11, 12, 13 ... 16  Next
Author Message
 Post subject:
PostPosted: November 24th, 2008, 3:08 am 
Offline

Joined: October 19th, 2008, 11:51 pm
Posts: 12
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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 24th, 2008, 7:11 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 25th, 2008, 6:38 am 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 26th, 2008, 11:07 pm 
Offline

Joined: October 19th, 2008, 11:51 pm
Posts: 12
Thanks again, Erictheturtle, that was very helpful :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject: scriptcontrol.timeout
PostPosted: January 28th, 2009, 6:49 pm 
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.


Report this post
Top
  
Reply with quote  
PostPosted: January 28th, 2009, 10:38 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2009, 1:36 pm 
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()


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2009, 5:48 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2009, 7:31 pm 
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.


Report this post
Top
  
Reply with quote  
PostPosted: February 17th, 2009, 9:06 pm 
Offline

Joined: August 25th, 2005, 9:40 pm
Posts: 129
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()

________
Vaporizer wholesaler


Last edited by webber on February 11th, 2011, 5:57 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 17th, 2009, 10:23 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
webber wrote:
Seems the vbscript call statement is not supported

It is when you use proper synax ;)

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

_________________
-m35


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2009, 1:43 am 
Offline

Joined: August 25th, 2005, 9:40 pm
Posts: 129
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
)

...

________
Extreme Q Vaporizer


Last edited by webber on February 11th, 2011, 5:57 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2009, 4:20 am 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2009, 7:28 am 
Offline

Joined: August 25th, 2005, 9:40 pm
Posts: 129
that works, and using the AHK include seems to work also.

This is a good thing.

thanks for making AHK a world better :D
________
Ultimate fighters


Last edited by webber on February 11th, 2011, 5:57 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 22nd, 2009, 7:23 am 
Offline

Joined: August 25th, 2005, 9:40 pm
Posts: 129
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
:?:
________
MEDICAL MARIJUANA PATIENT


Last edited by webber on March 11th, 2011, 12:28 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 232 posts ]  Go to page Previous  1 ... 7, 8, 9, 10, 11, 12, 13 ... 16  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, maraskan_user, Yahoo [Bot] and 15 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group