The QMIns() function inserts a field, value or subvalue in a dynamic array. It is analogous to the QMBasic INSERT() function.
The function arguments are:
|Src||is the dynamic array to be processed|
|Fno||is the number of the field to be inserted. If less than 1, 1 is assumed.|
|Vno||is the number of the value to be inserted. If less than 1, an entire field is inserted.|
|Svno||is the number of the subvalue to be inserted. If less than 1, an entire value is inserted.|
|NewData||is the new data to form the new dynamic array element.|
The QMIns() function returns a new dynamic array with the specified field, value or subvalue inserted.
This function is evaluated on the client system and does not require a server connection to be open.
The examples below read a record with an update lock, use QMIns() to modify it and then write it back to the file. A real program should test the error status from the read operation to determine if it was successful.
char * QMIns(char * Src, int Fno, int Vno, int Svno, char * NewData)
Rec = QMReadu(fClients, ClientNo, TRUE, Err);
Rec2 = QMIns(Rec, 1, Pos, 0, NewData);
QMWrite(fClients, ClientNo, Rec2);
Note that the function returns a pointer to a newly allocated memory area which must be released using QMFree() when no longer needed. A statement such as
Rec = QMIns(Rec, 1, Pos, 0, NewData);
will overwrite the Rec pointer without releasing the previously allocated memory.
QMIns(ByVal Src as String, ByVal Fno as Integer, ByVal Vno as Integer, ByVal Svno as Integer, ByVal NewData as String) as String
Rec = QMReadu(fClients, ClientNo, True, Err)
Rec = QMIns(Rec, 1, Pos, 0, NewData)
QMWrite fClients, ClientNo, Rec
This function is not supported by the QMClient class module as it is a QMBasic function.
String Ins(String Src, int Fno, int Vno, int Svno, String NewData)
Rec = qm.Readu(fClients, ClientNo, true);
Rec2 = qm.Ins(Rec, 1, Pos, 0, NewData);
qm.Write(fClients, ClientNo, Rec2);
Ins(Src, Fno, Vno, Svno, NewData)
Rec, Err = qm.Readu(fClients, ClientNo, true)
Rec2 = qm.Ins(Rec, 1, Pos, 0, NewData)
qm.Write(fClients, ClientNo, Rec2)