Code
Free software.
Friday, March 07, 2003
« Radio buglet and patch »
[I posted the original version of this to the Radio Userland mailing list.]
Free software.
« Radio buglet and patch »
[I posted the original version of this to the Radio Userland mailing list.]
- I recently found a bug in the htmlControlStartup callback while figuring out how to tell the Radio app to use my own background HTML file instead of the one supplied in <RadioInstallFolder>/Appearance/html/background.html.
- What I did: I wrote an HTML file called myBackground.html and put it
in the same folder as background.html. Then I wrote a script called workspace.myBackground and added its address to user.callbacks.htmlControlStartup. I based this on the fact that all other entries in user.callbacks.* are addresses. Here's my script:
on myBackground(url) { local (appFolder = file.folderFromPath(Frontier.getProgramPath())); local (pc = file.getPathChar()); local (appearanceFolder = appFolder + "Appearance" + pc); local (htmlFolder = appearanceFolder + "html" + pc); local (myBackground = htmlFolder + "myBackground.html"); local (myURL = file.fileToUrl(myBackground)); url^ = myUrl; return true } - What I expected to happen: After stopping and restarting Radio, and opening the application, I expected to see my background.
- What actually happened: I saw Radio's default background as usual.
- The workaround: I found that I had to put my actual script, rather than its address, into user.callbacks.htmlControlStartup in order for my script to be called and take effect.
- The source of the problem: Scripts in
user.callbacks.htmlControlStartup are called by
system.callbacks.htmlControlStartup. I compared the callback code there with callback code in other system.callbacks scripts, and found that there was some missing code. Here's the loop in htmlControlStartup:
for adrScript in @user.callbacks.htmlControlStartup { try { if adrScript^ (@url) { return (url) } } }Here's the equivalent loop in system.callbacks.opExpand:for adrscript in @user.callbacks.opExpand { try { while typeOf (adrScript^) == addressType { adrScript = adrScript^ }; if adrscript^ () { return (true) } } }Clearly, the while loop that dereferences the address of the user callback script is missing in htmlControlStartup. - The fix: I have a patched version system.callbacks.htmlControlStartup available for download here. I have tested it and it seems to work fine. It would be great if [UserLand] would examine this to make sure it's right, and if so, make it generally available.