Jump to content

Interprocess communication help


Champak
 Share

Recommended Posts

You are testing for the equivalence of "All"
but I can not see what your script actually returns.  What is "All" being compared to? 0="All" ? or "all"=="All"  --- is this perhaps better resolved as a regex issue?

Skysnake

Why is the snake in the sky?

Link to comment
Share on other sites

OK, here is what I've figured out. It is MailSlot that is messing with the first column of a multi D array....as far as I can see.

I've provided a script that demonstrates exactly that.

1/ Under "internal operation", script testSend demonstrates a 2D array being turned to a string, and then back to an array and then testing the value of an element in column 0, 1, 2. All tests return with no issue.

2/ Now comment out "internal operation", and uncomment "mailslot operation" and compile testReceive. What will happen is testReceive will only see the element in column 1, 2. Then if I inject the value into column 0 it will be seen.

This took all night to brake down and figure out because one minute it seemed to work and the next it didn't.

 

Here are the files.

testSend.au3

testReceive.au3

MailSlot.au3

Edited by Champak
Link to comment
Share on other sites

  • Moderators

Champak,

Quote

It is MailSlot that is messing with the first column of a multi D array

Rubbish. I have just tested using modified versions of the script I posted earlier in this thread and your array is passed perfectly. Compile and run both, update "SendTest" to get the correct address and then send/receive:

  

 

I will look at your scripts later today to see if I can spot where you have introduced the error.

M23

Edit: You appear to be trying to pass the array directly rather then reducing changing it to a string first:

_MailSlotWrite($hMailSlotToNav, $NAV_OPTIONS_ARRAY, 2, "80")

and then expecting it to automagically be read as an array on receipt:

Local $sData = _MailSlotRead($hMailSlotToNav, $iSize, 2)
    Switch $sData[0]

As you can see from the scripts I posted a little earlier, you need to convert the array to a string, pass the string, and then recreate the array on reception - then you get the array exactly as sent, although all elements are strings and might need to be recast as already mentioned.

Edited by Melba23
Added comments

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Did you look at the MailSlot that I attached? That is what is taking care of the conversions. If I wasnt converting, how did I get the array to pop up in the receiving app? My error is that my MailSlot has an #include file that has the actual function that is converting it back to an array and I forgot o adjust that before posting here. So, if you take that function in the testSend that I have and put it in my MailSlot you will see what I mean.

I'm on an Ipad so I cant read those files you just posted, I'll check them later. And your original post with the ini was not helping my situation, that's why I came up with this.

Link to comment
Share on other sites

  • Moderators

Champak,

Did you look at the MailSlot that I attached?

No, because you had not explained that you had modified it.

