Page 1 of 1

parse a type to a function

Posted: Fri Mar 10, 2006 7:02 am
by Seb McClouth
Can I parse for example:

Code: Select all

DECLARE FUNCTION CheckType (ctype)

TYPE sumfin
  x AS INTEGER
  y AS INTEGER
  c AS INTEGER
  t AS STRING
END TYPE

DIM SHARED wins AS sumfin

wins.x = 0:wins.y = 10: wins.c = 2: t = "dull!"

parsed = CheckType(wins)

IF PARSED = 1 THEN
   PRINT "Okay"
ELSE
   PRINT "Not okay." 'Duh!!
END IF

FUNCTION CheckType (ctype)

IF ctype.x > 0 AND ctype.x < 20 THEN
  IF ctype.y > 0 AND ctype.y < 20 THEN
    IF ctype.c > 0 AND ctype.c <= 15 THEN
      IF ctype.t <> "" THEN
        CheckType = 1
        EXIT FUNCTION
      ELSE
         CheckType =0
      END IF
   ELSE
     CheckType = 0
   END IF
  ELSE
   Checktype = 0
  END IF
ELSE
  CheckType = 0
END IF
END FUNCTION
grtz
Seb

Posted: Fri Mar 10, 2006 7:08 am
by Z!re
Yes, just do:
ctype AS sumfin

And it'll work

Posted: Fri Mar 10, 2006 7:21 am
by Seb McClouth
Thx Z!re... damn I could have thought of that myself...

Posted: Fri Mar 10, 2006 7:33 am
by Seb McClouth
and then we had the following:
^. TYPE not defined
^. Formal parameter specification illegal
Could it because the DECLARE for the FUNCTION is after... erm... TYPE?

Posted: Fri Mar 10, 2006 8:11 am
by Seb McClouth
mm.... nvm... it did work...