I am writing some code where I am using a single event handler for multiple labels, and I would like to add a custom property of a value from 0 to 8 so that I can organise the inputs into an array. For example (see image), I've got a 3x3 grid of Xs, I want to add a number 0 to 8 (0 being the top left and 8 being the bottom right, where it moves across the row then down a row), so that I can know which label has been clicked on. So far I have this, but I would like to replace i with something such as sender.pos (Positional index of the sender object, where pos is a property of the sender). This is what I have so far, the code is for a game of TicTacToe. Let me know if I've been unclear. I would love some help on this!
Related
Were moving to using 2d bar codes and 2d bar code scanners. Currently a picker will scan 3 linear bar codes, one for the product, one for the lot number and one for the quantity. The cursor starts in the Product field, after the scan the cursor moves to the lot number field the repeats the process for the quantity. Each scan contains data only for the field intended. Well along comes the 2d bar codes that concatenate all three values into 1 returned string with application identifiers (01,11,10) separating each 'field'. An example of this is (01)12345678901234(11)220728(10)12345. The parentheses are not included in the actual scan, I just showed them for demonstration purposes. My question is how do I know when to parse out each field? For example, in a CSV file, I just look for data in between the commas. I've also read something about FNC1. Can anyone help? Thanks...
2d bar code
Scanner results
All you need is the information on these pages.
This page contains ideas and flowcharts.
GS1 DataMatrix Guideline
You can find a list of application identifiers on this page.
GS1 Application Identifiers
Please use the above in combination to help you implement it.
I have a project where I want to filter down a lot of data based on user's selections of 8 different criteria. In my case it's kitchen cabinets but a more universal example would be cars. The user is presented with a userform containing 8 listboxes, one for Make, Model, Package, Color, Transmission and so on. Double-clicking on a listbox item removes all other choices in that listbox and filters out invalid choices from all the other listboxes. The choices compound so the user could choose "Green" for Color and "Ford" for Make.
I've done this two different ways already and I'm not happy with either.
1) I created a matrix where I listed Models down the left hand side and each of the other 7 features across the top with "X" at the intersect points. Then I taught VBA how to basically read it like a human would using a ton of nested loops. This was pretty slow, where each selection caused the program to halt for 1-2 minutes while it sorted everything out.
2) I listed out every single possible combination (some 22,000) and used Excel's built in filtering options to filter the data, then copy each column of the results onto a second sheet, filtering out duplicates and re-sorting them, and using that to re-populate the listboxes. This worked really well but for some reason I can't fathom, Excel gets hung up for 3-10 minutes doing something when I filter certain columns. I debug/traced it and the hang up happens after all my code is run, but before it returns control to the user.
At this point I'm open to any suggestions. Ultimately I need the user to choose one complete (all 8 options narrowed down to one choice) configuration. The tricky part is the user may start with color "Green" which would eliminate all other colors from the "Color" choices list, as well as any Make, or Model, or Package, etc that doesn't come in Green from their respective lists. Maybe data would help explain it?
Make Model Package Color Transmission
Ford Focus LT Blue Manual
Ford Focus LT Green Manual
...
Ford Focus ST Blue Manual
...
Ford Focus LT Blue Automatic
...
And so on for 22,000 rows.
So if the user chooses "Manual" I need to drop the "Automatic" rows. If the user then chooses "ST" I need to drop the "LT" rows (while assuming the Automatic rows are still being filtered out, and so on until there's only one row left.
Just an idea that came to mind: Are you familiar with a highly efficient method of searching for words in a dictionary of words called Trie?
If you code each option properly you could enter the whole option map in a Trie. When a user makes a selection you follow that path in the Trie. If no matching option exist then the Trie returns Null and you can inform the user about that.
Good explanation of a practical Trie implementation for words:
https://www.geeksforgeeks.org/trie-insert-and-search/
I have : <xp:repeat id="repeatColor" value="#{productcolors}"
var="rowData" indexVar="rownum" >
PROBLEM : rownum goes from 0 to the last correct value, but rowData is always the same
This repeat control is bound to a view "productcolors" , a view with a key on product code.
This view has a first column with the product code , ascending (for the key).
It also has a second and a third column with ascending multiple value fields.(second is framecolor, third is upholstery color)
The idea is that the repeat control goes through the different colors for the selected product, but it only shows the first one and does that the number of times (rownum increases correctly)that there are colors for the selected product.
EDIT :
So I have for example a product called "A" available in framecolors "1" "2" and "3"
When I am using the repeat control rownum changes from 0 to 2 but rowData is always the reference of framecolor "1". I don't know why rowData isn't changing.
When I use rowData.getUniversalID() I am getting 3 times the ID of the document containing the multiple value field with the 1 , 2 and 3 in it, which is I guess normal ? But how can I get a handle to those different values inside it ?
SECOND EDIT
I tried :
var testje:string = rowData.getUniversalID();
var db:NotesDatabase = session.getDatabase(database.getServer(),"product/colors.nsf");
var doc:NotesDocument = db.getDocumentByUNID(testje);
test = doc.getItemValueString("colorUpholstery");
The result is that "test" only holds the first item of the multiple value field "colorUpholstery" .
How is that possible ? I thought I would get the complete value of the "colorUpholstery" field ?
Maybe because I only have reader access(Publicaccess) to the colors.nsf database ?
It would be nice to see a little more code... like what's inside the repeat.. just to get a better feel for it to go along with your description of the Notes View.
rowData should be an XSPViewEntry... basically a NotesViewEntry... I suggest you first do something like rowData.getDocument().getUniversalId() to make sure it is iterating the documents correctly. I'm sure it is.
It sounds like you're trying to do something with a multi-value field.. are you also setting the view to use display multiple values as row entries? or whatever that setting is? That might get dicey if that's turned on. Not sure.
Again I'm not totally following what what the goal is but I would first test to make sure it is actually repeating the expected documents. then it's all about fine tuning.
EDIT: Ok... some thoughts based on your additional info:
I suspect that your problem is the use of the view setting "show multiple values as separate entries". Each is the same document really. So that's likely not helping you here. I'm still a little fuzzy on exactly what you want for the output. Is this from a "view page" of maybe products? a "form page" of a single product?
I ASSUME you want all the colors for a single product? And this is a lookup view right? so you're on your product "document" and now you want to list all the colors?
Assuming so...
Use SSJS and the object model. Do a lookup to find the SINGLE document that has the multi-value color field for your current product. then return to a repeat control something like:
lookupDoc.getItemValue("colorField")
I'm not 100% sure that's the correct syntax. The point is you can send a multi-value field to a repeat control and it will repeat it. Much easier then trying to use view tricks.
If your goal is to have a Repeat of multiple products.. and in side each "row" to show all the available colors then you're looking to have a nested repeat really... The outer repeat (outerData) to iterate over all the main products and inside that another repeat (innerData) for the colors. Inside that repeat code you use the "outerData" to get the multi-value field. Something like:
outerData.getDocument().getItemValue("colorField")
Assuming I'm understanding you correctly these are my suggestions.
I did do an example of nested repeats like this on an early NotesIn9. I believe it was this one: http://notesin9.com/index.php/2010/03/30/notes-in-9-show-14-repeats-repeated/
Maybe that will help.
Second Edit Response:
Based on the code you added you're using "doc.getItemValueString()" By design that will only get you the first value of a multi-value field. This is the same as saying in LotusScript:
doc.colorUpholstery(0)
or the less commonly used
doc.getItemValue("colorUpholstery")(0) ' I might have that wrong. I never really used it
Again if you want to make a list of all the colors I'd use a repeatControl and pass in:
doc.getItemValue("colorUpholstery") then your "rowData" for that repeat will be each value. I've seen others avoid the repeat and doing some javascript explode or implode type thing I believe. using "\N" or something as a separator for a new line. I just use a repeat. Easer for me to understand.
Again I THINK everything you need really is in NotesIn9 episode 14.
I'm not a developer but I'm supposed to create a report by C.R., so excuse me in advance if it is an obvious question for you, and please keep in mind that I'm a real beginner.
I have a job composed of 3 different workings (3 out of 5, which is the maximum workings I can have for a job).
In my SQL database, the table.field corresponding to those workings is job.phase, so when I put, in my report details, the field "job.phase", I get 3 rows for that job.
The point is that my report printout always has to show 5 different text objects (one below the other), corresponding to the descriptions of all the 5 possible table.field-records, and a 'X' should appear next to text objects when each one of the workings listed there is a part of my job (otherwise nothing should appear).
What I have done is the following:
- created a subreport containing the "job.phase" field
- put it near my first text object
- specified in my subreport the following "show string" formula:
if job.phase = 'working1' then 'X' else ''
and it works: a X appears if working1 is part of my job, nothing appears if working1 is not part of my job.
Then I have created 4 subreports more, equal to the first one, and specified the same for job.phase = working2, working3, working4 and working5, BUT, after doing that, no X is shown (even though working 1, 2 and 3 are part of my job)...
Is there anybody who can help me, please? It's so frustrating...
Using subreports for something like this is overkill for what you're trying to do and could be causing any number of things to behave badly. I'd recommend you abandon that idea. Here's how I would do it:
The first thing you'll want to do is group by job (if more than one will appear in your report, which I'll assume it will). The Group Footer section is where you can display the labels and Xs. You'll need to create 5 formulas as you did before if {job.phase} = "working1" then "X", one for each of the phases/workings. Drop all 5 of those formulas into the Details section of the report and then suppress that entire section so that it doesn't display.
To show the Xs, you can use a Maximum summary in the Group Footer for each of the five formulas you created. To do this, right-click each of the formulas in turn, select Insert -> Summary. Choose Maximum as the summary, and "Group 1" (Your job ID or whatever field you are using to group the job) as the Location. That will insert a field into the Group Footer that will display an X when that particular working is specified for the job, otherwise it won't display anything. Move them to display next to the appropriate label/text field and you're done.
I am making a space invaders game. Each invader has its position on the screen stored. This would form a nice grid of 5 rows with each 11 invaders.
There are 3 types of invader A, B, and C. A consists of 22 invaders, B also, and C 11. Because of this I could not use their positions alone to form the grid on the screen. So, I added variables for how many rows and columns there are and with these I could use a nested for loop to get the right amount of invadertypes.
Now, I have an idea for some kind of algorithm to get them to do something, but for that I need to store them in a certain way. How I'm thinking of doing it is to use a Dictionary<int, Tuple<Point, Invader>>, where int will be the index like in a list, Point will be used for storing row-column, and Invader for well, the invader.
Before I used a List to store invaders and so I could with a for loop access the invader I needed to perform an operation on. Like invaders[i].DoSomething().
I want to be able to still do that, and have not only the invader, but also what row-column it is occupying.
What are my options?
Why not add row / column variables to your invader class?