Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
errOSABadStorageType trying to load script?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

errOSABadStorageType trying to load script?



I'm still having problems loading and executing scripts. Thanks to Micah Koch's post from yesterday, I got past my earlier problem of getting the component. But now when I call OSALoad I get an errOSABadStorageType (-1752) as a result.

I'm loading a text file, that it as simple as:

say "hello"\r

Eventually, I want to switch to loading compiled scripts, but one step at a time.

Any help would be most welcomed.
TIA,
Brant

//------------------------------------------------------------------------------
- (void)loadScript
{
if (!loaded)
{
if (VScript_sScriptingComponent == 0)
{
VScript_sScriptingComponent = OpenDefaultComponent(kOSAComponentType, kAppleScriptSubtype);
}

{
NSData* fileData = [NSData dataWithContentsOfFile:filePath];
char* dataPtr = (char*)[fileData bytes];
AEDesc scriptDesc;

OSAError err = AECreateDesc( typeOSAGenericStorage, dataPtr, [fileData length], &scriptDesc );
if (err == noErr)
{
err = OSALoad(VScript_sScriptingComponent, &scriptDesc, kOSAModeNull, &scriptID);
if (err == noErr)
{
loaded = YES;
}
}
}
}
}

//------------------------------------------------------------------------------
- (void)execute
{
[self loadScript];
if (scriptID != kOSANullScript)
{
OSAID resultID = kOSANullScript;
OSAError err = OSAExecute(VScript_sScriptingComponent, scriptID,
kOSANullScript, kOSAModeNull, &resultID);
}
}




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.