Forums › Forums › SIMPOL Programming › another issue:
- This topic has 3 replies, 2 voices, and was last updated 14 years, 4 months ago by Jim Locker.
- AuthorPosts
- December 11, 2009 at 6:35 am #28Jim LockerMember
a statement like this will always fail, even when the referenced array contents are indeed identical: if array1[“VAL1”] == array2[1,ii] and array1[“VAL2”] == array2[2,ii] and array1[“VAL3”] == array2[3,ii] else end if The above statement will ALWAYS take the else branch. If rewritten like this: testval1 = array1[“VAL1”] : testval2 = array2[1,ii] if testval1 == testval2 testval1 = array1[“VAL2”] : testval2 = array2[2,ii] if testval1 == testval2 testval1 = array1[“VAL3”] : testval2 = array2[3,ii] if testval1 == testval2 end if end if end if it will evaluate correctly.
December 11, 2009 at 2:33 pm #1675MichaelKeymasterJim wrote:
> a statement like this will always fail, even when the referenced
> array contents are indeed identical:
>
> if array1["VAL1"] == array2[1,ii] and array1["VAL2"] == array2[2,ii]
> and array1["VAL3"] == array2[3,ii]
>
> else
>
> end if
>
> The above statement will ALWAYS take the else branch.
>
> If rewritten like this:
>
> testval1 = array1["VAL1"] : testval2 = array2[1,ii] if testval1 ==
> testval2 testval1 = array1["VAL2"] : testval2 = array2[2,ii] if
> testval1 == testval2 testval1 = array1["VAL3"] : testval2 =
> array2[3,ii] if testval1 == testval2
>
> end if end if end if
>
> it will evaluate correctly.
>Again, a small reproducible would be good here. I have occasionally seen
this sort of behavior, but I invariably discover something about my data
upon closer inspection.Ciao, Neil
December 11, 2009 at 5:08 pm #1824Jim LockerMemberNeil Robinson wrote:
> Jim wrote:
>> a statement like this will always fail, even when the referenced
>> array contents are indeed identical:
>>
>> if array1["VAL1"] == array2[1,ii] and array1["VAL2"] == array2[2,ii]
>> and array1["VAL3"] == array2[3,ii]
>>
>> else
>>
>> end if
>>
>> The above statement will ALWAYS take the else branch.
>>
>> If rewritten like this:
>>
>> testval1 = array1["VAL1"] : testval2 = array2[1,ii] if testval1 ==
>> testval2 testval1 = array1["VAL2"] : testval2 = array2[2,ii] if
>> testval1 == testval2 testval1 = array1["VAL3"] : testval2 =
>> array2[3,ii] if testval1 == testval2
>>
>> end if end if end if
>>
>> it will evaluate correctly.
>>> Again, a small reproducible would be good here. I have occasionally seen
> this sort of behavior, but I invariably discover something about my data
> upon closer inspection.> Ciao, Neil
Finding that one took me awhile, and I analyzed that data to a fare thee
well before rewriting the code; there are NO data issues.However on this one I'll pass; setting up a demo example would take a fair
amount of time, and the issue really isn't *that* important; I'll just
know to avoid the construction that fails, and I'll also know to look for
that problem.There are a number of unexpected subtleties in how arrays work, and I am
inclined to call these subtleties bugs because they lead to
inconsistencies in how things work. I am using them for indirection and
for hashing, and for many of those things that I would use data structures
and pointers for in C. However, the actual passing of the contents or a
proper reference to the contents is not totally reliable, as this case
indicates. I am learning that often I am safest passing the array member
contents to a temporary variable and using the temporary variable.I would prefer to not have to do this, but needs must.
This is the same basic issue that came up with my "object not found"
post.; contents of an array (or the array reference) were not passed in
the expected fashion.December 14, 2009 at 11:33 am #1436MichaelKeymasterJim wrote:
> Finding that one took me awhile, and I analyzed that data to a fare
> thee well before rewriting the code; there are NO data issues.
>
> However on this one I'll pass; setting up a demo example would take a
> fair amount of time, and the issue really isn't *that* important;
> I'll just know to avoid the construction that fails, and I'll also
> know to look for that problem.
>
> There are a number of unexpected subtleties in how arrays work, and I
> am inclined to call these subtleties bugs because they lead to
> inconsistencies in how things work. I am using them for indirection
> and for hashing, and for many of those things that I would use data
> structures and pointers for in C. However, the actual passing of the
> contents or a proper reference to the contents is not totally
> reliable, as this case indicates. I am learning that often I am
> safest passing the array member contents to a temporary variable and
> using the temporary variable.I would suggest, if you have any sort of complex data, createa type to
match it, and store the type in the array. Then everything should work
as expected.> I would prefer to not have to do this, but needs must.
>
>
> This is the same basic issue that came up with my "object not found"
> post.; contents of an array (or the array reference) were not passed
> in the expected fashion.Arrays in SIMPOL are not arrays of a given type, and as such, they work
in slightly different ways. Array elements that contain a value are the
only case that I am aware of where the element cannot be treated as an
object. That is because the array is the object, and this is just a
value in the object. If you want the content of the array to act like
objects, assign them as object references, using =@, not =.Ciao, Neil
- AuthorPosts
- You must be logged in to reply to this topic.