i am a newbie to flash builder! i am trying to create an app for IOS, on my school project. the problem that i faced is: can i select a few items value from a text input field and to implement them in a new view where i use some formulas! text input will look like this example :
aaa 23
bbb 45
ccc 56
i need the aaa and ccc that i want to use on my formulas!
about my first question! on my main view i have 2 buttons : 1 - Manual 2 - Auto . on manual view i have fields aka: aaa = ccc= ... and so on. in auto mode i was thinking of auto input method like this : to select the needed values for formulas from a text input area where the user will paste the text, for avoiding the manual input on each field.
PS:and can someone to tell me how correctly implement math simple formulas in flash builder, here i mean the syntax . like textinput1+textinput2/textinput3!?
From what I understand, you have two questions...
First, it doesn't quite make sense to me but I think you are asking if you can do math on letters??? No. But maybe I am just not understanding the question.
Second, you want to know how to do the math in ActionScript. Its fairly simple. Basic math functions are just like any other language. Take the string, convert it to a number then do your basic math:
Number(textInput1) + Number(textInput2) = result;
Using Number() will convert your string to a number so you can perform the math. Then, to display it, just convert your result back to a string:
textResultField.text = result.toString();
Or you could get fancy (AKA: harder to modify later) and do it all on one line:
textResultField.text = (Number(textInput1) + Number(textInput2)).toString();
Again, this will work for all BASIC math function (+, -, *, /). Really depends on what you are trying to do.
Related
Backstory:
I am creating a LTspice program, where I am creating a circuit with over 1000 resistors.
There are 9 different types resistors. I need to change the value of each type of resistor, many times. I can do this manually but I don’t want to. The file is like a text file and can be read by a program like notepad. The filetype is .asc
I was going to create a java program to help me with this.
File Snippet:
SYMATTR InstName RiMC3
SYMATTR Value 0.01
SYMBOL res -1952 480 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName RiMA3
SYMATTR Value 0.01
SYMBOL res -2336 160 R0
SYMATTR InstName ReC3
SYMATTR Value 8
Question:
How can I changes a word, I don´t know, in a file, but I know where it is, compared to another word I know?
An example:
I know the word "RiMC3", I need to changes the 3th word after this word to "0.02".
In the file Snippet the value is "0.01", but this will not always be the case.
My Solution:
I need a place to start.
Is this call something special? I have not found anything like this on google.
If you want to do this programmatically, you need to think about the limitations and requirements.
We don't know exactly how you want to do this, or in what context. But you can write this out on paper, in English, to give you a place to start.
For example, if we are going to make a standalone Java program (or class) to do this, and given simple line-oriented text, a naive approach might be:
Open the file for read
Open a file for write
Scan the file line by line
For each line:
Match the pattern or regular expression you are looking for and, if
it matches, modify the line in memory
Write out the possibly modified line to the output file
Finish up:
Close the files
Rename the output file to the input file
Buffering, error handling, application domain specifics are left as an exercise for the reader.
I'm pretty much a complete newbie to java and programming in general. I was wondering if anyone could help me out.
So I have a .csv that I am reading and storing data from (i think in the form of an array?) by using the following. This works fine and is grabbing all the data from the csv.
fo=new File()
fo.open(filename)
contents = fo.read()
fo.close
The data that I am grabbing from the .csv is in the form of well positions on a plate e.g. A1, B1, C1, D1 etc. Now is there a way that I can make each of the letters worth a particular value?
For example, A=1, B=2 C=3 etc, and then make this new value multiply by the second number e.g. A1 would become 1*1 = 2 and A2 would become 1*2 = 2 and B2 would become 2*2 = 4.
Any help would be greatly appreciated.
Usually the way that files are read follow this structure:
Open File using Reader. (using Scanner, FileReader, etc)
Read data. (Scanner.nextLine() for example)
Close File Reader. (close)
In your case, one possible approach is to read the data and then if you want an array of values, simply use String.split() method, passing the "," as a delimiter because it is comma separated file. Once you have an array, you make w/e changes you want. In your case, you want to iterate over that array and perform transformations.
However, I would also like to clarify something, because it is kind of implied by your question, that updating the array after you read will not update the file. Just wanted to make that clear to avoid confusion.
I am new to webharvest and am using it to get the article data from a website, using the following statement:
let $text := data($doc//div[#id="articleBody"])
and this is the data that I get from the above statement :
The Refine Spa (Furman's Mill) was built as a stone grist mill along the on a tributary of Capoolong Creek by Moore Furman, quartermaster general of George Washington's army
Notable people
Notable current and former residents of Pittstown include:
My question is that, is it possible to subtract a string from another
in the above example : "Notable people" from the content.
Is it possible to do this way? If its possible please let me know how. Thanks.
Is there something that I can do like this:
if (*contains*($text, 'Notable people')) then $text := *minus*($text, 'Notable people')
contains is a example function name to determine is a string is a substring of another,
and minus is a example function name to remove a substring from another
The desired output:
The Refine Spa (Furman's Mill) was built as a stone grist mill along the on a tributary of Capoolong Creek by Moore Furman, quartermaster general of George Washington's army
Notable current and former residents of Pittstown include:
From http://web-harvest.sourceforge.net/manual.php :
regexp
Searches the body for the given regular expression and optionally replaces found occurrences with specified pattern.
If body is a list of values then the regexp processor is applied to every item and final execution result is the list.
You just have to use correct regular expression a correct regexp-pattern and correct regexp-result
I am using the Java Inflector library to convert singular forms to plurals, example : 2 boat => 2 boats.
However, it fails when the inputs are already plural.
1 boats => boats,
butterflies => butterflieses
Is there any other Java utility that -
1. Converts plurals to singular when necessary, example : 1 boat => boat
2. Retains plural as it is, if the plural form is required.
Thanks!
You know, you can make a simulation, first avoid to convert verbs that are already in plural, how? take the verb and convert it to singular, then convert it in plural and check if the result string is the same than the string that is in the input, if not, thats ok, know you know that is not in plural.
Sorry if my question sounds dumb. But some time small things create big problem for you and take your whole time to solve it. But thanks to stackoverflow where i can get GURU advices. :)
So here is my problem. i search for a word in a string and put 0 where that word occur.
For example : search word is DOG and i have string "never ever let dog bite you" so the string
would be 000100 . Now when I try to convert this string into INT it produce result 100 :( which is bad. I also can not use int array i can only use string as i am concatinating it, also using somewhere else too in program.
Now i am sure you are wondering why i want to convert it into INT. So here my answer. I am using 3 words from each string to make this kind of binary string. So lets say i used three search queries like ( dog, dog, ever ) so all three strings would be
000100
000100
010000
Then I want to SUM them it should produce result like this "010200" while it produce result "10200" which is wrong. :(
Thanks in advance
Of course the int representation won't retain leading zeros. But you can easily convert back to a String after summing and pad the zeros on the left yourself - just store the maximum length of any string (assuming they can have different lengths). Or if you wanted to get even fancier you could use NumberFormat, but you might find this to be overkill for your needs.
Also, be careful - you will get some unexpected results with this code if any word appears in 10 or more strings.
Looks like you might want to investigate java.util.BitSet.
You could prefix your value with a '1', that would preserve your leading 0's. You can then take that prefix into account you do your sum in the end.
That all is assuming you work through your 10 overflow issue that was mentioned in another comment.
Could you store it as a character array instead? Your using an int, which is fine, but your really not wanting an int - you want each position in the int to represent words in a string, and you turn them on or off (1 or 0). Seems like storing them in a character array would make more sense.