home *** CD-ROM | disk | FTP | other *** search
- /*
-
- POLYTOPE OBJECT INCLUDE FILE v1.0b - vectorval include file
- Copyright (C) 1997 Thomas Willhalm
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-
- */
-
- /*
- Convert string to vector
-
- Usage:
- PRE: <string_vector> is string of a vector
- with no additional blanks
- POST: <float_vector> vector with contents of <string_vector>
- SIDE: <__cur_pos>, <__old_pos>, <__x>, <__y> altered
- */
-
- // checking
- #ifndef (string_vector)
- #error "string_vector undefined"
- #end
-
- #if (strcmp(substr(string_vector,1,1),"<"))
- #error "string_vector does not start with <"
- #end
-
- // find first comma
- #declare __cur_pos=1
- #while (strcmp(substr(string_vector,__cur_pos,1),","))
- #declare __cur_pos = __cur_pos+1
- #end
-
- // store first coordinate
- #declare __x = val(substr(string_vector,2,__cur_pos-2))
-
- // find second comma
- #declare __cur_pos = __cur_pos+1
- #declare __old_pos = __cur_pos
- #while (strcmp(substr(string_vector,__cur_pos,1),","))
- #declare __cur_pos = __cur_pos+1
- #end
-
- // store second coordinate
- #declare __y = val(substr(string_vector,__old_pos,__cur_pos-__old_pos))
-
- // find terminating >
- #declare __cur_pos = __cur_pos+1
- #declare __old_pos = __cur_pos
- #while (strcmp(substr(string_vector,__cur_pos,1),">"))
- #declare __cur_pos = __cur_pos+1
- #end
-
- // store result
- #declare float_vector = <__x,__y,val(substr(string_vector,__old_pos,__cur_pos-__old_pos))>
-