Showing posts from May, 2011

Curious bug in CodeSnip???

A user of my CodeSnip program has reported a strange bug where, after using the Snippets Editor to add a new snippet, the editor dialog box refuses to close, hanging the program. Apparently this happens only sometimes, and affects v3.8.9 and some earlier versions. I can't reproduce the problem and was wandering if anyone else has experienced this bug. If so it would be very helpful if you could leave a comment describing what happened and what you were doing when the bug arose. Thanks

Delphi, Javascript and Floating Point Parameters

I recently came across an interesting little problem when using Delphi to call JavaScript in an HTML document loaded into a TWebBrowser control. The code used the execScript method of the IHTMLWindow interface, which requires that a string containing the JavaScript function call is passed as one of its parameters. So you have to assemble a string containing the function call and its parameters, something like this: var JSFn : string ; StrParam : string ; IntParam : Integer ; FloatParam : Double ; begin StrParam := 'Say \"Hello\"' ; // double quotes must be escaped IntParam := 42 ; FloatParam := 1234.56789 ; JSFn := Format ( 'Foo(%d, "%s", %.8f);' , [ IntParam , StrParam , FloatParam ] ) ; ExecJS ( JSFn ) ; end ; I'll show ExecJS later. It's just a wrapper that ultimately calls IHTMLWindow.execScript with the required JavaScript. The interesting bit is what happens to the floating