G:/ScriptBasic/source/commands/goto.c

Go to the documentation of this file.
00001 /*goto.c
00002 
00003 --GNU LGPL
00004 This library is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU Lesser General Public
00006 License as published by the Free Software Foundation; either
00007 version 2.1 of the License, or (at your option) any later version.
00008 
00009 This library is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 Lesser General Public License for more details.
00013 
00014 You should have received a copy of the GNU Lesser General Public
00015 License along with this library; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 */
00019 
00020 #include <stdlib.h>
00021 #include <stdio.h>
00022 
00023 #include "../command.h"
00024 
00035 COMMAND(GOTO)
00036 #if NOTIMP_GOTO
00037 NOTIMPLEMENTED;
00038 #else
00039 
00040 
00041   SETPROGRAMCOUNTER(PARAMETERNODE);
00042 
00043 #endif
00044 END
00045 
00054 COMMAND(RESUMELABEL)
00055 #if NOTIMP_RESUMELABEL
00056 NOTIMPLEMENTED;
00057 #else
00058 
00059 
00060   SETPROGRAMCOUNTER(PARAMETERNODE);
00061   pEo->LastError = 0;
00062   pEo->ErrorGoto = 0;
00063   pEo->fErrorGoto = 0;
00064 
00065 #endif
00066 END
00077 COMMAND(ONERRORRESUMELABEL)
00078 #if NOTIMP_ONERRORRESUMELABEL
00079 NOTIMPLEMENTED;
00080 #else
00081 
00082 
00083   pEo->ErrorGoto = PARAMETERNODE;
00084   pEo->fErrorGoto = ONERROR_RESUME;
00085 
00086 #endif
00087 END
00088 
00096 COMMAND(ONERRORGOTONULL)
00097 #if NOTIMP_ONERRORGOTONULL
00098 NOTIMPLEMENTED;
00099 #else
00100 
00101 
00102   pEo->ErrorGoto = 0;
00103   pEo->fErrorGoto = 0;
00104 
00105 #endif
00106 END
00107 
00108 COMMAND(ONERRORGOTO)
00109 #if NOTIMP_ONERRORGOTO
00110 NOTIMPLEMENTED;
00111 #else
00112 
00113 
00114   pEo->ErrorGoto = PARAMETERNODE;
00115   pEo->fErrorGoto = ONERROR_GOTO;
00116 
00117 #endif
00118 END
00119 
00120 COMMAND(RESUME)
00121 #if NOTIMP_RESUME
00122 NOTIMPLEMENTED;
00123 #else
00124 
00125 
00126   pEo->LastError = 0;
00127   if( !pEo->ErrorResume )ERROR(COMMAND_ERROR_NO_RESUME);
00128   SETPROGRAMCOUNTER(pEo->ErrorResume);
00129 
00130 #endif
00131 END
00132 
00133 COMMAND(ONERRORRESUMENEXT)
00134 #if NOTIMP_ONERRORRESUMENEXT
00135 NOTIMPLEMENTED;
00136 #else
00137 
00138 
00139   pEo->fErrorGoto = ONERROR_RESUMENEXT;
00140 
00141 #endif
00142 END
00143 
00144 COMMAND(RESUMENEXT)
00145 #if NOTIMP_RESUMENEXT
00146 NOTIMPLEMENTED;
00147 #else
00148 
00149 
00150   pEo->LastError = 0;
00151   if( ! pEo->ErrorResume )ERROR(COMMAND_ERROR_NO_RESUME);
00152   SETPROGRAMCOUNTER( CDR(pEo->ErrorResume) );
00153 
00154 #endif
00155 END
00156 
00164 COMMAND(STOP)
00165 #if NOTIMP_STOP
00166 NOTIMPLEMENTED;
00167 #else
00168 
00169   pEo->fStop = fStopSTOP;
00170 
00171 #endif
00172 END
00173 
00181 COMMAND(END)
00182 #if NOTIMP_END
00183 NOTIMPLEMENTED;
00184 #else
00185 
00186   pEo->fStop = fStopSTOP;
00187 
00188 #endif
00189 END
00190 
00205 COMMAND(ERROR)
00206 #if NOTIMP_ERROR
00207 NOTIMPLEMENTED;
00208 #else
00209 
00210 
00211   RESULT = NEWMORTALLONG;
00212 /*  ASSERTNULL(RESULT) we already raise an error */
00213   if( RESULT ){
00214     LONGVALUE(RESULT) = pEo->LastError;
00215     }
00216 
00217 #endif
00218 END
00219 
00228 COMMAND(ERRORDOLLAR)
00229 #if NOTIMP_ERRORDOLLAR
00230 NOTIMPLEMENTED;
00231 #else
00232   VARIABLE vErrCode;
00233   long lErrCode;
00234 
00235   USE_CALLER_MORTALS;
00236 
00237   vErrCode = NULL;
00238   if( CAR(PARAMETERLIST) ){
00239     vErrCode = _EVALUATEEXPRESSION(CAR(PARAMETERLIST));
00240     ASSERTOKE;
00241     }
00242   if( vErrCode == NULL ){
00243     lErrCode = pEo->LastError;
00244     }else lErrCode = GETLONGVALUE(vErrCode);
00245 
00246   if( lErrCode < 0 || lErrCode >= MAX_ERROR_CODE ){
00247     RESULT = NULL;
00248     RETURN;
00249     }
00250 
00251   RESULT = NEWMORTALSTRING(strlen(en_error_messages[lErrCode]));
00252   ASSERTNULL(RESULT)
00253   memcpy(STRINGVALUE(RESULT),en_error_messages[lErrCode],STRLEN(RESULT));
00254 
00255 #endif
00256 END
00257 
00258 COMMAND(CERROR)
00259 #if NOTIMP_CERROR
00260 NOTIMPLEMENTED;
00261 #else
00262 
00263 
00264   ERROR(pEo->LastError=LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE))));
00265   /* this is a bit weird, but it can happen that the user wants to create an error and
00266      an error happens while the expression following the keyword ERROR is evaluated */
00267   ASSERTOKE;
00268 
00269 #endif
00270 END

Generated on Sun Mar 12 23:56:26 2006 for ScriptBasic by  doxygen 1.4.6-NO