Repeat
Richard Kreiss
rkreiss at verizon.net
Fri Mar 4 15:10:36 PST 2011
Brian,
No offense taken.
It is just a matter of realizing exactly how repeat is working as I don't use it a lot. As well as understanding precisely what the manual is saying.
As for quoting, again, this is considering how pushkey handles the input from the repeat. I kept looking at it as one would write pushkey manually, not acting an actual key stroke. That is why I added the extra quotes.
Considering everything, this was a good learning lesson.
Sometimes one plays with a filePro function to see if it can be made to do something that it wasn't programmed to do. I spent a lot of time playing around with the browse lookup function to see if I could get the windows size to be a variable based on the number of records to be displayed. I was working on an app for my community to list allowable visitors based on a list supplied by a resident. Some had 1 or 2 some had up to 30 names. I hated the blank space that came up using the standard browse format. After playing with it for a while, I finally figured out how to get the format to use a variable for the window size.
The method works but I am sure that it could be refined or done a bit better. At this point, the important thing is that it works and I can use it in other places where appropriate.
Richard
-----Original Message-----
From: filepro-list-bounces+rkreiss=verizon.net at lists.celestial.com [mailto:filepro-list-bounces+rkreiss=verizon.net at lists.celestial.com] On Behalf Of Brian K. White
Sent: Friday, March 04, 2011 4:06 PM
To: filePro Mailing List
Subject: Re: Repeat
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
_______________________________________________
Filepro-list mailing list
Filepro-list at lists.celestial.com
Subscribe/Unsubscribe/Subscription Changes http://mailman.celestial.com/mailman/listinfo/filepro-list
More information about the Filepro-list
mailing list