I have made a small script to check my expenses. In the description I look for a term. So I search within a string (like a supermarket brand). Unfortunately, it can only check case sensitive. How to fix this? I want to search within the string independent of the case. The search terms can be upper of lower case, easy to adjust.
for (i in uitgaven)
{
for(n=0;n<data.length;++n)// iterate row by row and examine data in column A
{
if(data[n][3].toString().match(uitgaven[i][0])==uitgaven[i][0]){ data[n][4] = uitgaven[i][1]
};
}
Just substitute this:
data[n][3].toString().toUpperCase()===uitgaven[i][0].toUpperCase()
for this:
data[n][3].toString().match(uitgaven[i][0])==uitgaven[i][0]
Related
How do I format a number with 2 decimal places to a whole number?
I used the Lookup function to get a result, but formatting decimal to whole number does not work for this value. I did Text box properties -> number -> whole number doesn't work for one of my value. Also customize number to #,### but its not changing anything.
How do I make this value display as a whole number?
You may be confusing how the number is displayed (which can be controlled using text box properties) and it's actual value. It sounds like the value returned from the lookup is not a number, it might be a string/text value instead which would explain why it was not affected by number formatting.
One option is to convert the value to an integer (whole number) in the lookup expression itself, using a function to convert the value: CInt()
For example if your expression currently looks something like this:
=Lookup(Fields!SomeField.Value, Fields!SomeDatasetField1.Value, Fields!SomeDatasetField2.Value, "SomeDataset")
then you can change it to:
=CInt(Lookup(Fields!SomeField.Value, Fields!SomeDatasetField1.Value, Fields!SomeDatasetField2.Value, "SomeDataset"))
Or if you want to keep the original value, but just change how it is displayed then convert to a decimal value instead:
=CDec(Lookup(Fields!SomeField.Value, Fields!SomeDatasetField1.Value, Fields!SomeDatasetField2.Value, "SomeDataset"))
and then use the text box formatting options to control the displayed format.
I am trying to create bindings for the Tk Text widget to limit the User so s/he can't delete the first character in the line (the character serves as a sort of prompt like in a terminal.)
Here's how I'm almost accomplishing this:
bind .text <BackSpace> {
if{[.text index insert] == [.text index {insert linestart+1c}]} {
break;
}
}
It works in terms of not letting the user delete the first character in the line, but for whatever reason, it also stops the user from deleting the ninth character in the line as well! For example:
>hello world!
Pressing backspace now from the end of that line will delete until
hello wor
and then stop! I can press the left-arrow to move to the next character after 'r' and keep deleting, and then as it should, it doesn't delete the carrot. I see no reason why this should be happening. If someone could either point out my mistake or let me know of a better way to achieve what I'd like that would be great.
At the point where it stops, [.text index insert] gives an index of 1.10 and [.text index {insert linestart+1c}] gives an index of 1.1.
These are numerically equal, and == likes to use numeric equality if at all possible.
The fix is to use the compare method of the text widget, perhaps like this:
bind .text <BackSpace> {
if {[.text compare insert == {insert linestart+1c}]} {
break
}
}
(I think you might actually be better off doing your overall goal a different way, perhaps by setting a tag on the text you want to preserve and checking before deletion whether any of the text to be deleted has the tag. But that's a very different approach.)
I have a table that with a cell that may contain one of several defined words (such as "piping" or "containment"). I want to display a phrase specific to the word based on the word in my table. So if the table says piping, want the section of my report to say "...the piping in this area..." a null value would return specific text as well.
What about a CASE statement? Something like this:
CASE {column}
WHEN 'Piping' THEN 'Piping in this area'
WHEN 'Containment' THEN 'Etc....'
END AS "Project status?"
As I must to add image on several group on the same form, I'd to customize my procédure to do that.
Indeed, actualy, I have something like that,
if(value=="17"){
gv17.addElement(imAc);
v17.setStyle("backgroundColor",'#ffffff');
}
My goal is to do something like that:
if(value=="18"){
gv18.addElement(imAc);
v18.setStyle("backgroundColor",'#ffffff');
}
if(value=="17"){
gv17.addElement(imAc);
v17.setStyle("backgroundColor",'#ffffff');
}
if(value=="16"){
gv16.addElement(imAc);
v16.setStyle("backgroundColor",'#ffffff');
}
Do you have a solution to solve that.
Indeed, I think it's stupid to write X times (3 in example) to do that. I can refer to object by Name as name is a string.
I'd like to do something like that :
var mytarget:string = "gv16";
mytarget.addElement(imAc);
Thanks
Depending on how your objects are named, you might try:
this['gv' + value].addElement(imAc);
this['v' + value].setStyle('backgroundColor', '#ffffff');
As long as your value number equates to the symbol name numbers, and the logic holds true for every element, this should solve your problem without getting overly complex.
My question concerns the following tutorial I've been working through:
Building a Flex Type-Ahead Text Input
I was successful in enabling a search of available terms using the characters entered in the input, but only irrespective of the location of the characters in the terms. However, I am wondering how one might have the characters match only the beginning of the terms.
For example, suppose I enter the string "app" into the text input. How can I get only "apple" and not, for instance, "pineapple" to appear as an option?
public function filterSelection(item:Object):Boolean{
if (String(item).indexOf(fruit.text)==0){
return true;
}
return false;
}