Subject: | Re: Help with LocateNextPattern
| Date: | Fri, 16 Aug 2019 12:47:22 +0100
| From: | Michael Kennedy <Info@KennedySoftware.ie>
| Newsgroups: | pnews.paradox-development
|
Kevin,
Yep - I think you're "close"... But, for example, I think your code
won't work if there are NO matching patterns in the TC table... because
it'll always think there's at least one match!
Also, you have two sets of identical code, which I, personally, dislike
a lot... Some day, someone may change one set, and forget to change the
other set, and... BOOM!
And, just a stupid question... In your FOR loop, I think you're quitting
the for-loop as soon as you get the first stFindValue match (if any).
that's a bit unusual in code... Is that OK?
So, going back to my logic, I think this will work:
Find out what type of variable is returned from the locatePattern() and
locateNextPattern() functions (probably boolean?), and define a variable
named gotHit, of that type. Hopefully, that var will also be acceptable
in a WHILE command (boolean, unsigned int, signed int, etc?)!
si2 = 1
uiListFrom.Attach(ListA1)
uiListTo.Attach(ListB1)
uptc.open("Main.DB")
uptc.edit()
delayScreenUpdates(Yes)
tc.open(":PRIV:__avcell.db")
tc.home()
gotHit = tc.locatePattern(WG,WGC)
while gotHit
stFindValue = tc."ListName"
vid = tc."Main ID"
scan uptc for uptc."Main ID" = vid :
uptc."Selected" = "Y"
uptc.postRecord()
endscan
for siCounter from si2 to (uiListSearch.list.count)
uiListSearch.list.selection = siCounter
if (stFindValue = uiListSearch.list.value) then
si2 = siCounter-1
uiListTo.list.selection = uiListTo.list.count + 1
uiListTo.list.value = uiListFrom.list.value
uiListFrom.list.value = ""
quitloop
endif
endfor
gotHit = tc.locateNextPattern(WG,WGC)
endWhile
uptc.endEdit()
uptc.close()
tc.close()
- Michael
On 16/08/2019 10:40, Kevin Baker wrote:
> Mike,
>
> Here's what I came up with, it works. Thanks for the help!
>
> si2 = 1
> uiListFrom.Attach(ListA1)
> uiListTo.Attach(ListB1)
> uptc.open("Main.DB")
> uptc.edit()
>
> delayScreenUpdates(Yes)
>
> tc.open(":PRIV:__avcell.db")
> tc.home()
> tc.locatePattern(WG,WGC)
> stFindValue = tc."ListName"
> vid = tc."Main ID"
>
> scan uptc for uptc."Main ID" = vid :
> uptc."Selected" = "Y"
> uptc.postRecord()
> endscan
>
> for siCounter from si2 to (uiListSearch.list.count)
> uiListSearch.list.selection = siCounter
> if (stFindValue = uiListSearch.list.value) then
> si2 = siCounter-1
> uiListTo.list.selection = uiListTo.list.count + 1
> uiListTo.list.value = uiListFrom.list.value
> uiListFrom.list.value = ""
> quitloop
> endif
> endfor
>
> while tc.locateNextPattern(WG,WGC)
> stFindValue = tc."ListName"
> vid = tc."Main ID"
>
> scan uptc for uptc."Main ID" = vid :
> uptc."Selected" = "Y"
> uptc.postRecord()
> endscan
>
> for siCounter from si2 to (uiListSearch.list.count)
> uiListSearch.list.selection = siCounter
> if (stFindValue = uiListSearch.list.value) then
> si2 = siCounter-1
> uiListTo.list.selection = uiListTo.list.count + 1
> uiListTo.list.value = uiListFrom.list.value
> uiListFrom.list.value = ""
> quitloop
> endif
> endfor
> endWhile
>
> uptc.endEdit()
> uptc.close()
> tc.close()
|