- Changed FOCUS to writing data files through nxscript

SKIPPED:
	psi/faverage.c
	psi/fowrite.c
	psi/psi.c
	psi/swmotor2.c
This commit is contained in:
cvs
2004-05-04 14:06:16 +00:00
parent fb15476a81
commit 0df15975dc
8 changed files with 458 additions and 14 deletions

View File

@@ -29,12 +29,6 @@
#include "udpquieck.h"
#include "nxdict.h"
#include "nxscript.h"
/*============== a personal data structure ============================*/
typedef struct {
pObjectDescriptor pDes;
NXhandle fileHandle;
NXdict dictHandle;
} NXScript, *pNXScript;
/*------------------------------------------------------------------------*/
char *makeFilename(SicsInterp *pSics, SConnection *pCon) {
pSicsVariable pPath = NULL, pPref = NULL, pEnd = NULL;
@@ -64,7 +58,7 @@ char *makeFilename(SicsInterp *pSics, SConnection *pCon) {
/* find length */
iLen = strlen(pPath->text) + 4; /* extra 4 for dir number */
iLen += strlen(pPref->text);
iLen += 9; /* for number + year */
iLen += 10; /* for number + year */
iLen += strlen(pEnd->text);
iLen += 10; /* safety margin */
@@ -109,7 +103,7 @@ char *makeFilename(SicsInterp *pSics, SConnection *pCon) {
sprintf(pNumText,"%4.4d",iYear);
strcat(pRes,pNumText);
strcat(pRes,"n");
sprintf(pNumText,"%5.5d",iNum);
sprintf(pNumText,"%6.6d",iNum);
strcat(pRes,pNumText);
strcat(pRes,pEnd->text);
@@ -721,7 +715,7 @@ static void putGlobal(SConnection *pCon, SicsInterp *pSics,
/*-----------------------------------------------------------------------*/
static int handlePut(SConnection *pCon, SicsInterp *pSics, pNXScript self,
int argc, char *argv[]){
int status;
int status, iVal;
char buffer[1024], defString[1024], numBuf[25];
double dVal;
float fVal;
@@ -749,6 +743,27 @@ static int handlePut(SConnection *pCon, SicsInterp *pSics, pNXScript self,
SCWrite(pCon,buffer,eError);
}
return 1;
} else if(strcmp(argv[1],"putint") == 0){
if(argc < 4){
SCWrite(pCon,"ERROR: insufficient number of arguments to putint",
eError);
return 1;
}
status = Tcl_GetInt(InterpGetTcl(pSics),argv[3],&iVal);
if(status != TCL_OK){
sprintf(buffer,"ERROR: failed to convert %s to int",
argv[3]);
SCWrite(pCon,buffer,eError);
return 1;
}
status = NXDputalias(self->fileHandle, self->dictHandle,
argv[2],&iVal);
if(status != NX_OK){
sprintf(buffer,"ERROR: failed to write %f to alias %s",
iVal, argv[2]);
SCWrite(pCon,buffer,eError);
}
return 1;
} else if (strcmp(argv[1],"puttext") == 0){
/*====================*/
if(argc < 4){