#include #include #include #ifdef PYCONSOLE #include #endif char console_more=0; char console_error[255] = ""; int file_script = 0; //takes a a string and compares it to element names, and puts it value into element. int console_parse_type(char *txt, int *element, char *err) { int i = -1; // alternative names for some elements if (strcasecmp(txt,"C4")==0) i = PT_PLEX; else if (strcasecmp(txt,"C5")==0) i = PT_C5; else if (strcasecmp(txt,"NONE")==0) i = PT_NONE; if (i>=0 && i=XRES || ny<0 || ny>=YRES) { if (err) strcpy(err,"Invalid coordinates"); return 0; } *x = nx; *y = ny; return 1; } //takes a string of either coords or a particle number, and puts the particle number into *which int console_parse_partref(char *txt, int *which, char *err) { int i = -1, nx, ny; if (err) strcpy(err,""); if (strchr(txt,',') && console_parse_coords(txt, &nx, &ny, err)) { i = pmap[ny][nx]; if (!i || (i>>8)>=NPART) i = -1; else i = i>>8; } else if (txt) { char *num = (char*)malloc(strlen(txt)+3); i = atoi(txt); sprintf(num,"%d",i); if (!txt || strcmp(txt,num)!=0) i = -1; free(num); } if (i>=0 && i