Interger .ToString() is null when value =0 Blazor - blazor-webassembly

Why interger .ToString() is null when value is 0? Can anyone explain to me?

Here's the Counter page, which it looks like you are using, and a screen capture of the Auto at the break point. As you can see s is not null. What are you not showing us?
#page "/counter"
<PageTitle>Counter</PageTitle>
<h1>Counter</h1>
<p role="status">Current count: #currentCount</p>
<button class="btn btn-primary" #onclick="IncrementCount">Click me</button>
#code {
private int currentCount = 0;
string s = "";
int i = 5;
private void IncrementCount()
{
int j = i;
s = currentCount.ToString();
currentCount+=i;
// Break point here
}
}
And a screen capture of the Autos:

Related

Add Toggle On/Off button to a .mq4 indicator

Could someone tell me how to add an ON/OFF button on this gap finder indicator I've recently modified?
I'm an amateur noobie programmer and I can only code basic things and this is getting pretty challenging for me.
I've tried to integrate and modify part of other codes with buttons template but no way.
This are the indicators inputs which are customizable
Indicator Input Parameters
This is how it prints gaps on charts
Indicator on chart
CODE
#property indicator_chart_window
#property indicator_buffers 1
#property description "Automatically render boxes for liquidity gaps "
#property indicator_color1 Black
extern double Gap_Size_Minimum = 100;
extern int ExtendBars = 1000;
extern int History = 1000;
extern color Gap_Up = Aqua;
extern color Gap_Down = Tomato;
input ENUM_LINE_STYLE Rectangle_Style = STYLE_SOLID;
double Pip;
int init()
{
Pip = Point;
if(Digits==3 || Digits==5) Pip = 10*Point;
return(0);
}
int deinit()
{
string ObjName;
for(int i = ObjectsTotal()-1; i>=0; i--)
{
ObjName = ObjectName(i);
if(StringFind(ObjName,"liquidity_gaps",0)>=0)
ObjectDelete(ObjName);
}
return(0);
}
int start()
{
int i, limit, counted_bars=IndicatorCounted();
limit = MathMin(History,Bars-counted_bars-1);
string ObjName;
for(i=limit; i>=0; i--)
{
if(i>Bars-2) continue;
if(MathAbs(Open[i]-Close[i+1]) > Gap_Size_Minimum*Pip)
{
ObjName = "liquidity_gaps_Up_"+Time[i];
color ObjColor;
if(Open[i] > Close[i+1]) ObjColor = Gap_Up;
else ObjColor = Gap_Down;
if(ObjectFind(ObjName)<0)
{
ObjectCreate(ObjName,OBJ_RECTANGLE,0,Time[i+1],Close[i+1],Time[i],Open[i]);
ObjectSet(ObjName,OBJPROP_BACK,0);
ObjectSet(ObjName,OBJPROP_COLOR,ObjColor);
ObjectSet(ObjName,OBJPROP_STYLE,Rectangle_Style);
}
}
//datetime thistime = Time[i];
int ib = i+ExtendBars;
while(ib>=0)
{
ObjName = "liquidity_gaps_Up_"+Time[ib];
if(ObjectFind(ObjName)>=0)
{
double pr2 = ObjectGet(ObjName,OBJPROP_PRICE2);
double pr1 = ObjectGet(ObjName,OBJPROP_PRICE2);
ObjectSet(ObjName,OBJPROP_TIME2,Time[i]);
ObjectSet(ObjName,OBJPROP_PRICE2,pr2);
}
ib--;
}
}
return(0);
}
Indicator download for MT4
Thanks in advance for you kind help

How to make a textField which only accepts integers but greater than 0

i am creating an program where the user has to enter the Number of dinnners on a Table which cant be zero , i am able to allow only integers as an input for the textField but how to exclude 0 and pop an error when user enters 0
A possibility to handle this simply use a ChangeListener for your textfield. In this posts its explained how to do it : Value Change Listener for JavaFX's TextField
For a range listener it should be sth like this:
TextField textField = new TextField();
textField.textProperty().addListener((observable, oldValue, newValue) -> {
int from = 0;
int to = 200;
if (newValue != null && !newValue.equals("")) {
try {
int number = Integer.parseInt(newValue);
if (number < from || number > to) {
throw new NumberFormatException();
}
} catch (NumberFormatException ignored) {
field.setText(oldValue);
}
}
});
This avoids the user to insert numbers bigger or smaller than you want. But its not a perfect way to do it (just written down fast).
I think this should work:
private void createListenerTextField (TextField textField, int LIMIT) {
UnaryOperator<TextFormatter.Change> integerFilter = change -> {
String newText = change.getControlNewText();
if (newText.matches("-?([1-9][1-9]*)?")) {
return change;
}
return null;
};
textField.setTextFormatter(new TextFormatter<>(new IntegerStringConverter(), null, integerFilter));
textField.lengthProperty().addListener((observable, oldValue, newValue) -> {
if (newValue.intValue() > oldValue.intValue()) {
// Check if the new character is greater than LIMIT
if (textField.getText().length() >= LIMIT) {
// if it's LIMIT character then just setText to previous one
textField.setText(textField.getText().substring(0, LIMIT));
}
}
});
}
You can remove the LIMIT part if you want to let the user enter a huge number (I recommend to use it because the user can enter a bigint)

