Anyone know how to prevent this type mismatch error?

Ken Ray kray at sonsothunder.com
Sun Oct 13 01:51:01 EDT 2002


Rob,

I checked the code on another machine and it turns out that in some cases,
the configuration doesn't have a class, and so it fails on the line:

  if (class of configuration i of config) is (TCPIP v4 configuration) then

It's not that "TCPIP v4 configuration" is bad... it just has a problem
getting a class for the config. So it might not be an OS 9/OS X problem
after all. This happened to me on an Airport configuration (which I
discovered by asking for "the name of configuration i of config").

Try wrapping the "if" statement in a try/end try, as in:

repeat with i from 1 to count of configuration of config
  try
    if (class of configuration i of config) is (TCPIP v4 configuration) then
      set cfg to configuration i of config
      set configName to name of config
      exit repeat
    end if
  end try
end repeat

At least this should skip over those configurations that don't have a
class... you might want to trap an "on error" and see what the configuration
name is if you're interested.

Hope his helps,

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/


----- Original Message -----
From: <RGould8 at aol.com>
To: <use-revolution at lists.runrev.com>
Sent: Saturday, October 12, 2002 5:53 PM
Subject: Re: Anyone know how to prevent this type mismatch error?


Ahhh - - - perhaps that's the problem.   I was looking for an Applescript
solution in OS 8/9 that would set the user's networking to DHCP.   So, if
this was designed to run in 10, then that sheds some light on the issue.

In the long-run, I'll need to do this on both Mac OS 9 _and_ Mac OS X.   I
was assuming that the technique would be radically different, with OS X
relying on more unix-calls.   Resources on the web that detail how to script
the networking control pane are few and far between, it seems.

>From what I gather from the script, it appears that there's some sort of
networking database that is being opened up, that contains different
networking settings.   The script appears to go through the list in the
database until it finds the active setting, and attempts to modify it to
"Use
DHCP" - - is that the correct description of what's going on?

If this script is designed to run on OS X - - - can anyone shed light on how
different the OS 9 version would be?

Thanks again for your help - - - this is indeed one of the best Listserve's
I've been on.   Folks here are very helpful and knowledgeable.

- Rob

In a message dated 10/11/02 9:01:45 PM, kray at sonsothunder.com writes:


> Rob,
>
> What version of AppleScript/Mac OS are you using? It is possible that this
> configuration didn't work properly in earlier versions...
>
> The reason I say that is that since I was the original poster of the
> AppleScript (to which Sarah added her valuable additions), and it worked
> for
> me on an iMac running OS 10.1...
>
> Let us know,
>
> Ken Ray
> Sons of Thunder Software
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/
>
> ----- Original Message -----
> From: <RGould8 at aol.com>
> To: <use-revolution at lists.runrev.com>
> Sent: Friday, October 11, 2002 5:53 PM
> Subject: Re: Anyone know how to prevent this type mismatch error?
>
>
> Sarah - - - thanks so much for this script. I've hit one stumbling block
> that's keeping it from running, and no one seems to know how to fix it - -
> -
> was wondering if someone on this list might:
>
> The problem is with this line:
>
> if (class of configuration i of config) is (TCPIP v4 configuration)
>
> appleScript is complaining of a type mismatch problem. I thought perhaps
> putting
>
> if (class of configuration i of config) as string is (TCPIP v4
> configuration)
>
> might fix the problem, but that gave me a syntax error. I've only been
> scripting for about 2 months. Would anyone happen to know how to solve
> such
> type-matching errors? The impression I get is that you can't compare a
> string to a class.
>
> - Rob
>
> In a message dated 10/2/02 7:08:18 PM, sarahr at genesearch.com.au writes:
>
> >
> > Hi Rob,
> >
> > Here is Ken's script with an added section that changes the relevant
> > setting to DHCP. As Ken mentioned, this just handles the first TCP
> > configuration it finds, so you might need to add a check for other
> > configs, but it should get you started:
> >
> > set configMethod to ""
> > set configName to ""
> > set cfg to ""
> >
> > tell application "Network Setup Scripting"
> > open database
> > set config to current configuration set
> > repeat with i from 1 to count of configuration of config
> > if (class of configuration i of config) is (TCPIP v4 configuration)
> > then
> > set cfg to configuration i of config
> > set configName to name of config -- so you can check the name
> > to see
> > if it's the right one
> > exit repeat
> > end if
> > end repeat
> > set configMethod to configuration method of cfg
> >
> > try
> > if configMethod ≠ "DHCP" then
> > begin transaction
> > set protec to get protection of configuration method of cfg
> > if protec = locked then return "Setting is locked"
> > set the configuration method of cfg to DHCP
> > end transaction
> > end if
> > on error errMsg number errNum
> > close database
> > return "Error: " & errMsg & " " & errNum
> > end try
> >
> > close database
> > return "Setting changed to DHCP"
> > end tell
> >
> > Note: there is a line above that uses the Mac's Not-equal sign
> > (option-equal): if configMethod **not-equal** "DHCP" then
> > It may not translate via email. Also beware of long lines wrapping. If
> > you want me to send you the actual script, send me an email off-list.
> >
> > Sarah
> >
> > _______________________________________________
> > use-revolution mailing list
> > use-revolution at lists.runrev.com
> > http://lists.runrev.com/mailman/listinfo/use-revolution
> >
> >
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>





More information about the use-livecode mailing list