View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001064 | Far Manager | Macro | public | 2009-09-22 13:36 | 2009-09-30 12:49 |
Reporter | farman | Assigned To | vskirdin | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 2.0 | ||||
Fixed in Version | 2.0 | ||||
Summary | 0001064: Error in string handling | ||||
Description | This is a little bit heavy to explain here. Seems to be an error in string handling. John Doe sais: Workaround: In first line use %si= "0"+%i; instead of %si="01". Maybe this does explain the problem a little (FAR2 ignores the "0"). Please take a look at (1st and 2nd post): http://forum.farmanager.com/viewtopic.php?f=35&t=4562&p=51355#p51355 | ||||
Tags | No tags attached. | ||||
Build | 1152 | ||||
|
Since build 1127 there are unneeded string-to-number conversions (in some cases) Simple example macro: msgbox("01") |
|
JohnDoe, see the GAWK manual :-) msgbox("01") - fixed (build 1134) |
|
vskirdin, look at this case please: %i= 1; %si= "0"+string(%i); msgbox(%si) |
|
What are your suggestions? |
|
obviously "0"+string(1)="01" |
|
hi vskirdin, this is the problem: example: %i= 1; %si= "0"+string(%i); msgbox(%si) result: %si becomes "1" (string?) expected: %si should be string "01" |
|
Sorry for my English (I use translate.google.com) :-\ What to do in a situation where the variable "A" - a string (it contains only digits), and the variable "B" - the number, and for "A + B", we do not want to get string concatenation, but we need the result of adding numbers? |
|
i knew! the translation of russian via google is one of the horriblest things in the world. ;) therefore i'm not sure what you mean. i'm sorry too. i hope we can make it step by step. a) maybe you mean that: String + number = ? well, i don't know what to do... b) but if you look above we have a clear situation: "0" = String string(%i) = string so: string + string should become string and not "1" |
|
vskirdin Ok, let String+Number=Number But in this case the type is defined explicitly: "0"+string(1) but result is 1 |
|
Term: strnum - a string containing only the "numbers" (dec, oct, hex, float) - fully converted to the number string - a string that can not be fully converted to the number number - the number (dec, oct, hex, float) Resume: strnum + number || number + strnum = number string + number || number + string = string string + strnum || strnum + string = string string + string = string Is this correct? |
|
we were talking about two problems. that was a little bit confusing, i think. sorry for that. i think that will be fine. the string solution for mixed cases seems to be more usable for the daily user. thanx very much. |
|
argh, i'm going crazy about that simple thing. maybe i better think about it at home. somehow there are too many things in my head now and here. if %i="66" than i would handle it as a string always, not as a strnum. that's because of the quotation marks usually defining a string. and therefore "0"+string(1) should become string "01". or is this a definition problem when we're using hex, oct, ... ? |
|
If both operands are of type "string", then perform the operations as a string (eg, for operation "+" - string concatenation). Assertion is true? |
|
Yes msgbox("0"+"1") must be "01" |
|
thanks for your patience, vskirdin. yes, it's like you asserted. and this is terrible wrong (build 1148). %i=1; %si= string(0)+string(%i); msgbox(%si) - becomes "1" - should be "01" |
|
verify. build after 1149 |
|
msgbox("1" + 0) 10 msgbox(1 + "0") 1 I think both must be equal |
|
this bug: msgbox("1" + 0) do it (forced conversion type to string): msgbox(string(1) + "0") be like this: 1. string + string = string 2. string + num = string 3. num + string = string 4. strnum + string = string 5. string + strnum = string 6. num + strnum = num 7. strnum + num = num End of game. |
|
so i will play the joker ;-) that's a "long" version of JohnDoe's bug: %i= 1; %si= "0"+%i; msgbox(%si) ="01" = 2. string + num = string %i= 1; %si= %i+"0"; msgbox(%si) ="1" != 3. num + string = string should both be the same string. |
|
sorry. that's more readable: so i will play the joker ;-) that's a "long" version of JohnDoe's bug: %i= 1; %si= "0"+%i; msgbox(%si) ="01" = 2. string + num = string %i= 1; %si= %i+"0"; msgbox(%si) ="1" != 3. num + string = string should both be the same string. |
|
see build 1152: msgbox("1" + 0) ==> 1 msgbox(1 + "2") ==> 3 msgbox("foo1" + 0) ==> "foo10" msgbox(string(1) + "2") ==> "12" %i=1; msgbox("0" + string(%i)) ==> "01" %i=1; msgbox(int("012ag") + %i) ==> 13 %i=1; msgbox(string(int("012ag")) + %i) ==> 13 %i=1; msgbox(string(int("012ag")) + string(%i)) ==> "121" |
Date Modified | Username | Field | Change |
---|---|---|---|
2009-09-22 13:36 | farman | New Issue | |
2009-09-22 15:16 | JohnDoe | Note Added: 0004096 | |
2009-09-22 16:52 | vskirdin | Status | new => assigned |
2009-09-22 16:52 | vskirdin | Assigned To | => vskirdin |
2009-09-22 18:09 | vskirdin | Note Added: 0004097 | |
2009-09-23 09:11 | JohnDoe | Note Added: 0004100 | |
2009-09-23 17:47 | vskirdin | Note Added: 0004101 | |
2009-09-24 09:22 | JohnDoe | Note Added: 0004102 | |
2009-09-24 10:14 | farman | Note Added: 0004103 | |
2009-09-24 11:01 | vskirdin | Note Added: 0004104 | |
2009-09-24 11:32 | farman | Note Added: 0004105 | |
2009-09-24 11:43 | JohnDoe | Note Added: 0004106 | |
2009-09-24 12:26 | vskirdin | Note Added: 0004107 | |
2009-09-24 13:44 | farman | Note Added: 0004108 | |
2009-09-24 14:05 | farman | Note Added: 0004109 | |
2009-09-25 12:30 | vskirdin | Note Added: 0004118 | |
2009-09-26 11:58 | JohnDoe | Note Added: 0004125 | |
2009-09-28 09:29 | farman | Note Added: 0004143 | |
2009-09-28 17:30 | vskirdin | Note Added: 0004147 | |
2009-09-28 17:30 | vskirdin | Status | assigned => feedback |
2009-09-29 08:04 | JohnDoe | Note Added: 0004156 | |
2009-09-29 08:21 | vskirdin | Note Added: 0004158 | |
2009-09-29 08:49 | farman | Note Added: 0004161 | |
2009-09-29 08:51 | farman | Note Added: 0004162 | |
2009-09-29 09:00 | vskirdin | Note Added: 0004163 | |
2009-09-30 09:49 | JohnDoe | Status | feedback => resolved |
2009-09-30 09:49 | JohnDoe | Resolution | open => fixed |
2009-09-30 12:49 | vskirdin | Build | => 1152 |
2009-09-30 12:49 | vskirdin | Status | resolved => closed |
2009-09-30 12:49 | vskirdin | Fixed in Version | => 2.0 |