parse a type to a function

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
User avatar
Seb McClouth
Veteran
Posts: 342
Joined: Wed Nov 09, 2005 7:47 am
Location: Inside the Matrix...
Contact:

parse a type to a function

Post 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
QBinux is a Linux distribution with the aim of integrating the work of the vast community of free software developers at Pete's QBASIC Site in order to create a modern, performant, safe and easy to use system for system administrators and desktop users.
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

Yes, just do:
ctype AS sumfin

And it'll work
I have left this dump.
User avatar
Seb McClouth
Veteran
Posts: 342
Joined: Wed Nov 09, 2005 7:47 am
Location: Inside the Matrix...
Contact:

Post by Seb McClouth »

Thx Z!re... damn I could have thought of that myself...
QBinux is a Linux distribution with the aim of integrating the work of the vast community of free software developers at Pete's QBASIC Site in order to create a modern, performant, safe and easy to use system for system administrators and desktop users.
User avatar
Seb McClouth
Veteran
Posts: 342
Joined: Wed Nov 09, 2005 7:47 am
Location: Inside the Matrix...
Contact:

Post 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?
QBinux is a Linux distribution with the aim of integrating the work of the vast community of free software developers at Pete's QBASIC Site in order to create a modern, performant, safe and easy to use system for system administrators and desktop users.
User avatar
Seb McClouth
Veteran
Posts: 342
Joined: Wed Nov 09, 2005 7:47 am
Location: Inside the Matrix...
Contact:

Post by Seb McClouth »

mm.... nvm... it did work...
QBinux is a Linux distribution with the aim of integrating the work of the vast community of free software developers at Pete's QBASIC Site in order to create a modern, performant, safe and easy to use system for system administrators and desktop users.
Post Reply