Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binding Error for ShowText Fixed #4

Open
jackien1 opened this issue Jul 26, 2019 · 0 comments
Open

Binding Error for ShowText Fixed #4

jackien1 opened this issue Jul 26, 2019 · 0 comments

Comments

@jackien1
Copy link

jackien1 commented Jul 26, 2019

I changed the code from

Robot.prototype.showText = function(text, interval, scrIn, complete) { let ind = scrIn?-3:0, tId = setInterval(timeFunc, interval); function timeFunc() { if(ind < 1) { this.write(164); for(let i=0,l=-ind; i<l; i++) this.write(0); this.write(text.substring(0,4-l)); } else { let str = text.substr(ind,4); this.write(164,str); for(let i=0,l=4-str.length; i<l; i++) this.write(0); if(!str.length || (!scrIn && str.length < 4)) { if(str.length) this.write(164,0,0,0,0); clearTimeout(tId); if(typeof complete == "function") complete(); } } ind++; } timeFunc(); return tId; }

to

Robot.prototype.showText = function(text, interval, scrIn, complete) { let ind = scrIn?-3:0, tId = setInterval(timeFunc.bind(this), interval); function timeFunc() { if(ind < 1) { console.log(this == undefined) this.write(164); for(var i= 0,l =- ind; i<l; i++) this.write(0); this.write(text.substring(0,4-l)); } else { let str = text.substr(ind,4); this.write(164,str); for(var i=0,l=4-str.length; i<l; i++) this.write(0); if(!str.length || (!scrIn && str.length < 4)) { if(str.length) this.write(164,0,0,0,0); clearTimeout(tId); if(typeof complete == "function") complete(); } } ind++; } return tId; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant