- Switched to NAPI-3.0 with XML support
- Fixed exeman to write files by default into the first directory in batchpath - Fixed a bug in nxdict which prevented it from handling attributes containing :/ properly - Removed junk files - Fixed a bug in hklscan.c which made it dump core - Added XML support to nxscript.c - Added support for writing NeXus-XML data files to tasub
This commit is contained in:
90
nxscript.c
90
nxscript.c
@@ -159,6 +159,8 @@ static int handleFileOperations(SConnection *pCon, pNXScript self,
|
||||
} else if(strcmp(argv[1],"create5") == 0){
|
||||
access = NXACC_CREATE5;
|
||||
unlink(argv[2]); /* kill file for overwrite */
|
||||
} else if(strcmp(argv[1],"createxml") == 0){
|
||||
access = NXACC_CREATEXML;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@@ -727,6 +729,91 @@ static void putArray(SConnection *pCon, SicsInterp *pSics,
|
||||
SCSendOK(pCon);
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static void putIntArray(SConnection *pCon, SicsInterp *pSics,
|
||||
pNXScript self,
|
||||
int argc, char *argv[]){
|
||||
int *data = NULL;
|
||||
int length, i, status;
|
||||
char num[20];
|
||||
char buffer[256], defString[512], *varData;
|
||||
Tcl_Interp *tcl = NULL;
|
||||
int iVal;
|
||||
|
||||
if(argc < 5){
|
||||
SCWrite(pCon,"ERROR: insufficient number of arguments to array",
|
||||
eError);
|
||||
return;
|
||||
}
|
||||
tcl = InterpGetTcl(pSics);
|
||||
assert(tcl != NULL);
|
||||
|
||||
/*
|
||||
get array length
|
||||
*/
|
||||
status = Tcl_GetInt(tcl,argv[4],&length);
|
||||
if(status != TCL_OK){
|
||||
sprintf(buffer,"ERROR: failed to convert %s to integer",argv[4]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
allocate
|
||||
*/
|
||||
if(length > 0){
|
||||
data = (int *)malloc(length*sizeof(int));
|
||||
}
|
||||
if(data == NULL){
|
||||
SCWrite(pCon,"ERROR: out of memory or invalid length",eError);
|
||||
return;
|
||||
}
|
||||
memset(data,0,length*sizeof(int));
|
||||
|
||||
/*
|
||||
try getting data
|
||||
*/
|
||||
for(i = 0; i < length; i++){
|
||||
sprintf(num,"%d",i);
|
||||
varData = (char *)Tcl_GetVar2(tcl,argv[3],num,0);
|
||||
if(varData != NULL){
|
||||
status = Tcl_GetInt(tcl,varData,&iVal);
|
||||
if(status != TCL_OK){
|
||||
sprintf(buffer,"ERROR: failed to convert %s to int",
|
||||
varData);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
}
|
||||
data[i] = iVal;
|
||||
} else {
|
||||
snprintf(buffer,254,"WARNING: failed to find array element %d", i);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
build definition string
|
||||
*/
|
||||
status = NXDdefget(self->dictHandle,argv[2],buffer,254);
|
||||
if(!status){
|
||||
sprintf(buffer,"ERROR: alias %s for array not found",
|
||||
argv[2]);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
free(data);
|
||||
return;
|
||||
}
|
||||
snprintf(defString,511,"%s -dim {%d} ",buffer,length);
|
||||
|
||||
/*
|
||||
write it!
|
||||
*/
|
||||
status = NXDputdef(self->fileHandle,self->dictHandle,defString,data);
|
||||
if(status != NX_OK){
|
||||
sprintf(buffer,"ERROR: failed to write array");
|
||||
SCWrite(pCon,buffer,eError);
|
||||
}
|
||||
free(data);
|
||||
SCSendOK(pCon);
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static void putGlobal(SConnection *pCon, SicsInterp *pSics,
|
||||
pNXScript self,
|
||||
int argc, char *argv[]){
|
||||
@@ -851,6 +938,9 @@ static int handlePut(SConnection *pCon, SicsInterp *pSics, pNXScript self,
|
||||
}else if(strcmp(argv[1],"putarray") == 0){
|
||||
/*================*/
|
||||
putArray(pCon,pSics,self,argc,argv);
|
||||
}else if(strcmp(argv[1],"putintarray") == 0){
|
||||
/*================*/
|
||||
putIntArray(pCon,pSics,self,argc,argv);
|
||||
}else if(strcmp(argv[1],"putglobal") == 0){
|
||||
/*===============*/
|
||||
putGlobal(pCon,pSics,self,argc,argv);
|
||||
|
||||
Reference in New Issue
Block a user