Pasting the contents of the clipboard into multiple fields

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
SirWobbyTheFirst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 246
Joined: Tue Jun 30, 2009 11:15 pm

Pasting the contents of the clipboard into multiple fields

Post by SirWobbyTheFirst » Fri Jul 09, 2010 9:15 pm

Hello everyone.

How does Revolution paste your serial number into the five fields when your activating it on the first run. I've been experimenting with the PasteKey message but with little success. I want a way for the user to just directly paste my applications serial number in without having to hilight each section of it, additionally how do you get rev to switch to the next field when the 5 characters of a field have been entered (Chances are this will be a really noob question).

As per se, all help is most appreciated. Thank you.

doc
Posts: 148
Joined: Fri Jun 09, 2006 4:30 pm

Re: Pasting the contents of the clipboard into multiple fields

Post by doc » Fri Jul 09, 2010 9:51 pm

How does Revolution paste your serial number into the five fields when your activating it on the first run.
Hello,
I've prepared a simple little sample stack that will show at least one way to do it...
Keep in mind that I didn't add any kind of error checking or such, so that part is up to you. :)

http://www.docstoolchest.com/PasteInFields.rev

...and have a look at "focus" in the rev documentation for the other answer you need.

HTH,
-Doc-

SirWobbyTheFirst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 246
Joined: Tue Jun 30, 2009 11:15 pm

Re: Pasting the contents of the clipboard into multiple fields

Post by SirWobbyTheFirst » Fri Jul 09, 2010 9:54 pm

Sup, Doc. (I always wanted to say that)

You don't know the kind of face palm I've just done when you mentioned the word Focus because I used it previously to make a Search box become active when the user clicked on the Search menu item in the menu and it's just hit me like a brick wall. :roll:

doc
Posts: 148
Joined: Fri Jun 09, 2006 4:30 pm

Re: Pasting the contents of the clipboard into multiple fields

Post by doc » Fri Jul 09, 2010 10:20 pm

Heh... that's never happened to me. :wink:

Here's another little bit of code you can substitute for the one I used in the sample stack. Perhaps a bit more elegant:

Code: Select all

on mouseUp
   put the clipboarddata into tRegistration
   repeat with i =  1 to 5
      put char 1 to 4 of tRegistration into fld (("Field") & (i))
      delete char 1 to 4 in tRegistration
   end repeat
   put "" into fld "RegField"
end mouseUp
...although it's quite simple to code as I did in the original example, I didn't exactly intend to recommend it that way. :)
Sure wouldn't be much fun if you had a lot of fields of data to work with....

-Doc-

SirWobbyTheFirst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 246
Joined: Tue Jun 30, 2009 11:15 pm

Re: Pasting the contents of the clipboard into multiple fields

Post by SirWobbyTheFirst » Fri Jul 09, 2010 10:27 pm

Well whenever I am writing code, I always try and find ways of minimizing the number of lines in it. Because for some strange reason I think that the lower the number of lines of code the faster the script will operate and I have been this way even when writing Visual Basic, Revolution, even the Batch files for the DOS and the Command Prompt.

I'll have a bash at that script when I fire Rev up tomorrow. So thank you.

Post Reply