This Question is Answered

13 "helpful" answers available (3 pts)
9 Replies Last post: Feb 22, 2008 12:03 PM by friedger

Reload when importing a package

Feb 21, 2008 4:45 AM

Click to view friedger's profile MVP friedger 103 posts since
Jan 13, 2008

Hi,

I try to import the packages of the currrent project opened in Surge Lab (to be used in an immediate Window) and would like to import always the latest source. Is this possible? How do I force {import-package} to reload the package (within an IDE editor}?

Another question: Is it possible to get the source location of an exception from the exception. In earlier days there was exception.url, is there an equivalent in Curl 6.0?

Friedger


Click to view friedger's profile MVP friedger 103 posts since
Jan 13, 2008
1. Re: Reload when importing a package Feb 21, 2008 4:48 AM

I have adde a screenshot to my blog to give you an impression of the immediate window:

http://curl-friedger.blogspot.com/2008/02/immediate-window-curl-ide-editor.html

Click to view cbarber's profile Curl cbarber 93 posts since
Sep 27, 2007
2. Re: Reload when importing a package Feb 21, 2008 7:37 AM
With a single applet instance all packages and other files will be synchronized as of the specified 'resync-as-of' time declared in the {applet ...} declaration. Setting this to a time in the future will cause content to be synchronized as of the start time of the applet:

{applet
    resync-as-of = {utc-date-time "4000-01-01"}
}


To force synchronization after the applet start time, you have to resort to a hack involving importing the package through a freshly modified manifest. This is described in detail along with other synchronization issues and recommendations in the "Caching and Synchronization" chapter in the Developer's Guide, which was expanded for 6.0. The downside to this technique is that previously imported packages will not be freed from memory as long as the applet is still running.

What I would recommend is that you compile and run the code in new synchronized subapplet whenever you want to force an update without having to restart the main applet.

Regarding exceptions, the url, line and column attributes were indeed removed from the Exception class because they were only used for SyntaxError, which still retains those properties; so if you want to get a source location from an Exception you just need to type-switch it to SyntaxError first.
Click to view friedger's profile MVP friedger 103 posts since
Jan 13, 2008
3. Re: Reload when importing a package Feb 21, 2008 1:38 PM
in response to: cbarber

Unfortunately, for Curl IDE editors {get-applet-data} fails as the IDE is not an applet.

Click to view cbarber's profile Curl cbarber 93 posts since
Sep 27, 2007
4. Re: Reload when importing a package Feb 21, 2008 2:09 PM
in response to: friedger

I am not sure what {get-applet-data} is. Did you mean {get-the-applet}? In any case, you are correct that the IDE does not run as an applet, so {get-the-applet} will fail. However, I think you should be able to run and interact with subapplets through the AppletData class. The subapplet will be a normal applet. You should check out the new documentation regarding subapplets in the Developer's Guide under Interacting with External Resources / Child Applets and JavaScript Support.


Click to view friedger's profile MVP friedger 103 posts since
Jan 13, 2008
5. Re: Reload when importing a package Feb 21, 2008 5:18 PM
in response to: cbarber

I got it working using AppletData, by creating a temp file for the applet that contains the code and a temp file for a manifest that delegates to the current project's manifest.
Click to view cbarber's profile Curl cbarber 93 posts since
Sep 27, 2007
6. Re: Reload when importing a package Feb 22, 2008 6:47 AM
in response to: friedger
You should be able to avoid the temp files by using string url's instead, and I don't think you should need the extra manifest if all it does is delegate to the project's manifest:

{AppletData
    null,
    {string-url
        {format
             {stringify
                {curl 6.0 applet}
                {applet
                    manifest = "%s",
                    resync-as-of = {utc-date-time "4000-01-01"}
                 }
                 %s
             }
        },
        project-manifest-url,
        applet-body
    }
}
Click to view friedger's profile MVP friedger 103 posts since
Jan 13, 2008
7. Re: Reload when importing a package Feb 22, 2008 10:55 AM
in response to: cbarber

With your suggested solution I get a security exception:

An error occurred while loading this applet.
SyntaxError: curl://string/...:2[1]: Cannot import default manifest: SecurityException: An unprivileged applet tried to read the local file 'file:///d:/...

Any ideas on that?

Friedger

Click to view cbarber's profile Curl cbarber 93 posts since
Sep 27, 2007
8. Re: Reload when importing a package Feb 22, 2008 11:26 AM
in response to: friedger

I think you just need to add 'grant-privilege? = true' to the AppletData constructor call.


Click to view friedger's profile MVP friedger 103 posts since
Jan 13, 2008
9. Re: Reload when importing a package Feb 22, 2008 12:03 PM
in response to: cbarber

Thanks, that solved it. The Immediate Window now works fine.

Friedger