void ausfuehren_foreach(BBForEach& f) { int x, y; y = f.M->M->yanz; x = f.M->M->xanz; if (f.type == BBForEach::Point) { // foreach p in M do for (f.P->v.y=0; f.P->v.y<y; (f.P->v.y)++) { if( g_Set_Progress(f.P->v.y, y) == false ) { throw BBFehlerUserbreak("User Break"); } for (f.P->v.x=0; f.P->v.x<x; (f.P->v.x)++) { // P setzen //f.P->v.x = j; //f.P->v.y = i; // Anweisungen ausführen ausfuehren_anweisung(f.z); } } } else { // foreachn n of p in M do for (int i=-1; i<=1; i++) { for (int j=-1; j<=1; j++) { if (i != 0 || j != 0) { int vx, vy; vx = j+f.P->v.x; vy = i+f.P->v.y; if (vx < 0 || vx >= f.M->M->xanz || vy < 0 || vy >= f.M->M->yanz) continue; // n setzen f.N->v.x = vx; f.N->v.y = vy; // Anweisungen ausführen ausfuehren_anweisung(f.z); } } } } }
void ausfueren_bedingung(BBIf& b) { if (auswert_bedingung(b.b)) { ausfuehren_anweisung(b.z); } else { if (b.isElse) ausfuehren_anweisung(b.zelse); } }
//--------------------------------------------------------- bool CBSL_Interpreter::On_Execute(void) { //----------------------------------------------------- Parameters("OUTPUT")->asGridList()->Del_Items(); g_bProgress = Parameters("PROGRESS")->asBool(); if( m_bFile ) { CSG_File Stream; if( !Stream.Open(Parameters("BSL")->asString(), SG_FILE_R, false) ) { return( false ); } Stream.Read(m_BSL, Stream.Length()); } else { m_BSL = Parameters("BSL")->asString(); } //----------------------------------------------------- if( !Parse_Vars(false) ) { return( false ); } //----------------------------------------------------- CSG_Parameters Input(this, _TL("Input"), _TL(""), SG_T("INPUT"), true); FindMemoryGrids(); for(T_InputText::iterator it=InputGrids.begin(); it!=InputGrids.end(); it++) { CSG_String sName(it->c_str()); Input.Add_Grid(NULL, sName, sName, _TL(""), PARAMETER_INPUT, true); } DeleteVarList(); DeleteAnweisungList(AnweisungList); if( Dlg_Parameters(&Input, _TL("Input")) == false ) { return( false ); } //----------------------------------------------------- if( !Parse_Vars(true) ) { return( false ); } //----------------------------------------------------- g_pInterpreter = this; if( GetMemoryGrids(&Input) ) { try { ausfuehren_anweisung(AnweisungList); } catch(BBFehlerAusfuehren x) { if( x.Text == "" ) Message_Add(_TL("unknown error: execution")); else Message_Add(CSG_String::Format(SG_T("error: %s\n"), CSG_String(x.Text.c_str()).c_str())); } catch(BBFehlerUserbreak x) { if( x.Text == "" ) Message_Add(_TL("unknown error: user break")); else Message_Add(CSG_String::Format(SG_T("error: %s\n"), CSG_String(x.Text.c_str()).c_str())); } } g_pInterpreter = NULL; DeleteVarList(); DeleteAnweisungList(AnweisungList); return( true ); }