For Each instruction based on a dynamic array - arrays

I'm currently experiencing the following problem:
For Each item In Array
If isItemInTheArray(Array, item) Then
removeItem(Array, item)
End If
Next
But the problem is, when removing the current item (i.e. index = 0), the next item which should be taken by the for each is still index 0 and not the index 1.
To sum up, in vb.net, how to tell to "for each" that the next item it should take is still the first one (i.e. index 0) and not the obvious next one (i.e. index 1)?
EDIT:
Maybe I could be more specific.
I have many pieces of music in my drive which are stock like following:
Each .mp3 file is in a folder like "Blob-release2018\blob.mp3"
Each music folder contains different types of file like ".mp3", ".nfo" or ".jpg"
Some music has 2 version : "extended" for DJing and "edited" for radio broadcasting
Some music folder contains albums, so different .mp3 but not the same music...
I want to scan my all music path and populate a grid view with ".mp3" files. But if I have 2 version of a song, I need only 1 line with a "version extd" / "version edit" checkbox checked to show which version I have....
EDIT: Problem solved by using a custom class and check before adding in a collection. Thanks to #Craig ! More details in comment zone

Related

How to verify words one by one on a locator in Robot Framework?

I am still a bit new to the robot framework but please rest assured I am constantly reading its User Guide. I am a bit stuck now with one test case.
I do have a list of individual words, that I need to verify on a page, mostly German translations of field labels if they appear correctly or are found in an element at all.
I have created a list variable as follows:
#{GERMAN_WORDS} | Benutzer | Passwort | Sendung | Transaktionen | Notiz
I have the following locator that contains the text labels on the webpage, and the one I need to verify:
${GENERAL_GERMAN_BOARD} |
xpath=//*[#id="generalAndIncidents:generalAndIncidentsPanel"]
I would like to check every single word one by one from the list variable, whether they are present in the locator above.
I did create the following keyword for this purpose, however I might be missing something because it calls the entire content of my list variable, instead of checking the words from it one by one:
Block Text Verification
[Arguments] ${text_list_variable} ${locator_to_check}
Wait Until Element is Visible ${locator_to_check}
FOR ${label} IN ${text_list_variable}
${labelTostring} Convert to String ${label}
${isMatching} = Run Keyword and Return Status Element Should Contain ${locator_to_check} ${labelTostring}
Log ${label}
Log ${isMatching}
Exit For Loop If '${isMatching}' == 'False'
END
I am getting the following output for this:
Element
'xpath=//*[#id="generalAndIncidents:generalAndIncidentsPanel"]' should
have contained text '['Benutzer', 'Passwort', 'Sendung',
'Transaktionen', 'Notiz']' but its text was.... (and it lists all the
text from my locator)
So, it is basically not checking the words one by one.
Am I doing something wrong here? Is this a bad approach I am trying to do here?
I would be grateful if anyone could provide me some hint on what I should do here instead!
Thank you very much!
You've made one small but crucial mistake - the variable in this line here:
FOR ${label} IN ${text_list_variable}
, should be accessed with #:
FOR ${label} IN #{text_list_variable}
The for-in loops in RF expect 1 or more arguments of the looped over values, and the # expands a list variable to its members.

Issue reading .txt file in Matlab. I want to get an array from this file without the unnecessary info it contains

I'm having trouble reading a .txt file to get some data. I want to be able to change some of the values this data contains.
At first, I used this:
A=importdata('myfile.txt');
And got this cell array:
Now what I want is this:
1) Get rid of the headers (the information from cell 1 to 22). That could be easily done by simple indexing (creating a sub-array using just the info from cell 23 to the end of the file).
2) I want to separate the information into different cells, using these identifiers. But I don't know how to separate them into different cells of the array.
'# item bepoch ecode label onset diff dura b_flags a_flags enable bin'
3) Do the same in step 2 to fill those columns with the data in the rest of the cells.
I'm trying to use this approach, but I'm not getting the expected results.
If someone can help me, I'd be glad.
Have you tried dragging the file into the variable workspace window and using the data import wizard? It has some nice features that normally take care of what you are trying to do automatically. Unfortunately, it seems that your text file may have unconventional spacing, but Matlab may be able to handle it if you set the delimeter to ' ' or suchlike.

creating a character array with gff file

