SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
DDE statements in user defined functions

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
DDE statements in user defined functions
Author Message
Felix



Joined: 16 Aug 2003
Posts: 7

Post DDE statements in user defined functions Reply with quote


I have defined two functions:

1) "DDE_open() return number" as:

Dim channel, number

DDEOpen "Excel", "test.xls", channel

Return channel

2) "DDE_getdata(channel number) return string" as:

Dim buffer, string

DDEGetData channel, "R1CA", buffer

Return buffer

When I run this script (with Excel running on the correct sheet):

Dim channel, number

Dim buffer, string

DDE_open channel

DDE_getdata channel, buffer

MessageBox buffer

...

the system produces this error message:
"...Request R1CA failed. DDE error: Invalid parameter passed to DDE function."

Is there something that prevents the use of DDE functions in user defined functions?
I have tested that if all DDE operations are contained in the same user defined function all works fine.

I have tested this behaviour on a Win2k machine running 24x7 Scheduler ver. 3.4.12.

Any ideas?

Thanks!

Tue Sep 02, 2003 11:28 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7963

Post Re: DDE statements in user defined functions Reply with quote

Is "R1CA" a valid Excel reference?
Isn't it supposed to be in "R[row #]C[col #]" format?

: I have defined two functions: 1) "DDE_open() return number" as: Dim
: channel, number

: DDEOpen "Excel", "test.xls", channel

: Return channel

: 2) "DDE_getdata(channel number) return string" as: Dim buffer,
: string

: DDEGetData channel, "R1CA", buffer

: Return buffer

: When I run this script (with Excel running on the correct sheet): Dim
: channel, number

: Dim buffer, string

: DDE_open channel

: DDE_getdata channel, buffer

: MessageBox buffer

: ...

: the system produces this error message: "...Request R1CA failed. DDE
: error: Invalid parameter passed to DDE function."

: Is there something that prevents the use of DDE functions in user defined
: functions?
: I have tested that if all DDE operations are contained in the same user
: defined function all works fine.

: I have tested this behaviour on a Win2k machine running 24x7 Scheduler ver.
: 3.4.12.

: Any ideas?

: Thanks!

Tue Sep 02, 2003 11:50 am View user's profile Send private message
Felix



Joined: 16 Aug 2003
Posts: 7

Post Re: DDE statements in user defined functions Reply with quote

You are right!
I made a mistake writing a simple example to explain the problem that I found on my code. It should be "R1C1".
You can try. If You write in a script:

DDEOpen "Excel", "test.xls", channel
DDEGetData channel, "R1C1", buffer

it works. But:

DDE_open channel
DDE_getdata channel, buffer

(see my previous post) doesn't work...

: Is "R1CA" a valid Excel reference?
: Isn't it supposed to be in "R[row #]C[col #]" format?

Thu Sep 04, 2003 2:46 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7963

Post Re: DDE statements in user defined functions Reply with quote

I think the problem is not in DDE but in the way you defined DDE_getdata and/or your other DDE statements

For the sake of argument if you define buffer as a number and channel as string you may get various type conversion errors and making the script unusable. Please check you statement definitions and that you pass variables correctly.

If possible post your entire script.

: You are right!
: I made a mistake writing a simple example to explain the problem that I found
: on my code. It should be "R1C1".
: You can try. If You write in a script: DDEOpen "Excel",
: "test.xls", channel
: DDEGetData channel, "R1C1", buffer

: it works. But: DDE_open channel
: DDE_getdata channel, buffer

: (see my previous post) doesn't work...

Thu Sep 04, 2003 8:20 am View user's profile Send private message
Felix



Joined: 16 Aug 2003
Posts: 7

Post Re: DDE statements in user defined functions Reply with quote

From the "Script Library" window:

DDE_getdata ( channel number ) return string

DDE_open ( ) return number

Implementations:
DDE_getdata:
-----------
Dim buffer, string

DDEGetData channel, "R1C1", buffer

Return buffer

DDE_open:
--------
Dim channel, number

DDEOpen "Excel", "test.xls", channel

Return channel

Test script:
-----------
Dim channel, number
Dim buffer, string

//DDEOpen "Excel", "test.xls", channel
DDE_open channel

//DDEGetData channel, "R1C1", buffer
DDE_getdata channel, buffer

MessageBox buffer

DDEClose channel
----------
Really simple...but doesn't work:

Line 8: Line 4: Request R1C1 failed. DDE error: Invalid parameter passed to DDE function.

The strange is that if You check the correctness of the channel number with a message box in the two user functions You see the same number...

: I think the problem is not in DDE but in the way you defined DDE_getdata
: and/or your other DDE statements

: For the sake of argument if you define buffer as a number and channel as
: string you may get various type conversion errors and making the script
: unusable. Please check you statement definitions and that you pass
: variables correctly.

: If possible post your entire script.

Thu Sep 04, 2003 9:29 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7963

Post Re: DDE statements in user defined functions Reply with quote

Got it! 24x7 keeps track of open resources (opened with DDEOpen, FileOpen, DatabaseConnect, TelnetOpen and so on). On the script terminations it automatically cleans up any resources left open. As the result when it executes your DDE_Open function it closes the DDE channel when the function terminates. And so the returned channel becomes invalid and cannot be used in other scripts.

Therefore the solution is to keep all DDE calls in one script, or open/close new channel in every script.

Hope this helps.

: From the "Script Library" window: DDE_getdata ( channel number )
: return string

: DDE_open ( ) return number

: Implementations: DDE_getdata: -----------
: Dim buffer, string

: DDEGetData channel, "R1C1", buffer

: Return buffer

: DDE_open: --------
: Dim channel, number

: DDEOpen "Excel", "test.xls", channel

: Return channel

: Test script: -----------
: Dim channel, number
: Dim buffer, string

: //DDEOpen "Excel", "test.xls", channel
: DDE_open channel

: //DDEGetData channel, "R1C1", buffer
: DDE_getdata channel, buffer

: MessageBox buffer

: DDEClose channel
: ----------
: Really simple...but doesn't work: Line 8: Line 4: Request R1C1 failed. DDE
: error: Invalid parameter passed to DDE function.

: The strange is that if You check the correctness of the channel number with a
: message box in the two user functions You see the same number...

Thu Sep 04, 2003 12:09 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.