|
Show the code that adds to, and deletes from, the list.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Contents : -Data Structures used in Linked List
-Class namely 'DataType' having properties and methods to
create linked list
-the function in which linked list is created
//***************************************************************************************************
// Vector structure: This structure is used to emulate "Vectors" section of ABF file.
//**************************************************************************************************
typedef struct tag_VECTOR
{
char lpszVectorDescription[5] ; //1) Vector description as a variable length string.
char lpszVectorName[7] ; //2) Vector name as a variable length string.
char lpszEquation[5] ; //3) Equation as a variable length string. I read but ignore this value.
long int lNoOfPoints ; //4) Number of points in vector as a four-byte integer.
long int lNoOfBytes ; //5) Number of bytes in each point, either four or eight for single and double precision. The GM Safety Lab data uses single precision.
long int lBinaryFlag ; //6) Binary flag as four-byte integer, always set to one.
float lpDataValue[10000] ; //7) The four or eight byte binary, floating-point data values. The total number of bytes in this section is the product of the values read in four and five, above.
}VECTOR, *LPVECTOR;
//**************************************************************************************************************
//The request description is made up of the channel name, anomaly error (if any), channel description,
//channel number, units, filter, and file name. For example:
//aa001a, ANOMALY = Data Affected by Accelerometer Rotation, CTR FRT C/MBR ON SENSOR LONGITUDINAL ACCEL, G'S, Channel = 123, Units = G's, Filter = 1000, File = c12001a
//To model this sequence I am writing following structure
//**************************************************************************************************************
typedef struct tag_REQUEST_DESCRIPTION
{
char lpszChannelName[25] ; //1) Channel name and is assigned as Request name
char lpszAnomalyError[20] ; //2) Anaomaly Error if any.
char lpszChannelDescription[25] ; //3) Channel Description
char lpszChannelNumber[4] ; //4) Channel Number
char lpszUnits[15] ; //5) Channel units
char lpszFilter[10] ; //6) Filter
char lpszFileName[15] ; //7) FileName
}REQUEST_DESCRIPTION, *LPREQUEST_DESCRIPTION ;
//***************************************************************************************************
// Request Structure: This structure is used to emulates "Requests" section of ABF file.
//***************************************************************************************************
typedef struct tag_REQUEST
{
REQUEST_DESCRIPTION RequestDescription ; //1) Request description as a variable length string.
char lpszRequestName[35] ; //2) Request name as a variable length string.
char lpszRequestNameRe[35] ; //3) Request name, repeated, as a variable length string. I read but ignore this value.
char lpszTotalDescription[240] ; //4) Total description is string formed by concating all elements of "RequestDescription" element
tag_REQUEST *NextRequest ; //5) This points to next request of same data type. If no next request is available it is NULL
LPVECTOR lpVector ; //6) This points to vector
}REQUEST, *LPREQUEST;
//****************************************************************************************************
// Data Type Structure: This structure is used to emulate "Data Types" section of ABF file
//****************************************************************************************************
typedef struct tag_DATA_TYPE
{
char lpszDataTypeDescription[25] ; //1) Data Type description as a variable length string.
char lpszDataTypeName[25] ; //2) Data Type name as a variable length string.
long int lDefaultTimeDataType ; //3) Flag indicating if this is the one and only default time Data Type. This is a four-byte integer,1 = true, 0 = false. At most only one Data Type in each file may set this to true.
long int lNoOfRequests ; //4) Number of requests as a four-byte integer. This number denotes the number of channels, in given data set, of same data type
long int lNoOfComponents ; //5) Number of components as a four-byte integer.
tag_DATA_TYPE *NextDataType ; //6) This points to next data type.
LPREQUEST lpRequest ;
}DATA_TYPE,*LPDATA_TYPE ;
class DataType
{
private:
LPDATA_TYPE m_Node ; //This acts as a Base Node
public:
DataType();
~DataType();
void AppendDataType(LPDATA_TYPE) ; //adds a new node at the end of the linked list
void AddDataTypeatBeg(LPDATA_TYPE) ; //add a new node at the begining. this way the, after adding the first node becomes second node
void AddDataTypeAfter(LPDATA_TYPE, int Num) ; //add a new node after nth node(2nd argument)
LPDATA_TYPE FindDataType(LPDATA_TYPE) ; //find node with desired data type
LPDATA_TYPE GetDataType(int Num) ; //get the nth node
int GetTotalDataTypes() ; //get total number of data types available:this is equal to number of nodes in link list
LPDATA_TYPE GetNewDataType() ; //This creates a new pointer to DATA_TYPE structure on HEAP and returns the same
LPREQUEST GetNewRequest() ; //This creates a new pointer to REQUEST structure on HEAP and returns the same
LPVECTOR GetNewVector(int DataPoints, int NoOfBytes=4) ; //This creates a new pointer to VECTOR structure on HEAP and returns the same
void AppendRequest(LPREQUEST,LPDATA_TYPE) ; //Append request to the last request of data type given as second argument
};
DataType::DataType()
{
m_Node = NULL ;
}
//**************************************
// Destroy the link list objects
//**************************************
DataType::~DataType()
{
LPDATA_TYPE Tempdata; LPREQUEST TempRequest ; LPVECTOR TempVector;
if(m_Node==NULL)
return;
while(m_Node != NULL)
{
if(m_Node->NextDataType !=NULL)
{
TempRequest = m_Node->lpRequest ;
while(TempRequest != NULL)
{
LPREQUEST temprequest1 = TempRequest->NextRequest ;
//delete TempRequest->lpVector->lpDataValue ;
delete TempRequest ;
TempRequest = temprequest1 ;
}
Tempdata = m_Node->NextDataType ;
delete m_Node;
m_Node = Tempdata;
}
else //if there is only one link list object or if there are n nodes, then the above "if" condition deletes (n-1), for deleting last this else condition is written.
{
TempRequest = m_Node->lpRequest ;
while(TempRequest != NULL)
{
LPREQUEST temprequest1 = TempRequest->NextRequest ;
//delete TempRequest->lpVector->lpDataValue ;
delete TempRequest ;
TempRequest = temprequest1 ;
}
delete m_Node ;
m_Node = NULL ;
}
}
}
//******************************************
// Purpose: adds a new code of DATA_TYPE
//******************************************
void DataType::AppendDataType( LPDATA_TYPE NewNode)
{
LPDATA_TYPE Temp1, Temp2;
NewNode->lNoOfComponents =1;
NewNode->lNoOfRequests =1 ;
NewNode->lDefaultTimeDataType =0 ;
if(m_Node ==NULL) //If Base node in NULL.
{
//Create the First Base Node
m_Node = NewNode ;
m_Node->NextDataType = NULL;
}
else
{
//Go to the Last Node
Temp1 = m_Node ;
while(Temp1->NextDataType != NULL)
Temp1 = Temp1->NextDataType ;
//Add Node at the End
Temp2 = NewNode ;
Temp2->NextDataType = NULL;
Temp1->NextDataType = Temp2 ;
}
}
//************************************************************************************************
// This Function adds a NewRequest, passed as 1st argument, to the given DataType, 2nd argument.
//************************************************************************************************
void DataType::AppendRequest(LPREQUEST NewRequest,LPDATA_TYPE ToThisDataType)
{
LPDATA_TYPE TempDataType; LPREQUEST TempRequest ;
if(ToThisDataType->lpRequest == NULL) //If immediate pointer to request, an element of DataType, is NULL.
{
ToThisDataType->lpRequest = NewRequest ;
ToThisDataType->lpRequest->NextRequest = NULL ; //recent
}
else
{
TempRequest = ToThisDataType->lpRequest;
while(TempRequest->NextRequest != NULL ) // Move to last request
TempRequest = TempRequest->NextRequest ;
TempRequest->NextRequest = NewRequest ;
TempRequest->NextRequest->NextRequest = NULL ; //recent
}
}
//************************************************************
// This Functions makes passed argument as the Base node
//************************************************************
void DataType::AddDataTypeatBeg(LPDATA_TYPE NewNode)
{
LPDATA_TYPE Temp ;
//add new node
Temp = NewNode ;
Temp->NextDataType = m_Node ;
m_Node = Temp ;
}
//*************************************************************************************
// This Function adds new node of DATA_TYPE, after Num(2nd argument) no of nodes
//*************************************************************************************
void DataType::AddDataTypeAfter(LPDATA_TYPE NewNode, int Num)
{
LPDATA_TYPE Temp1, Temp2; int count ;
for(count=0,Temp1=m_Node;count < Num;count++)
{
Temp1 = Temp1->NextDataType ;
if(Temp1 == NULL)
return ;
}
//insert new node
Temp2 = NewNode ;
Temp2->NextDataType = Temp1->NextDataType ;
Temp1->NextDataType = Temp2;
}
//************************************************************************************
// This Function returns datatype node of nth num(which is passed as 2nd argument)
//************************************************************************************
LPDATA_TYPE DataType::GetDataType(int Num)
{
LPDATA_TYPE Temp ; int count ;
Temp=m_Node ;
if(Num==1)
return Temp ;
for(count=2;count <=Num;count++)
{
Temp = Temp->NextDataType ;
if(Temp == NULL)
return NULL;
}
if(Temp ==NULL)
return NULL;
else
return Temp;
}
//***************************************************************************************
// Purpose : Searches datatype node
// Searching Criteria : DataTypeName, which is an element of DATA_TYPE node.
// Return Value : If desired node of same Data Type name is found in Linked list,
// then the node passed as argument to this function is delete, as
// already DataType node of data Type Name exists, and the pointer
// to the available node is returned back.
// If no node is present, NULL is returned.
//***************************************************************************************
LPDATA_TYPE DataType::FindDataType(LPDATA_TYPE Node)
{
LPDATA_TYPE Temp = m_Node ; int count ;
while(Temp != NULL)
{
if(strcmp(Temp->lpszDataTypeName,Node->lpszDataTypeName)==0) //If you find a data type, delete new created data type object
{
delete Node ;
return Temp ;
}
Temp = Temp->NextDataType ;
}
return NULL ;
}
//*****************************************************************************************
// Purpose : Total number of data type nodes that are available in the Linked List
// Return Value: Total No of Data types
//*****************************************************************************************
int DataType::GetTotalDataTypes()
{
LPDATA_TYPE Temp = m_Node ; int Total=0;
while(Temp != NULL)
{
Temp = Temp->NextDataType ;
Total++;
}
return Total ;
}
//*************************************************************************
// Purpose : Function creates object of structure DATA_TYPE on Heap.
// Sets Request & NextdataType element of its as NULL.
// Return Value : Pointer to DATA_TYPE.
//*************************************************************************
LPDATA_TYPE DataType::GetNewDataType()
{
LPDATA_TYPE NewDataType ;
NewDataType = new DATA_TYPE ;
NewDataType->NextDataType = NULL ;
NewDataType->lpRequest = NULL ;
return NewDataType ;
}
//*************************************************************************
// Purpose : Function creates object of structure REQUEST on Heap.
// Sets NextRequest & Vector element of its as NULL.
// Return Value : Pointer to REQUEST.
//*************************************************************************
LPREQUEST DataType::GetNewRequest()
{
LPREQUEST NewRequest ;
NewRequest = new REQUEST ;
NewRequest->NextRequest = NULL;
NewRequest->lpVector = NULL ;
return NewRequest ;
}
//**************************************************************************************
// Purpose : Function creates object of structure VECTOR on Heap.
// Creates memory on heap for data points
// Parameters : 1st argument - denotes number of data points available in the channel
// : 2nd argument - denotes number of bytes for each data point.
// Return Value : Pointer to REQUEST.
//**************************************************************************************
LPVECTOR DataType::GetNewVector(int DataPoints,int NoOfBytes)
{
LPVECTOR NewVector ;
NewVector = new VECTOR ;
//NewVector->lpDataValue = new float[sizeof(DataPoints*NoOfBytes+5)];
return NewVector ;
}
Inside function body:
{
int StringLen ; //Used to get the lenght of any string and use it for any purpose such as allocationg memory of same lenght
float ActualValue ; //Used to store value retrived from channel
Units cUnit ; //
DataType *lpcDataType ; //To create Linked List
int TotalNoOfRequest=0 ; //Total requests irrespective of data type
int ChannelLen=0 ; //data Points in Channel
register int Index=1 ; //Used in For Loop , register storage class makes the processing faster
register int RowCount ; //Used in For Loop , register storage class makes the processing faster
TDataDouble dValueT ; // Local double variable
TDataChannelLenInfo DataChannelLenInfoT ; // Local length information for a data channel
//Set how many channels are there.
ABFFile.SetNoOfChannels(unsigned int (lChannelNos)) ; //This is neccessory to set the upper bound of array of datatypes, requests and vectors
// Request object channel length info for the first data channel using the property function
lDataObjProperties(lChannelNos,eChannelLenGet,sizeof(TDataChannelLenInfo),&DataChannelLenInfoT);
ABFFile.SetChannelLength((int)DataChannelLenInfoT.lLen) ;
//ABFFile.SetChannelLength((int)25) ;
ChannelLen = ABFFile.GetChannelLength() ;
if( ChannelLen <=0 )//If channel len <=0 return
{
MessageBox((HWND)hDIAdemWndGet(),"Invalid Channel Lenght/Data Points in channel","Invalid Data Points",MB_OK);
return ;
}
if (ChannelLen > 0) //VALIDATION NO 1:- this check will ensure that given channel number, as argument of this function contains data rows/data points. This instruction assumes that data for channels below channel number given as argument exists
{
lpcDataType = new DataType ;
FILE *pTxtFile ;
pTxtFile = fopen("ABFChnPro.txt","r");
if(pTxtFile == NULL)
{
MessageBox((HWND)hDIAdemWndGet(),"Failed to Open Text file ","Channel Properties File",MB_OK) ;
return ;
}
//details about data types
int k; int i=0; char data1[50], data2[50], data3[50], data4[50] ;
TDataObjHeader DataObjHeaderT ;
DataObjHeaderT.lSize = sizeof(TDataObjHeader) ;
//try
//{
k = fgetc(pTxtFile) ;
while('\n'!= (char)k)
{
LPDATA_TYPE TempDataType ; LPREQUEST TempRequest ; LPVECTOR TempVector ;
TempDataType = lpcDataType->GetNewDataType() ;
if(TempDataType == NULL)
{
MessageBox(NULL,"Enough memory is not available","Low memory",MB_OK);
return ;
}
TempRequest = lpcDataType->GetNewRequest();
if(TempRequest == NULL)
{
MessageBox(NULL,"Enough memory is not available","Low memory",MB_OK);
return ;
}
TempVector = lpcDataType->GetNewVector(ABFFile.GetChannelLength()) ;
if(TempVector == NULL || TempVector->lpDataValue == NULL)
{
MessageBox(NULL,"Enough memory is not available","Low memory",MB_OK);
return ;
}
i=0;
while('\n'!= (char)k) //This is name of channel
{
data1[i] = (char) k ;
i++;
k = fgetc(pTxtFile) ;
}
data1[i] = '\0' ;
i=0;
k = fgetc(pTxtFile) ;
while('\n'!= (char)k) //This is data type name
{
data2[i] = (char) k ;
i++;
k = fgetc(pTxtFile) ;
}
data2[i] = '\0' ;
strcpy(TempDataType->lpszDataTypeName,data2) ;
strcat(TempDataType->lpszDataTypeName,"\0");
i=0;
k = fgetc(pTxtFile) ;
while('\n'!= (char)k) //This is units of channel
{
data3[i] = (char) k ;
i++;
k = fgetc(pTxtFile) ;
}
data3[i] = '\0' ;
//request unit name ;
strcpy(TempRequest->RequestDescription.lpszUnits,data3); //aRequests[Index].RequestDescription.lpszUnits = new char[StringLen] ;
strcat(TempRequest->RequestDescription.lpszUnits,"\0") ; //strcpy(aRequests[Index].RequestDescription.lpszUnits,data3) ;
//data type description
strcpy(TempDataType->lpszDataTypeDescription,cUnit.GetDataDescription(data3)); //strcpy(aDataTypes[Index].lpszDataTypeDescription,cUnit.GetDataDescription(data3) ) ;
strcat(TempDataType->lpszDataTypeDescription,"\0");
strcpy(TempRequest->RequestDescription.lpszUnits,cUnit.GetDataDescription(data3));
strcat(TempRequest->RequestDescription.lpszUnits,"\0");
i=0;
k = fgetc(pTxtFile) ;
while('\n'!= (char)k) //This channel number
{
data4[i] = (char) k ;
i++;
k = fgetc(pTxtFile) ;
}
data4[i] = '\0' ;
strcpy(TempRequest->RequestDescription.lpszChannelNumber,data4) ;
strcat(TempRequest->RequestDescription.lpszChannelNumber,"\0") ;
k=(char )fgetc(pTxtFile) ;
k=(char )fgetc(pTxtFile) ;
nDataObjHeaderGet(Index,&DataObjHeaderT) ; //GPI SERVICE ROUTINE
//REQUEST NAME:-The request name is set to the channel name
strcpy(TempRequest->lpszRequestName,DataObjHeaderT.szName) ;
strcat(TempRequest->lpszRequestName,"\0") ;
strcpy(TempRequest->lpszRequestNameRe,DataObjHeaderT.szName) ;
strcat(TempRequest->lpszRequestNameRe,"\0") ;
strcpy(TempRequest->RequestDescription.lpszAnomalyError,"NA") ;
strcat(TempRequest->RequestDescription.lpszAnomalyError,"\0") ;
strcpy(TempRequest->RequestDescription.lpszChannelName,DataObjHeaderT.szName);
strcat(TempRequest->RequestDescription.lpszChannelName,"\0") ;
strcpy(TempRequest->RequestDescription.lpszChannelDescription,"NA");
strcat(TempRequest->RequestDescription.lpszChannelDescription,"\0");
strcpy(TempRequest->RequestDescription.lpszFileName,"NA");
strcat(TempRequest->RequestDescription.lpszFileName,"\0");
strcpy(TempRequest->RequestDescription.lpszFilter,"NA");
strcat(TempRequest->RequestDescription.lpszFilter,"\0");
if(TempRequest->RequestDescription.lpszChannelName != NULL)
{
strcpy(TempRequest->lpszTotalDescription,TempRequest->RequestDescription.lpszChannelName) ;
}
if(TempRequest->RequestDescription.lpszAnomalyError != NULL)
{ strcat(TempRequest->lpszTotalDescription,",") ;
strcat(TempRequest->lpszTotalDescription,"ANOMALY=");
strcat(TempRequest->lpszTotalDescription,TempRequest->RequestDescription.lpszAnomalyError );
}
else
{ strcat(TempRequest->lpszTotalDescription,",");
}
if(TempRequest->RequestDescription.lpszChannelDescription!=NULL )
{ strcat(TempRequest->lpszTotalDescription,",") ;
strcat(TempRequest->lpszTotalDescription,TempRequest->RequestDescription.lpszChannelDescription);
}
else
{ strcat(TempRequest->lpszTotalDescription,",");
}
if(TempRequest->RequestDescription.lpszChannelNumber !=NULL )
{ strcat(TempRequest->lpszTotalDescription,",");
strcat(TempRequest->lpszTotalDescription,"Channel=");
strcat(TempRequest->lpszTotalDescription,TempRequest->RequestDescription.lpszChannelNumber);
}
else
{ strcat(TempRequest->lpszTotalDescription,",");
}
if(TempRequest->RequestDescription.lpszUnits != NULL)
{ strcat(TempRequest->lpszTotalDescription,",");
strcat(TempRequest->lpszTotalDescription,"Units=");
strcat(TempRequest->lpszTotalDescription,TempRequest->RequestDescription.lpszUnits);
}
else
{ strcat(TempRequest->lpszTotalDescription,",");
}
if( TempRequest->RequestDescription.lpszFilter !=NULL)
{ strcat(TempRequest->lpszTotalDescription,",");
strcat(TempRequest->lpszTotalDescription,"Filter=");
strcat(TempRequest->lpszTotalDescription,TempRequest->RequestDescription.lpszFilter);
}
else
{ strcat(TempRequest->lpszTotalDescription,",");
}
if(TempRequest->RequestDescription.lpszFileName != NULL )
{ strcat(TempRequest->lpszTotalDescription,",");
strcat(TempRequest->lpszTotalDescription,"File=");
strcat(TempRequest->lpszTotalDescription,TempRequest->RequestDescription.lpszFileName );
}
else
{ strcat(TempRequest->lpszTotalDescription,",");
}
strcat(TempRequest->lpszTotalDescription,"\0");
//Vectors
for(RowCount=1 ; RowCount <=ChannelLen ; RowCount++)
{
lpdDataObjChannelValueGet(Index,RowCount,&dValueT) ;
ActualValue = (float)dValueT ;
TempVector->lpDataValue[RowCount-1] = ActualValue ;
}
strcpy(TempVector->lpszVectorDescription,"---") ; //1) Vector description as a variable length string.
strcat(TempVector->lpszVectorDescription,"\0") ;
strcpy(TempVector->lpszVectorName,"---") ; //2) Vector name as a variable length string.
strcat(TempVector->lpszVectorName,"\0") ;
strcpy(TempVector->lpszEquation ,"\0") ; //3) Equation as a variable length string. I read but ignore this value.
TempVector->lNoOfPoints = ABFFile.GetChannelLength() ; //4) Number of points in vector as a four-byte integer.
TempVector->lNoOfBytes = 4 ; //5) Number of bytes in each point, either four or eight for single and double precision. The GM Safety Lab data uses single precision.
TempVector->lBinaryFlag = 1 ; //6) Binary flag as four-byte integer, always set to one.
TempRequest->lpVector = TempVector ;
//process data type details
LPDATA_TYPE Temp1 ;
Temp1= lpcDataType->FindDataType(TempDataType) ;
if(Temp1==NULL) //If Data Type node do not exist
{
TempDataType->lpRequest = TempRequest ;
lpcDataType->AppendDataType(TempDataType) ;
TotalNoOfRequest++;
}
else //If data type node already exist
{
Temp1->lNoOfRequests++ ;
lpcDataType->AppendRequest(TempRequest,Temp1);
TotalNoOfRequest++; //This number denotes total requests ir-respective of data types
}
Index ++ ;
if(Index>lChannelNos)
{
fclose(pTxtFile) ;
break ;
}
}
//}
//catch(...)
//{
// MessageBox((HWND)hDIAdemWndGet(),"Error while porting channels","Error",MB_OK);
//}
//HeaderInfo info
TDataSet DataSetT ; //Local Data Set parameter data structure
char Filename[25] ;
DataSetT.lSize = sizeof(TDataSet) ;
nDataSetGet(&DataSetT) ; //Call service routine to get Data set properties
ABFFile.SetTitle((char *)DataSetT.szDataSetTitle) ; // Get Title of Data Set
ABFFile.SetDateOfTest((char *)DataSetT.szDataSetDate); // Get the Data of Data Set
//These values are set arbitrarily for time being
ABFFile.SetTypeOfTest("Car to Car, 50% Offset") ;
ABFFile.SetTypeOfSubtest("Sub-Car to Car, 50% Offset");
ABFFile.SetRegulation("NOVALUE") ;
ABFFile.SetLabName("Lab Example") ;
ABFFile.SetLabContactName("Mr. Safety") ;
ABFFile.SetLabContactEmail("lab@example.com") ;
ABFFile.SetLabContactPhone("0123-450") ;
ABFFile.SetDescription() ; // to concat title, dateof test....
//Datermine No of data types & requests
ABFFile.SetNoOfDataTypes((long)lpcDataType->GetTotalDataTypes()); //for time being
ABFFile.SetNoOfRequests((long)TotalNoOfRequest) ;
strcpy(Filename,DataSetT.szDataSetTitle) ;
strcat(Filename,".th") ;
if (! ABFFile.FileOpen(Filename,"wb") )
return ; //in case of failure
ABFFile.WriteHeader() ;
//write all parts
for(int DataTypeNo=1;DataTypeNo<= lpcDataType->GetTotalDataTypes() ; DataTypeNo++)
//for(int ChannelCount=1;ChannelCount<=lChannelNos;ChannelCount++) // Channel Loop
{
LPDATA_TYPE TempDataType ; LPREQUEST TempRequest ; LPVECTOR TempVector ;
TempDataType = lpcDataType->GetDataType(DataTypeNo) ;
//Write data type data
StringLen = strlen(TempDataType->lpszDataTypeDescription);
ABFFile.Write(&StringLen,1,2) ;
ABFFile.Write(TempDataType->lpszDataTypeDescription,1,strlen(TempDataType->lpszDataTypeDescription));
StringLen = strlen(TempDataType->lpszDataTypeName);
ABFFile.Write(&StringLen,1,2) ;
ABFFile.Write(TempDataType->lpszDataTypeName,1,strlen(TempDataType->lpszDataTypeName)) ;
ABFFile.Write(&TempDataType->lDefaultTimeDataType,1,4);
ABFFile.Write(&TempDataType->lNoOfRequests,1,4);
ABFFile.Write(&TempDataType->lNoOfComponents,1,4 );
TempRequest = TempDataType->lpRequest ;
while(TempRequest !=NULL)
{
//write Request data
StringLen = strlen(TempRequest->lpszTotalDescription);
ABFFile.Write(&StringLen,1,2);
ABFFile.Write(TempRequest->lpszTotalDescription ,1,(unsigned int)StringLen);
//ABFFile.Write("\n",1,1);
StringLen = strlen(TempRequest->lpszRequestName);
ABFFile.Write(&StringLen,1,2);
ABFFile.Write(TempRequest->lpszRequestName,1,(unsigned int)StringLen) ;
//ABFFile.Write(",",1,1);
//ABFFile.Write("\n",1,1);
StringLen = strlen(TempRequest->lpszRequestNameRe);
ABFFile.Write(&StringLen,1,2);
ABFFile.Write(TempRequest->lpszRequestNameRe,1,(unsigned int)StringLen) ;
//ABFFile.Write(",",1,1);
//ABFFile.Write("\n",1,1);
TempVector = TempRequest->lpVector ;
//write vector details
StringLen =strlen(TempVector->lpszVectorDescription) ;
ABFFile.Write(&StringLen,1,2);
ABFFile.Write(TempVector->lpszVectorDescription,1,3);
StringLen = strlen(TempVector->lpszVectorName);
ABFFile.Write(&StringLen,1,2);
ABFFile.Write(TempVector->lpszVectorName,1,3);
StringLen =strlen(TempVector->lpszEquation) ;
ABFFile.Write(&StringLen,1,2);
ABFFile.Write(TempVector->lpszEquation,1,StringLen);
StringLen =TempVector->lNoOfPoints ;
ABFFile.Write(&StringLen,1,4);
StringLen = TempVector->lNoOfBytes ;
ABFFile.Write(&StringLen,1,4);
StringLen = TempVector->lBinaryFlag ;
ABFFile.Write(&StringLen,1,4);
StringLen = TempVector->lNoOfBytes * TempVector->lNoOfPoints ;
ABFFile.Write(TempVector->lpDataValue,1,StringLen);
TempRequest = TempRequest->NextRequest ;
}
}
//MessageBox((HWND)hDIAdemWndGet(),"End Of Porting Channels","End",MB_OK) ;
ABFFile.FileClose() ;
delete lpcDataType ;
}
else
{
MessageBox((HWND)hDIAdemWndGet(),"The Channels do not contain data, Conversion to ABF will be stopped!!!","Abort",MB_OK) ;
}
return ;
}
|
|
|
|
|
Amol Ravatale wrote: strcat(TempVector->lpszVectorName,"\0") ;
What are you expecting this to do? These type of statements can be removed as they do nothing.
There's too much code here to wade through. Have you tried scaling the problem down to something more manageable? A few dozen lines of code is all you'd need to make a linked list that can easily be debugged. After you are certain that you can add to, and delete from, the simplest of lists, only then should you add all of the other code.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Friends,
How can we display "line numbers" in the editor of Visual C++ 6.0 IDE?
In case of VS.NET, the line numbers can be invoked from:
Tools->Options->Text Editor->C/C++->Line numbers
Is it possible with Visual C++ 6.0 ? If yes, then how ? Also please tell me about the "shortcut keys" to display line numbers in case of both Visual C++ 6.0 and Visual C++.NET+
Ahsan
|
|
|
|
|
Ahsan Askare wrote: How can we display "line numbers" in the editor of Visual C++ 6.0 IDE?
Look in the lower, right corner of the IDE. You will see line and column number.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
hmm.. sorry, i think you didn't get the question.
I am not talking about the line number displayed on the lower right corner of IDE along with column number. I want to display each line number in the source code editor of the IDE.
In case of VS.NET, this option can be invoked from:
Tools->Options->Text Editor->C/C++->Line numbers
Just like to know whether it is possible with VC++ 6.0
Ahsan
|
|
|
|
|
Ahsan Askare wrote: I want to display each line number in the source code editor of the IDE.
Maybe it's a language barrier thing, but the line numbers I mentioned are shown in the editor. They are, however, not on the left of the code which I think is what you are after.
Ahsan Askare wrote: Just like to know whether it is possible with VC++ 6.0
This functionality does not exist with VC++ v6.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
|
From MSDN:
When specifying an explicit RGB color, the COLORREF value has the following hexadecimal form:
<code>0x00bbggrr </code>
The low-order byte contains a value for the relative intensity of red; the second byte contains a value for green;
and the third byte contains a value for blue. The high-order byte must be zero. The maximum value for a single byte is 0xFF.
So just use masks to retrieve the colors:
COLORREF Color = ....;<br />
int BlueValue = Color&0x00FF0000;<br />
int GreenValue = Color&0x0000FF00;<br />
int RedValue = Color&0x000000FF;<br />
<br />
|
|
|
|
|
or use the GetRValue , GetGValue , GetBValue functions.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
True, because I just realized my version was completely bugged . It works well for the red component but for this other ones, the bits needs to be shifted...
|
|
|
|
|
Cedric Moonen wrote: True, because I just realized my version was completely bugged
yeah, you forgot the shifts...
int BlueValue = Color&0x00FF0000 >> 16;
int GreenValue = Color&0x0000FF00 >> 8;
int RedValue = Color&0x000000FF;
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20]
|
|
|
|
|
oki, but how can I use the GetRValue, GetGValue, GetBValue functions to display the colorref value in a messagebox or an editbox? an example code?
thanks alot
|
|
|
|
|
Just use printf:
char szText[255];<br />
printf(szText,"Red value: %i, Blue value: %i, Green value: %i",GetRValue(...),GetBValue(...),GetGValue(...));
Of course, you have to replace the ... by your COLORREF variable
|
|
|
|
|
|
For the first one, just use COLORREF GetColour(); from the control.
Dude, when you use classes from an article here, first read how to use it (and there is also example source code with the article). If we don't use this control, we don't know how to use. It just took me 30 seconds looking at the text of the article to find how to use it.
|
|
|
|
|
don't call me a dude, and I read before I ask, and if it is bothering you then don't answer at all, I don't need your answer, got it dude?
|
|
|
|
|
hi!
Noone answerd my question last time so ill try again:
I have a problem with my directsound application.Every time i play my sound and if there is another application playing(e.g windows media player) i get corupted sound.My cooperative level is DSSCL_PRIORITY. I also have problem when trying to create DirecSound object with CoCreateInstance metod(always fails).
If anyone has some experience with this problem or if you can direct me to some good article i would be very grateful
Many thanks!
|
|
|
|
|
I have service application which has to launch an application in the context of the current interactive user. If there is not interactive user, then the application will not be started.
I tried using CreateProcessAsUser, but then I need to have a token to that user's session. How do I get that?
Thanks!
|
|
|
|
|
Hi,
Try LogOnUser function to get the token.
Bye,
Cool Ju
Dream Ur Destiny
|
|
|
|
|
Cool Ju wrote: Try LogOnUser function to get the token
I need to run my app on the same session as the current interactive session. LogonUser will create a different session. Furthermore, how do I get to know the username, etc.....
I want to achieve something of the sort that DCOM does. For DCOM servers, we have the option to specify to launch it in the interactive user's session. Similar kind of thing is what I am looking for...
|
|
|
|
|
I need to add some files from the
other directory then my existing project
directory .
The files are header files and are located
on diffent drive.
Insted of changing all the path can i give
a path in Project>Setting , ???
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Yep, sure. Depends on which IDE you use. For 2005, you go in the project properties -> c/c++ -> general -> additional include directories. It is almost the same for VC6 (except that is not displayed the same way).
|
|
|
|
|
In VC6, you will find it here:
Goto Project->Settings->C/C++->Preprocessor.
Put them in "Additional include directories:"
If you want more than one, separate the with commas.
|
|
|
|
|
Hi All,
This is my second post regarding the problem.i haven't got its solution yet.
I am using access automation. Please Guide How can I Get number of tables & names in a database using access automation?
I just want to figure out number of tables & table names in an access database.is it possible using access automation.How?
i don't know if it is possible using database connectivity since i don't intend to do anything with data or data fields in the tables.
I am using vc++ 6.0,access-2000.
Please Help!!
Regards,
Ankush Mehta
Ankush Mehta
|
|
|
|
|