Anyone know how to prevent this type mismatch error?

RGould8 at aol.com RGould8 at aol.com
Fri Oct 11 18:00:01 CDT 2002


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
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.runrev.com/pipermail/use-livecode/attachments/20021011/55d81afe/attachment.html>


More information about the use-livecode mailing list