PowerBuilder ‘Gotcha’ – Autoscript and Clipboard

Posted on Wednesday, February 2nd, 2011 at 8:20 pm in

Ah, you finally gotten the time to refactor some code or maybe even clean up some proof of concept to move it into an actual application and now it’s time to make the stuff more ‘Object Oriented’. You look in your Open method and it’s full of various stuff.

You create a new method to encapsulate some piece you intend to remove from ‘Open’. You highlight the code, control – X to cut it into the buffer, save to validate the event is still okay after removing the code, switch to the new method, and start typing in some variable, object, etc. prior to pasting in the code. Poof! – autoscript comes up with the syntax to complete the declaration/call/whatever. Nice, you think, I didn’t have to remember any of that stuff.

Thanks Powerbuilder, the code snippet you put into the clipboard previously is gone. I hope you are using some sort of version control. Aha! you are. But wait – this was a new object so it isn’t registered…

To get around this you should make it a habit to paste your code into a text editor somewhere right after it is clipped. You can also disable autoscript (I don’t like this), or set the millisecond delay to at least 15000 or so.

Update March 2021 – The autoscript delay is limited to 6000…be warned.