So I am making a quest system, and I want to randomly choose a quest, but i dont want it to choose the same one again.
Here is the piece on code for the string.
I cant find any good answer.
This is a more simple line of code.
string[] QuestChoose = new string[] {"Quest1", "Quest2", "Quest3"};
3 methods come to mind:
Convert to a List and call Remove().
Write null into the array after having read the quest and when selecting a quest, always search for the next suggestion if null was selected.
Keep a separate data structure like a HashSet<int> where you add the index in the array whenever a quest has been used. Then check for Contains on your ID when selecting.
You really ought to use lists if you want to dynamically add/remove elements from your set.
Instead of:
string[] QuestChoose = new string[] {"Quest1", "Quest2", "Quest3"};
try using:
List<string> QuestChoose = new List<string> { "Quest1", "Quest2","Quest3"};
You can add elements by calling QuestChoose.Add("Quest4");
Or remove an element by calling: QuestChoose.Remove(ItemNumber);
Where as "ItemNumber" is the index of the string you want to remove. For example; Calling QuestChoose.Remove(0); will remove the first item in the list, which in this case would be "Quest1"
Related
I have been going through the below Plunker,
plunker link here
Here If I try to edit , the new record is added above instead of updating the current ,
How can I update the current edited row for the same example instead adding a new one?
I have tried deleting the row and update the new in the deleted place , but this idea is not correct tmk
Any guiding links or any help is much appreciated ....TIA
From your code I understand you want to update the model (variable aData). It would be a better idea to use data binding but if you want to edit it you can use:
aData.map(function(item) {
if (item.ID==id){
item.Name = name;
item.Age = age;
item.Salary = sal;
}
return item; });
This is probably not the efficient way to do it and it consider you have unique ids.
Also don't use the function unshift() because it add new value (doesn't update the existent).The record is added above because you actually add a new element (see link).
You should try to work with data binding rather than manually extracting and inserting your values:
https://sapui5.hana.ondemand.com/1.28.33/docs/guide/91f0ca956f4d1014b6dd926db0e91070.html
Nevertheless, if you do want to edit a property of an item in your array, you can edit it as follows:
array[index].property = "new value";
I am trying to automate text boxes to fill with a certain value, however the text boxes names are not static so they will always change. I am looking to find a way to always populate them even though they do not have a static name and how to find the second, third, fourth etc instance of the boxes and be able to also fill them without overwriting the previous text boxes
i have tried using the _collect function in sahi pro but could not find how to target the class correctly
I expect to be able to populate any textbox using the same class name without overwriting the first instance of this class.
I am using Sahi pro.
The sahi documentation on _collect seems to be you exactly what you are looking for
// Collect all textboxes matching any identifier, in table "listing".
// Note the use of match all regular expression "/.*/"
var $textboxes = _collect("_textbox", "/.*/", _in(_table("listing"));
// Iterate and set values on all textboxes
for (var $i=0; $i<$textboxes.length; $i++) {
_setValue($textboxes[$i], "value");
}
If this does not solve your problem, please provide an example of the html and of your _collect code
$GLOBALS['TCA']['tt_content']['types'][$myCType]['columnsOverrides']['imagecols']['config']['items'] = [[2,2],[3,3]];
But above not working it just replace fist two items with my list but other items are still visible how can i override items array for my custom ctype?
It seems, \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule(), which is used to handle the columnsOverrides, does allow unsetting a key (or array), but not replacing a substructure.
Maybe it's possible to find a combination of unsetting and afterwards merging with new values.
In this case you can use TCEFORM to solve your task.
TCEFORM.tt_content.imagecols.types.myCType.keepItems = 2,3
I have a combo, with a comboViewer in Jface,
and because is an update record dialog, I wan to sel the combo with correct selection.
I'm tryin to use
//Seleccionar Protocolo
if (fcruza.getTipoCosecha() != null)
comboProtocoloViewer.setSelection(new StructuredSelection(fcruza.getTipoCosecha()));
But the combo is not selected.
I follow java code, but I can't figure out what i'm doing wrong.
Also I have this on this control:
comboProtocoloViewer = new ComboViewer(comboProtocolo);
comboProtocoloViewer.setContentProvider (new ArrayContentProvider());
comboProtocoloViewer.setLabelProvider (new ProtocoloLabelProvider());
comboProtocoloViewer.setInput(tipoCosechaController.obtenerTipoCosecha());
Any sugestion.
Best regards
Yes ArrayContentProvider works with lists. Have you tried selecting an element as I posted earlier?
You have to make sure the element you are trying to select is part of the list, equals() of the element (fcruza.getTipoCosecha()) needs to match one of the input list.
I'm currently working on a form in Microsoft Dynamics AX.
The form consists of a grid with about 10 fields from 4 different tables.
As the form is now it returns too many values so I need to include some sort of filter, it doesn't need to be dynamic, just a static filter saying only show the lines with value X in column Y.
Has anyone here got some experience with this sort of thing? Where do I start?
I must say I'm not experienced with Microsof AX at all, I've been working with it for about a month now.
I've tried to follow this guide: How to: Add Filter Controls to a Simple List Form [AX 2012]
But I got stuck at the second part (To add a control to the custom filter group) Step 2: I dont know which type of control to chose, and ik i pick lets say a ComboBox i cant get Step 3 to work because I dont see the 'Override Methods' they mention.
Well, I usually do it this way:
In ClassDeclaration, create as many QueryBuildRanges variables as fields to filter. Let's name them Criteria1, Criteria2, etc (name them properly, please, not as here)
QueryBuildRange criteria1, criteria2;
In each Datasource you need to filter, override method Init, an add code similar to this:
super();
criteria1 = this.query().datasource(tablenum(tableofdatasource)).addQueryRange(fieldNum(fieldtofilter))
//criteria1.status(RangeStatus::locked); //optional - this way you can hide filter field to user, have it readonly for users, etc
Create a control of type StringEdit or ListBox in form to be used as filter. Change their AutoDeclaration property to Yes. Override modified() method. In it, I use to put something similar to:
super();
element.changeFilters();
In form, add method changeFilters();
range rangeFromStringControl = StringEditControlName.text(); //Put in rangeFromStringControl the string to be used as filter, as a user would write it
range rangeFromListBoxControl;
criteria1.value(rangeFromStringControl);
switch (listBoxControl.Selection())
{
case NoYesAll::All:
rangeFromListBoxControl = ''; //Empty filter string - No filter at all
break;
case NoYesAll::No:
rangeFromListBoxControl = QueryValue(NoYes::No); //Or whatever string filter value you want
break;
//Etc
}
//We have all filter strs done; let's filter for each main DataSource required with new filters
DataSource1.executeQuery();
//If there is other datasources joined to this one, it's usually no necessary to call their executeQuery;
//If there are others with filters and not joined to it, call their executeQuery()
If you need this filter to be applied when form is open, set appropiate initial values to controls, and then in form's run() method:
run();
element.changeFilters();