1. user types vs built-ins

I have two small code blocks:

-- code1 -- 
object h1 
h1 = "10" 
-- code2 -- 
type test(object x) 
  return x 
end type 
 
test h1 
 
h1 = "10" 

Code1 runs, but code2 crashes with a type error. Why doesn't code 2 run?

new topic     » topic index » view message » categorize

2. Re: user types vs built-ins

Looks like your type() function is not returning true, so it's going to fail the type check.

Try something like:

   return object(x) 

or the result of whatever you're testing x for.

"10" does not resolve to 'true,' so that's why it's failing (I suspect).

new topic     » goto parent     » topic index » view message » categorize

3. Re: user types vs built-ins

katsmeow said...

I have two small code blocks:

-- code1 -- 
object h1 
h1 = "10" 
-- code2 -- 
type test(object x) 
  return x 
end type 
 
test h1 
 
h1 = "10" 

Code1 runs, but code2 crashes with a type error. Why doesn't code 2 run?

A type function should return 1 or 0. It's meant for type checking.

Matt

new topic     » goto parent     » topic index » view message » categorize

4. Re: user types vs built-ins

mattlewis said...
katsmeow said...

I have two small code blocks:

-- code1 -- 
object h1 
h1 = "10" 
-- code2 -- 
type test(object x) 
  return x 
end type 
 
test h1 
 
h1 = "10" 

Code1 runs, but code2 crashes with a type error. Why doesn't code 2 run?

A type function should return 1 or 0. It's meant for type checking.

Matt

Thanks, Matt, that was it. I read User-defined types section in the OE-315.pdf help file, that bit of data isn't explicitly there.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu