How do I make a function to subtract and add values in a TEdit? [closed] - delphi

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed last month.
Improve this question
I'm new to programming, I'm looking to make a command to add and subtract values.
Where I would have a TEdit.Value with the initial value 0 and 2 more buttons, one of " + " and one of " - ", to increase or decrease the value, but I still don't know how to do that, can someone give me one light?
I looked up some examples of how to do this, but I didn't find anything that could help me.

You could use StrToInt() to convert the Edit's current Text string to an integer, then increment/decrement the integer, then use IntToStr() to convert the integer to a string and assign it back to the Text property. For example:
var Value: Integer := StrToInt(Edit1.Text);
Inc(Value); // or Dec()
Edit1.Text := IntToStr(Value);
However, a better option would be to use a UI control that is specifically designed to handle numeric input, such as a TSpinEdit, or a TUpDown attached to an Edit control.

Related

How to access MACD value and signal (both 2 data) in mql4 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am trying to create a robot in mql4 for forex trading.So i need to access both MACD value and MACD signal value.But it looks like only providing MACD value without MACD signal value.Please help me to access those values.
enter image description here
It provides u with both value pls look to my code
double macdBaseIndicatorLine = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
double macdSignalIndicatorLine =iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
thats how you get the values, pls give me a like if it helps u thx

Why do we check if empty before we move? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I see a lot of codes like this:
if WA > SPACES
move WA to WA2
end-if
What are the advantages that this is checked? Is it more efficient to check if it is empty than to just move it anyways?
Additional information:
WA and WA2 can be simple structures (without fillers) but also just simple attributes. They are not redifined and typed as chars or structures of chars. They can be either low-values (semantically NULL) or have alphanumeric content.
Nobody can tell you what the actual reason is except for the people who coded it, but here is a very probable reason:
Usually this is accompanied with an ELSE that would cover what happens if the value is less than spaces, but in this case I would assume that what every happens to this data later is relying on that field NOT being LOW-VALUES or some funky non-displayable control character.
If I had to guess, I would assume that WA2 is initialized to spaces. So doing this check before the move ensures that nothing lower than spaces would be moved to that variable. Remember, less than spaces does not mean empty, it just means that hex values of that string are less than X'40' (so for example is the string was full of low values, it would be all X'00'. So I would guess that its more about ensuring that the data is valid than efficiency.

is one hot encoding is free of the dummy trap [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
there is a thing called dummy trap in one hot encoder that is when we encode the categorical column with 3 categories lest say a,b,and c then with one hot encoder we get 3 categories like or columns a, b ,and c but when we use get_dummies we get 2 columns instead a, and b then it is save from dummy trap. is one hot encoding exposed to dummy trap or it takes care of it . am i right? which one is save of dummy trap? or is it ok to use both with our removing columns, iam using the dataset for many algorithms.
looking for help . thanks in advance.
OneHotEncoder cannot process string values directly. If your nominal features are strings, then you need to first map them into integers.
pandas.get_dummies is kind of the opposite. By default, it only converts string columns into one-hot representation, unless columns are specified.

Clarification on numeric formatting [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have a couple questions regarding the following code from the book Delphi Foundations
S := Format('It is %d', [65]); //assigns it to 64
Is 64 a typo?
Why does S := Format('%u', [-1]); return 4294967295?
S := Format('It is %d', [65]) will produce 'It is 65'. If the book says otherwise then it is wrong.
S := Format('%u', [-1]) produces '4294967295' because the number is being formatted as an unsigned value. Signed -1 has the same bit pattern as unsigned 4294967295 (they are both $FFFFFFFF in hex).
Lay person
(1) Typo - see http://delphifoundations.com/errata/ for that one and more (and if you spot any others yourself, I would be grateful for the feedback).
(2) For the reason I say in the book:
If a signed integer is passed, it is simply cast to an unsigned
integer. Given the way a signed integer is represented internally,
this will not just strip off the sign from a lay person’s point of
view. E.g., Format('%u', [-1]) returns '4294967295', not '1'. If just
stripping off the sign is what you want, then pass the value to the
Abs standard function first: Format('%u', [Abs(-1)]).
So, take an Integer/Int32 and a Cardinal/UInt32: an instance of both these types takes 32 bits of memory. In the case of Integer/Int32 however, one of those bits is used to record the sign (plus or minus?), whereas with a Cardinal/UInt32, there is no sign to record; instead, that same bit is used to allow representing a number much bigger than an Integer/Int32 can represent. As such, the internal representation of Int32(-1) happens to be the same as the internal representation of UInt32(4294967295).
(3) 'Lay person' in this context is just a synonym for 'non-technical person', 'someone who isn't a geek', etc.

Limit a NSMutablestring's length [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am working on a calculator App.
The NSMutablestring is used for calculation E.g "5-3*8-(-1)/77".
But the label can't display endless an NSMutablestring, so is there have any way to limit NSMutablestring's length?
(not too long, I want the NSMutablestring's length to be less than 100).
You can get the first 100 characters of a string as follows:
NSString *first100chars = [myString substringToIndex:100];
However, it sounds like you need to prevent the user from actually entering a string this long, which is a different problem. The comments to your question give examples of other people asking similar questions (e.g. Set the maximum character length of a UITextField), I suggest you check those.
This is a job for an NSFormatter subclass. That's exactly what it's for.

Resources