Andy_P

Read an array of strings from NJ to NA

11 posts in this topic

I have an array of 1000 strings in an NJ controller, and I wish to read them into an NA HMI.

To do this at the moment I am using Array.Copy within some vb code, but this seems to hang the screen as it takes way too long, if it ever completes at all.

i.e. Array.Copy(NJ_array, NA_array, 1000)

also, the docs for Array.Copy state that the destination array needs to be greater in size than the source array, which seems bizarre.

Any recommendations on how to do this more efficiently?

Share this post


Link to post
Share on other sites

Why do you need to copy the Strings? Why not just use the Variable Map in NA to get the values of the said Strings inside NJ?

Share this post


Link to post
Share on other sites

I need to read them all in at once, and this way also takes a very long time.

I am trying to populate a ListBox with the string data.

Share this post


Link to post
Share on other sites
Quote

i.e. Array.Copy(NJ_array, NA_array, 1000)

Looking at this you clearly had to map your NJ String arrays into that NJ_array variable. You already have the updated list of those strings, so I don't understand why you need to copy them again to another string array...

Quote

also, the docs for Array.Copy state that the destination array needs to be greater in size than the source array, which seems bizarre.

All Copy/Paste process eventually will use an indexing process with some kind of "for loop" inside it. I doubt the variables are being copied all at once. The size difference might have something to do with the "for loop" implementation.

 

Quote

I am trying to populate a ListBox with the string data.

Unfortunately you cannot change the Text inside ListBox object dynamically. Same goes for ComboBox/DropDown.

There is no way to do so in NA. It's kind of suck, eventhough the IDE utilizes Visual Basic, the functionality is very limited.

Share this post


Link to post
Share on other sites
19 hours ago, innoaloe said:

Unfortunately you cannot change the Text inside ListBox object dynamically. Same goes for ComboBox/DropDown.

There is no way to do so in NA. It's kind of suck, eventhough the IDE utilizes Visual Basic, the functionality is very limited.

 

Yes you can. I am doing it by:

ListBox0.SetItems(arrayOfObjects)

 

The array has to be an array of Objects, (and not strings, integers, etc.) because that is all the Compact .NET Framework in the NA supports.

Share this post


Link to post
Share on other sites

 

What is calling the array.copy sub? Can you copy the array in the background before calling the list box?

 

Share this post


Link to post
Share on other sites
18 hours ago, Andy_P said:

 

Yes you can. I am doing it by:

ListBox0.SetItems(arrayOfObjects)

 

The array has to be an array of Objects, (and not strings, integers, etc.) because that is all the Compact .NET Framework in the NA supports.

 

Weird, because I cannot find that SetItems function anywhere in a ListBox component, even on the latest NA firmware version (1.08). Can you perhaps post a screenshot when the Intellisense shows this function?

Regarding changing type to Object instead of String, wouldn't CType function work? It is used to convert / cast types without copying it to a new variable

Share this post


Link to post
Share on other sites

Intellisense doesn't show it, but trust me, it is there and it works.

This is a bug in the NA/Sysmac Studio software in my opinion. This is not the only function that is missing either.

Omron need to improve this.

Share this post


Link to post
Share on other sites

Well... that's definitely annoying. Gonna try it this afternoon, thanks.

Share this post


Link to post
Share on other sites

I couldn't find a solution to this, so I have moved all the strings from retained memory in the NJ into retained memory in the NA.

This works, as the NA can now For..Next loop through internal memory instead of reading each one from the NJ.

However, this means I now have a bit of a disconnect between the data stored in the NJ and what is now stored in the NA. This is a bit annoying, but it is a solution of sorts for my application at present.

Share this post


Link to post
Share on other sites
4 hours ago, Andy_P said:

I couldn't find a solution to this, so I have moved all the strings from retained memory in the NJ into retained memory in the NA.

This works, as the NA can now For..Next loop through internal memory instead of reading each one from the NJ.

However, this means I now have a bit of a disconnect between the data stored in the NJ and what is now stored in the NA. This is a bit annoying, but it is a solution of sorts for my application at present.

my recipe control is usually on a popup, so when when i open page the page displayed event calls my ListBox_Update sub;

Sub ListBox_Update
    Dim List_obj As Object 
    Dim array(100) As String
    Dim x As Integer
    For x = 0 To 99
        array(x) = ListItems(x)
    Next x
    List_Obj = array
    listbox0.SetItems(List_Obj)
End Sub

Haven't tried with a larger array though.

Share this post


Link to post
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