PDA

View Full Version : Need help on nesting functions...



TRILIGHT
10-14-2003, 07:54 PM
I don't really know if this is the correct way to describe it but
I want to include a way to do things with multiple matches. Basically, what I've seen and used is the following...



ForeachMfsFile fsid name type "/Resource/Image" "" {

RetryTransaction {

set resobject [db $db openid $fsid]
set resname [dbobj $resobject get Name]
set resfsid [dbobj $resobject get File]

if { $resname == "PowerOnCoverup.1" } {
set newfsid [ToMfs POC1.png]
dbobj $resobject set File $newfsid
}
}
}

Now, this searches through "/Resource/Image" and performs the function if the name is matched. However, this is only effective for a single match and replacement. I would like to know how to include other matches/replacements during the same search. So as things are matched, they are replaced and only a single scan is required. Can someone assist me with figuring out how to do this properly? Thanks!

mrblack51
10-14-2003, 08:47 PM
ForeachMfsFile fsid name type "/Resource/Image" "" {

RetryTransaction {

set resobject [db $db openid $fsid]
set resname [dbobj $resobject get Name]
set resfsid [dbobj $resobject get File]

if { $resname == "PowerOnCoverup.1" } {
set newfsid [ToMfs POC1.png]
dbobj $resobject set File $newfsid
}

if { $resname == "PowerOnPowerup.8" } {
set newfsid [ToMfs POP8.png]
dbobj $resobject set File $newfsid
}

}
}


that will replace both parts of the aquiring sat image. if you wanted to do more replacements, the same pattern could be followed. basically, it will check to see if the current resource name is equal to the one you want to replace. this method will check everything each iteration, but the comparisons are cheap computationally