Page 1 of 1 1
Topic Options
#176284 - 2007-05-15 06:40 PM Creating Transactional Queues (MSMQ) in KiXtart
pearly Offline
Getting the hang of it
*****

Registered: 2004-02-04
Posts: 92
I'm having a tough time converting VB code into KiXtart. It has to do with the True constant value in VB that doesn't get recognized when I place alternative values -1 or 1.

Here is the VB Code:

 Code:
Sub CreateMyXactQueue(
                      strPathname As String
                      )
  Dim qinfo As MSMQQueueInfo
  
  Set qinfo = New MSMQQueueInfo
  qinfo.PathName = strPathname
  qinfo.Label = "TestQueue"
  
  On Error GoTo ErrorHandler
  qinfo.Create IsTransactional:=True
  
  MsgBox "Created Queue."
  Exit Sub
  
ErrorHandler:
  MsgBox "Error " + Hex(Err.Number) + " was returned." _
          + Chr(13) + Err.Description
End Sub


Without IsTransactional optional arg set to 'True', the sub-procedure creates non-transactional queues which I can create in KiXtart.

Here is the KiXtart code:

 Code:
Function CreateMyXactQueue($strPathname)
	Dim $qinfo
	
	$qinfo = CreateObject("MSMQ.MSMQQueueInfo")
	If @ERROR $CreateMyXactQueue = @ERROR EndIf
	$qinfo.PathName = $strPathname
	$qinfo.Label = "TestQueue"
	
	;$qinfo.Create(1)
	$qinfo.Create(-1)
	If @ERROR $CreateMyXactQueue = @ERROR EndIf
EndFunction


I'm pretty sure 'True' in VB equals -1, but I've tried everything to make this work, but failed. If someone can shed some light on this, I'd appreciate it.

Top
#176289 - 2007-05-15 09:17 PM Re: Creating Transactional Queues (MSMQ) in KiXtart [Re: pearly]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Try this:

$TRUE = NOT 0

$qinfo.Create($TRUE)

Top
#176290 - 2007-05-15 09:20 PM Re: Creating Transactional Queues (MSMQ) in KiXtart [Re: Shawn]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
If this works and you wonder why ... trace this:

?"VarTypeName=" + VarTypeName($TRUE)

versus this:

?"VarTypeName=" + VarTypeName(-1)

Top
#176291 - 2007-05-15 09:24 PM Re: Creating Transactional Queues (MSMQ) in KiXtart [Re: Shawn]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
If that doesn't work ... then its the following:

The VB code is using "named parameters" instead of positional paramaters - i forget the terminology but the point is that the Create method prolly takes more than one argument - and specifying it like this:

qinfo.Create IsTransactional:=True

allows you to pass the IsTransactional without actually knowing which "parm number" it is - it may be the first parm, or the second, or the last of many.

If this is the case - then you have to research the layout of the call, then dummy-out any parm before the one you want, like this:

$qinfo.Create(,,,$TRUE)

The trailing ones you can ignore. Hope this helps.


Top
#176292 - 2007-05-15 09:39 PM Re: Creating Transactional Queues (MSMQ) in KiXtart [Re: Shawn]
pearly Offline
Getting the hang of it
*****

Registered: 2004-02-04
Posts: 92
Shawn you rock!!!

I didn't know you can do the following

$TRUE = NOT 0

And yes there's a big difference between the code above and $TRUE = -1

Boolean vs. Long

Here's the final code:

 Code:
Function CreateMyXactQueue($strPathname)
	Dim $qinfo
	Dim $TRUE
	
        $TRUE = Not 0
	$qinfo = CreateObject("MSMQ.MSMQQueueInfo")
	If @ERROR $CreateMyXactQueue = @ERROR EndIf
	$qinfo.PathName = $strPathname
	$qinfo.Label = "TestQueue"
	$qinfo.Create($TRUE)
	If @ERROR $CreateMyXactQueue = @ERROR EndIf
EndFunction

Top
#176293 - 2007-05-15 09:42 PM Re: Creating Transactional Queues (MSMQ) in KiXtart [Re: Shawn]
pearly Offline
Getting the hang of it
*****

Registered: 2004-02-04
Posts: 92
 Originally Posted By: Shawn
If that doesn't work ... then its the following:

The VB code is using "named parameters" instead of positional paramaters - i forget the terminology but the point is that the Create method prolly takes more than one argument - and specifying it like this:

qinfo.Create IsTransactional:=True

allows you to pass the IsTransactional without actually knowing which "parm number" it is - it may be the first parm, or the second, or the last of many.

If this is the case - then you have to research the layout of the call, then dummy-out any parm before the one you want, like this:

$qinfo.Create(,,,$TRUE)

The trailing ones you can ignore. Hope this helps.



Thanks Shawn. Yes I looked in MSDN when I was first creating the function. This is what it says:

The Create method of the MSMQQueueInfo object creates a public or private queue based on the properties of the MSMQQueueInfo object.
CopyCode imageCopy Code

Sub Create( _
[ ByRef IsTransactional As Variant ], _
[ ByRef IsWorldReadable As Variant ] _
)

Parameters

IsTransactional

[in, optional] Boolean. When True, it indicates that the queue is a transactional queue. All messages sent to a transactional queue or read from a transactional queue must be done as part of a transaction. The default is False.

IsWorldReadable

[in, optional] Boolean. When True, all members of the Everyone group can read the messages in the queue and its queue journal. When False, only the owner can read the messages. The default is False.

So it was the first argument of the method.

Top
#176294 - 2007-05-15 09:49 PM Re: Creating Transactional Queues (MSMQ) in KiXtart [Re: pearly]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
hehee great - you did your homework and you got it to work. just know that not all com objects are so "picky". most of them will take a plain-old 1 or -1 as a true - depends on how the guy coded it. only ever seen one other case like this in all my days (cant remember - think its a certain wmi call).
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 313 anonymous users online.
Newest Members
Jojo67, MaikSimon, kvn317, kixtarts2025, SERoyalty
17873 Registered Users

Generated in 0.103 seconds in which 0.079 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org