Repeat

Brian K. White brian at aljex.com
Fri Mar 4 13:06:21 PST 2011


On 3/4/2011 1:50 PM, Richard Kreiss wrote:
> Joe,
>
> Try this code:
>
> 63  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>         ◄ If: br gt "1"
>         Then: zz=repeat("[CDWN]","6"*br)
>   64  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>         ◄ If: br gt "1"
>         Then: pushkey "\""{zz{"\""
>
> I set br=@br-"1" as you will be starting on the first row.
>
> If you set br to @br, the cursor will be moved to the next record.
>
> Place the above code above your browse line.

Gah don't help until _after_ you actually understand it yourself.

Is it really so hard to keep track of where & when to quote? & how & 
why? Is it really so hard to devise a sensible, methodical, sequence of 
trial & error tests that starts with nothing and gradually adds things, 
changing only one variable at a time, to see what effect each new 
addition has, so that you actually understand how the tool you are 
trying to use behaves, instead of scattershotting around trying guesses 
at random which never builds any basis which can be used to deduce why 
each new attempt doesn't do what you expected? Is it really so hard to 
insert a few shows, and remember that show itself is affected by quoting 
& escaping, to see if variables actually contain what you think they 
should contain just before they are used? Figure out how the building 
blocks themselves work before trying to assemble them into anything 
larger. Figure out out how to make repeat() do what you want by just 
playing with repeat() itself with hard coded values and show statements. 
Then figure out how to feed keystrokes to browse with pushkey using just 
pushkey and litteral values. THEN when you've figured out that 'doing 
pushkey "[CDWN][CDWN]" just before lookup works' and 'I definitely know 
how to make repeat() output "[CDWN][CDWN]" perfectly any time I want' 
Only then does it make any sense to try to combine the two into 
something more complex and expect it to actually work.

Above, you are going out of your way to tell pushkey to actually push 
litteral " marks, as if the user pressed ". Would the user ever actually 
press " at the time & place this pushkey is run?

It may have seemed to work, because in that particular context pressing 
" probably has no _apparent_ effect. It has an effect, the keystroke is 
sent, received, processed, and ultimately ignored. But that doesn't mean 
it's harmless to send it when it's not expected or intended.

If you want to press down N times,

pushkey repeat("[CDWN]",N*"6")

No mystery & no flakiness.

If you need to build a variable and pushkey that instead:

zz = repeat("[CDWN]",n*"6")
pushkey zz

If you want to ensure that it's really sending what you think, and avoid 
the incorrect assumption I described above:

zz = repeat("[CDWN]",n*"6")
show "zz=\"" & zz & "\""
pushkey zz


Put this in a table:
@keyt
dim mmm(6)
mmm("1") = "01"
mmm("2") = "02"
mmm("3") = "03"
mmm("4") = "04"
mmm("5") = "05"
mmm("6") = "06"
n = "4"
zz = repeat("[CDWN]",n*"6")
show "zz=\"" & zz & "\""
pushkey zz
x = listbox(mmm)
show ""
end

bang T Enter T Enter all you want, it will always work and always show 
exactly the same thing and zz="" will show exactly and only what is 
expected. The extra, escaped, quotes on the show line are specifically 
because I DO want literal quotes to appear in the display, and the & 
instead of { are also deliberate so that the display will leave no doubt 
about what is and is not in the zz variable.

("work" in this case means it highlights line 5)

After doing that just to arrive at a syntax that nit only seems to work, 
but you have proven that it's really only doing what you wanted inside 
in the parts you can't see, you can remove the unnecessary extra 
variables and shows.

@keyt
dim mmm(6)
mmm("1") = "01"
mmm("2") = "02"
mmm("3") = "03"
mmm("4") = "04"
mmm("5") = "05"
mmm("6") = "06"
n = "4"
pushkey repeat("[CDWN]",n*"6")
x = listbox(mmm)
end

I'm sorry my impatient nature refuses to couch this in nicer tones. You 
don't really deserve to be demeaned since I'm sure you've done a lot of 
good work for a lot of clients for ages, and not grasping some quoting 
syntax is hardly a moral failing.

-- 
bkw


More information about the Filepro-list mailing list