POV-Ray : Newsgroups : povray.advanced-users : Sub routines : Re: Sub routines Server Time
29 Jul 2024 06:26:31 EDT (-0400)
  Re: Sub routines  
From: ABX
Date: 25 Nov 2002 03:14:37
Message: <8sk3uu0ms8u923ji54bqaucfkoo04392ae@4ax.com>
On Sun, 24 Nov 2002 14:40:58 GMT, mca### [at] aolcomcom (Stephen McAvoy) wrote:
> In Basic I would use a "goto" or "gosub" statement...

 BASIC                      |   SDL
 ---------------------------|--------------------------------------
 10 INPUT P                 |   #declare P=Input();
 20 IF P="A" GOTO NOT_C     |   #if(ctrcmp(P,"A")<>0)
 30 INPUT C                 |     #declare C=Input();
 40 IF C="N" GOTO NOT_Z     |     #if(ctrcmp(P,"N")<>0)
 50 INPUT Z                 |       #declare Z=Input();
 60 PRINT Z                 |       #debug Z
 70 LABEL NOT_Z             |     #end
 80 PRINT C                 |     #debug C
 90 LABEL NOT_C             |   #end
100 PRINT P                 |   #debug P
 ---------------------------|--------------------------------------
                            |
                            |   #macro Print_A()
                            |     #debug "A was input"
                            |   #end
                            |
 10 INPUT P                 |   #declare P=Input();
 20 IF P="A" GOSUB PRINT_A  |   #if(ctrcmp(P,"A")0) Print_A() #end
 30 PRINT "Happy End"       |   #debug "Happy End"
 40 EXIT                    |
 50 LABEL PRINT_A           |
 60 PRINT "A was input"     |
 70 RETURN                  |
                            |

Note 1: Input() is some macro to get value from somewhere. Just wrapper for 
        some abstract operation.
Note 2: strcmp() is macro to compare strings, check documentation for details
Note 3: If you do not know how to replace "goto" with conditions or something
        then you really should ask in newuser group. You can be master in 
        texturing and very experienced in modelling, but as long as you are 
        asking for things not explored earlier you should really ask there. 
        That's not shame. Other advanced users usually reads both groups.
        It can result in some order of knowledge. Some other newusers would
        faster find answer reading that group.
Note 4: Sorry if my Basic or SDL is not accurate in some place but I mostly
        use C recently

ABX


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.