showing table with specefic element

i have a table full of object(type) when i click "liste des vihicules" i'de like to go to a table full of obeject(vehicule) with this condition:
vihicule.nom_type=type.nom_type
to do this i used this code
////go to vehicule list
#RequestMapping(value="/liste/{nom_type}")
public String listvih(#PathVariable(value = "nom_type") String nom_type, Model model) {
List<Vihicule> l = vihiculeRepository.findAll();
List<Vihicule> l1= null;
for(int i=0; i<l.size(); i++)
{ if(l.get(i).getNom_type()==nom_type)
{
l1.add(i, l.get(i));
}
}
model.addAttribute("v", l1);
return "liste";
}
but it always show an emty table. what could be the problem, please help
update: i did some changes in the code and now everything work fine
#RequestMapping(value="/liste/{nom_type}")
public String listvih(#PathVariable(value = "nom_type") String nom_type, Model model) {
List<Vihicule> l =vihiculeRepository.findAll();
List<Vihicule> l1 = new ArrayList<Vihicule>();
for(int i=0;i<l.size();i++)
{
if(l.get(i).getNom_type().equals(nom_type))
{int j=0;
l1.add(j, l.get(i));
j++;
}
}
model.addAttribute("v",l1);
return "liste";
}

Angular2 model binding not working

I try to update an input value in Angular 2, it works the first time the size value exceeds maxSize, but afterwords it does not work anymore. It seems like when I am setting this.size to some value the UI is not updated, am I overlooking something ?
HTML:
<input type="text" class="form-control" [value]="size" (input)="size = updateValue($event)">
Code:
export class BrushSizePicker {
#Input() minValue;
#Input() maxValue;
#Input() size;
increaseValue(event) {
this.size++;
this.checkValue();
}
decreaseValue(event) {
this.size--;
this.checkValue();
}
updateValue(event) {
this.size = parseInt(event.target.value);
this.checkValue();
return this.size;
}
private checkValue() {
if (this.size > this.maxValue) {
this.size = this.maxValue;
}
if (this.size < this.minValue) {
this.size = this.minValue;
}
}
EDIT:
I logged what happened: checkValue is called every time with the correct input, and it returns the correct value. But the new value is not set into the input field / value field
While it may not solve the problem, the way you have implemented the input event can be simplified. I would have written it like this, side-effect free functions:
updateValue(event) { // The method name with this change is a misnomer
return this.checkValue(parseInt(event.target.value));
}
private checkValue(item) {
if (item > this.maxValue) {
return this.maxValue;
}
else if (else < this.minValue) {
return this.maxValue;
}
return item;
}

How to match text in string in Arduino

I have some issues with Arduino about how to match text.
I have:
String tmp = +CLIP: "+37011111111",145,"",,"",0
And I am trying to match:
if (tmp.startsWith("+CLIP:")) {
mySerial.println("ATH0");
}
But this is not working, and I have no idea why.
I tried substring, but the result is the same. I don't know how to use it or nothing happens.
Where is the error?
bool Contains(String s, String search) {
int max = s.length() - search.length();
for (int i = 0; i <= max; i++) {
if (s.substring(i) == search) return true; // or i
}
return false; //or -1
}
Otherwise you could simply do:
if (readString.indexOf("+CLIP:") >=0)
I'd also recommend visiting:
https://www.arduino.cc/en/Reference/String
I modified the code from gotnull. Thanks to him to put me on the track.
I just limited the search string, otherwise the substring function was not returning always the correct answer (when substrign was not ending the string). Because substring search always to the end of the string.
int StringContains(String s, String search) {
int max = s.length() - search.length();
int lgsearch = search.length();
for (int i = 0; i <= max; i++) {
if (s.substring(i, i + lgsearch) == search) return i;
}
return -1;
}
//+CLIP: "43660417XXXX",145,"",0,"",0
if (strstr(command.c_str(), "+CLIP:")) { //Someone is calling
GSM.print(F("ATA\n\r"));
Number = command.substring(command.indexOf('"') + 1);
Number = Number.substring(0, Number.indexOf('"'));
//Serial.println(Number);
} //End of if +CLIP:
This is how I'm doing it. Hope it helps.
if (tmp.startsWith(String("+CLIP:"))) {
mySerial.println("ATH0");
}
You can't put the string with quotes only you need to cast the variable :)

Resources