Could someone please help me with creating a "character array" with this sort of data:
ftp://ftp.ncbi.nih.gov/genomes/Bacteria/Escherichia_coli_ATCC_8739_uid58783/NC_010468.gff
Instruction from our collaborator:
One can copy and paste a gff file into a character array by typing gff={} and then copy and “paste excel data”
But I can somehow only save it as a cell array and hence the script downstream can't run properly.
additional info
I need to use the .gff file in a .m script (that I got from someone else) to parse my sequences.
Here's the part of my script that I think pertains to my question:
genelist=gff(:,3);
starts=gff(:,4);
ends=gff(:,5);
names=gff(:,9);
genelogical=strncmp('gene',genelist,4);
Therefore I want 9 columns with information like this:
1. seqID;
2. source;
3. type;
4&5. start and end;
6. score;
7. strand;
8. phase
9. attributes
Also when I saved the cell array as "cell", and tried to convert it into a character array by typing
char(cell)
I got this error message:
cell elements must be character arrays
So guess that doesn't work...
edit over
Anyone has any idea?
Thanks,
Joyce
The instructions you were given are referring to the following context menu item accessible from the "Variables" editor:
First, run at the command line gff={}; to make an empty cell array. Then double click the gff variable in the Workspace tab to get the above editor window. Click on the square regino to the top left of the table to select all cells, then right click to get the displayed menu, and paste the data. You should end up with the following if the paste worked correctly (it could actually take a couple of minutes - check CPU usage):
Then the commands you posted work. The strncmp says definitively that as cell array is needed.

Updating an unshown field in a form based on another table's field

Using Access 2010. Fairly new to automation and macros.
I have two tables (tblProductReceived and tblBins) and a form (frmProductReceived).
A field in tblBins corresponds to a location the bin is at (named BinLocationID) and the tblProductReceived table tracks product that a specific bin has received.
What I need is for the tblProductReceived field PRLocationID ([tblProductReceived].[PRLocationID]) to be automatically populated with where the bin is at ([tblBins].[BinLocationID]) when selecting a specific bin in the form (frmProductReceived).
Is there an easy way I can do this? I'm really new at macros/vba and I would extremely be grateful for some tips/suggestions!
Also, there is no object in the form for the PRLocationID field. I want it to be updated behind the scenes based on the bin number field the user selects ([tbl.Bins].[BinID])
Here are images of tblBins, tblProductReceived, and frmProductReceived: http://imgur.com/a/0IUHm/ (can't post images quite yet without reputation)
See this is the structure i have:
tblProductReceived is a table that records items that were deposited into bins.
tblBins is a listing of physical drop locations (bins) that contain a field BinLocationID
BinLocationID actually corresponds to another table (tblLocations) that has all the locations.
But I can't simply link the field from tblBins to tblProductReceived's because sooner or later bins can move from location to location (whatever the reason is is unimportant). This is the reason why I need a copy of [tblBins].[BinLocationID] to be copied over to [tblProductReceived].[PRLocationID] because should a bin move, it would mess any analysis (as we want to keep track of where the product was dropped off at, not only the location of the bin).
Also, the form I set up does have the drop down to the various bins ([PRBinID] in [tblProductReceived] — (i use a lookup query on tblBins) but keep in mind there is no txtBox for the PRLocationID in the field as it's superfluous. The bins are at location already, all i need is for it to be copied over to the appropriate table.
Am i overlooking anything?
After picking at it for hours this is the most elegant solution I've come up with:
On the form, I have a hidden txtBox called txtPRLocationID whose row source is PRLocationID (in tblLocations)
After a bin is selected at txtPRBinID, i have an event scripted at Lose Focus:
'Private Sub txtPRBinID_LostFocus()'
'[txtPRLocationID].Value = DLookup("[BinLocationID]", "tblBins", "BinID = " & Nz(Me!txtPRBinID.Value, 1))'
'End Sub'
Basically what it does is everytime a value is selected for txtPRBinID and the user moves on (Loses Focus of the txtBox), a DLookup occurs for tblBins.BinLocationID for the value of BinID and changes the value of txtPRLocationID text box.
The 'Nz()' is to avoid Null errors (according to Google search). Not sure if necessary, if anyone can confirm, please do!
Thanks for reading!

reorder array-table row and update database

I've been looking for a way to do something and I'm convinced I've been using the wrong search criteria to finding a solution...so, here I am.
I have a dropdown menu in a content management system that when a new page is created or position is edited, the database is updated with the new or edited value...this is all working great.
However, what I'd like to do is...when a number for the page position is changed from let's say, position 5 to position 1...the former position number 1 is changed to position number 2...and every position number for any pages remaining are renumbered accordingly.
So, my question is, how do I UPDATE my database so, whenever I change the position of the page in the dropdown menu, ALL position values get, I don't know, a +1...or something...and additionally, NOT allowing two position values to be the same...you know, there can be only one...
Thanks in advance...hope I didn't do too bad in explaining what I'd like to do :-)
Have you tried something like:
UPDATE my_table SET position=position+1 WHERE position>2 AND position<5
The where statement should be the new position & old position of the one you've just updated

Resources