Now I have looked at it and seen what you have changed (which incidentally I consider a very bad idea (much better to keep the UDF as it was and add the new code in your own scripts) I have modified the test files so that they pass the array directly and expect to receive one back and guess what? They still pass the array just fine.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

@Champak: if you're looking for generic multi-purpose IPC solutions, you may wish to check out my Pool environment (in my signature below). It can send arrays directly (or anything else), and takes care of all required conversions internally. But beware, I provide no support for that one, so you'd have to figure out yourself how it works from my detailed comments and example scripts.

@Melba: sorry for interrupting...

Link to comment
Share on other sites

  • Moderators

RTFC,

Be my guest...

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

@RTFC, it looks good, but looks complicated...on the surface, especially with no support. I've already invested in this and just want to see it through from what I've put in. If nothing comes about then I'll dive into yours. Thanks.

@Melb23, again, you are not looking at what I'm providing. I have no problem passing an actual array as I've stated in all my previous posts. My issue is the elements in the first column in any array passed are not being read properly. They are being passed, but cannot be evaluated properly...I don't know the proper terminology. And the same thing is happening with your test files...it does not pass the array "just fine".

Put this in your receive file right before your "Received Array" display and see what happens. See if line 2 gives you the MsgBox.

MsgBox(0,0,$aArray[3][0])
        If $aArray[3][0] = "Mr" Then MsgBox(0,0,"Same")
        MsgBox(0,0,$aArray[3][1])
        If $aArray[3][1] = "Mar" Then MsgBox(0,0,"Same")

 

Link to comment
Share on other sites

  • Moderators

Champak,

Now you have actually explained the problem, I have solved the mystery. It would have been a lot easier had you given more details earlier rather then expecting me to work through 2 uncommented scripts and a modified UDF with no real idea of the error for which I am looking. Had you mentioned from the outset that the elements were not matching in a comparison that would have been a good clue - as it was you said:

What will happen is testReceive will only see the element in column 1, 2

implying that the [0] element is missing - which is obviously is not. So please in future explain any problems you have in detail - then we will not waste our time looking for things which are not actually the problem. So, to the real solution:

When you convert the array to a string, the EndOfRow is signalled by default with a @CRLF - when you recreate the array in your  _StringToMultiDArray function, you only look for the @CR. So the @LF remains attached to the start of each of the [#][0] elements in the reconstructed array. This is quite clear if you use BinaryToString to look at the content of the [3][0] element - you send 0x4D72 and receive 0x0A4D72.

So you either need to convert the array to a string using @CR as the delimiter (the $sDelim_Row parameter lets you do this) or change your  _StringToMultiDArray function to use @CRLF as the delimiter when reconstructing the array (the better choice in my opinion).

Top Tip: When strings which should match do not, always convert them to binary to see if there is a non-printing character which is causing the difference - as in this case, visual inspection is often not enough.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

First, Thank you Melba23, I wouldn't have found the issue if not for you. Even if I looked at BinaryToString, I probably wouldn't know what to make of it.

Now, again, you are not paying attention to what I say. Because from post 15 I clearly stated that the array is passing and I'm unable to evaluate what I am seeing,

My real issue is when I'm trying to read out "words" and do an evaluation/comparison it just wont work no matter what I try...even trying to put it into a variable.

Ex: This doesn't work:

If $NAV_OPTIONS_ARRAY[3][0] = "All" Then

Now if I put $NAV_OPTIONS_ARRAY[3][0] in a MsgBox in App 'B' I see "All" in it as I should. I've stripped white space as well and nothing. How do I get App 'B' to see the actual value? How do I recast a 'word'?

and you clearly responded to it so I don't know how you can say now that I didn't let you know what my issue was from earlier, and I continued from there. I've made my issue explicitly clear from the beginning (to the best of my ability) and progressed with it on from there...maybe not explicitly restating it, but I didn't think I would need to. The fact that I didn't think I needed to may be my issue, but I thought once I had the help from people reading the thread, they would progress through it with me. As far as commenting in the script I didn't see a need since I clearly detailed what the script was doing and what it was producing in both scenarios and reading the script is straight forward with no complicated functions. That's like me putting "GUICtrlCreateLabel; This creates a label" after I told you I was creating a label in the script. All the functions in my example are the MailSlot which you use, clear uncomplicated calls to autoit's library, and my adaptation to the _StringToMultiDArray...which I couldn't really explain at the time anyway. The same thing I put in post 28 that you all of a sudden saw, I put in my working script example and explained, and I originally stated in post 15. MISUNDERSTANDING? fine, but don't say I didn't state my issue. Sometimes progressing throughout a thread the original issue can get lost in understanding and not explicitly reiterated in the same manner throughout. I just took slight offense in the way you chose to respond and felt your statements needed to be addressed.

As for _StringToMultiDArray(), I actually thought that the @CR was the issue when I started out to fix this, but when I changed it to @CRLF originally it caused other problems, so I put it back since it wasn't causing an issue without MailSlot thinking it must be MailSlot. With you pointing out what was actually happening I delved a bit deeper and changed the function around to the following. And in creating any of my arrays, I now add "NULL" in any empty element.

Func _StringToMultiDArray($str)

    Local $aArray=StringSplit($str ,"|" & @CRLF)
        For $i = UBound($aArray) - 1 To 0 Step - 1
            If $aArray[$i] = "" Then _ArrayDelete($aArray, $i);Get rid of empty rows
        Next
    Local $iFilas=StringSplit($str,@CRLF)
        For $i = UBound($iFilas) - 1 To 0 Step - 1
            If $iFilas[$i] = "" Then _ArrayDelete($iFilas, $i);Get rid of empty rows
        Next
        $NewCount = UBound($iFilas);Get new count
    Local $iCol=StringSplit($iFilas[1],"|")[0]
    $iFilas=$iFilas[0]
    Local $aArray2D[$NewCount-1][$iCol]
    Local $i=0
    For $f= 0 to $NewCount-2
        For $c=0 to $iCol-1
            $aArray2D[$f][$c]=$aArray[$i+$c+1]
        Next
        $i+=$iCol

    Next

    If UBound($aArray2D) < 2 Then $aArray2D = _StringExplode($str, "|");Test if it's one column, if it is just explode the original variable so it's a 1d array

    Return $aArray2D

EndFunc

Regardless of everything else, I respect and appreciate all your help Melba23, thanks.

Link to comment
Share on other sites

  • Moderators

Champak,

Now, again, you are not paying attention to what I say

That is certainly true from now on - because I will not be reading it.

M23 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...