I want to work with a dynamic array using visual basic and I want that each element of the array will be an individual dynamic array too. How I should proceed? Thanks.
Read this - https://msdn.microsoft.com/en-us/library/aa716275(v=vs.60).aspx
And also this, in case you decide that reDim-ing things is annoying: https://msdn.microsoft.com/en-us/library/system.collections.arraylist(v=vs.110).aspx
Essentially though, you want to make an array and fill it with arrays. Then just treat those arrays independently for re-sizing purposes.
Related
When using the MATLAB jsonencode function it seems very difficult to convert size 1 arrays into the correct JSON format i.e. [value]. For example if I do:
jsonencode(struct('words', [string('hello'), string('bye')]))
Then this produces:
{"words":["hello","bye"]}
which is correct. If however I do:
jsonencode(struct('words', [string('hello')]))
Then it produces:
{"words":"hello"}
losing the square brackets, which it needs because it is in general an array. The same happens when using a cell rather than an array, although using a cell does work if it's not inside a struct.
Any idea how I can work around this issue?
It seems this can be solved by using a cell rather than an array and then not creating the struct inline. Like
s.words = {'hello'};
jsonencode(s)
Output:
{"words":["hello"]}
I presume when created inline the cell functionality of matlab is actually trying to make multiple structs rather than multiple strings. Note that this still won't work with arrays as matlab treats a size one array as a scalar.
I am creating a Sudoku project in vb.net, to such an end I need to store a list of all the possibilities for each square where the squares are indexed by one number. for example the computer needs to know that for square [8] the numbers {1,3,5,9} are possible etc... I began by using a jagged array however there is no apparent 'remove' method which needs to be called a lot. this makes my code looks ugly with all the redim statements in it and so I was curious as to whether a list or arraylist would be best suited to my purposes? I have discovered arraylists have a remove method but I have also read that array lists are all but deprecated and i want to know if there is a nicer solution to this.
I am trying to debug code that works with byte arrays of extremely large sizes (7 million or so bytes), but the built in functionality of VS is insufficient, Array Visualizer cannot handle such sizes, and you cannot write your own custom debugging visualizers to work with arrays. Is there an easy way to visualize or inspect regions of the array from within visual studio so I do not have to write the array to file and inspect it with a hex editor?
Thanks!
If you are debugging native languages you can use the following:
You can use the syntax (array + offset), to watch a particular range of elements starting at the offset position (of course, array here is your actual object). If you want to watch the entire array, you can simply say array, count.
http://www.codeproject.com/Articles/469416/More-Visual-Studio-Debugging-Tips-for-Native-De
is there a way to create a fixed size array in LabView?
I know that I can do some check on the array size, then discard values when an array size become greater than a specific value. But, I think that is a common problem, so there is some built in function in LabView to have a fixed size array?
As far as I know this is impossible, unless they changed something in one of their latest releases but I doubt it: it would probably require a serious rewrite of the core array code.
The closest you can get is writing your own (possibly polymorphic) array class in which you encapsulate an actual array, that you initialize once with a certain size. For the rest your class only exposes methods to get/set by index. No resize etc.
Or, if you are talking about arrays of controls etc on the front panel, you can probably do this at the UI level by hide the indexing control from it and making sure it cannot be resized graphically. Or probably it's also doable to create a custom control and strip lots of array functionality from it.
If the array size is fixed at design time, then you might consider using a cluster instead. There is even a primitive to convert an array to a cluster of fixed size, provided the length is less then 257. (Array To Cluster function.)
There is also a primitive to go the other way if you need to index the array.
One implementation that you could do is a queue with a fixed size. You can use preview queue and flush queue to implement the functionality you want. However a specific custom class is probably a better idea.
In regular desktop LabVIEW, fixed-sized arrays would be something you'd have to code as per the answers you've already gotten here. However, in LabVIEW FPGA with, say, cRIO, all arrays must be fixed-size.
When calling the Call Library Function Node to a WINAPI DLL, there are times where a structure element may be officially be defined as BYTE[130]. So how do you absolutely, positively make sure your cluster has exactly the space for 130 bytes?
You can't do it with arrays no matter what, because LabVIEW arrays are pointers to a structure (the first element being the length), meaning any array you insert will only allocate enough space for a pointer, 4 bytes.
The work-around I came up with is to insert a cluster that includes sixteen U64 and one U16, pass that through an unflatten to string and you'll find it's exactly 130 bytes long.
When the cluster returns from the call, merely type cast the flattened into string results into a U8 array
Is it possible to create a multidimensional array of gtkwidgets? Specifically something like this:
mywidgetlist[2]["title"];
Or should I be doing this in a different way? How would I do this?
Basically I have a number of "widgets" (Loaded from gtkbuilder) composed of smaller widgets and I want to be able to change certain values, so this array setup seems preferable.
Is there another way of doing this (Other than actually coding a complete widget using signals etc and placing them in a simple array?)
In C, you cannot use a string to index into an array. Or, strictly speaking you can, but it's almost never what you want to do.
For C solution using glib (handy if you already use GTK+), consider a single-dimensional array of GHashTable pointers.