hi all,
i want to no what is the use of the following Lines
==========================
1.RC = OSPathNetConstruct (0, svrname, dbname, retPathName)
2.RC = NSFDBOpen(retPathName, hDb)
3.If hDb = 0 Then
-
chgRepID = False
-
Exit Function
6.End If
7.RC = W32_NSFDBReplicaInfoGet(hDb, ReplicaInfo)
8.Call W32_OSCurrentTimeDate(ReplicaID)
9.ReplicaInfo.ID = ReplicaID
10.RC = W32_NSFDBReplicaInfoSet(hDb, ReplicaInfo)
11.RC = NSFDBClose(hDb)
can any body xplain 7, 10, 11,
i am expressing my view
W32_NSFDBReplicaInfoGet taking two input parameter. and getting calculated, and getting stored at RC. next a function call.then again W32_NSFDBReplicaInfoSet is called and result getting stord at RC. Now if this values is replaced then what is the need of storing a value in the Line 7. similar for 11.
pls explain.
Subject: C - API
RC is being used to store the status return of the API calls – the value of RC isn’t particularly useful except for error checking. API returns are gathered through “out” variables passed as arguments. “hDb”, for instance, is a database handle that is assigned when NSFDBOpen is called. It has a value of 0 when it is fed in, and after the function runs it should have a valid database handle value.
Please – if you are going to be maintaining LS code that calls the C API, get Normunds Kalnberzins’ book. It will explain a lot.
Subject: C - API
You aren’t correct in Your assumption that the value is stored back in the variable “RC”. The RC-variable is only used for return codes/values that indicates error or success of the function. A returncode of 0 usually means that the function executed without errors (i.e. = Success).
The actual value that You should work with is stored in the functions argument-varaibles, in Your case “ReplicaInfo”. This is because the arguments are passed ByRef and not ByVal.
You have already provided an example of this in Your code: Take a look at line #9. There You are working with the result that were passed back in the ReplicaInfo variable/argument at line #7.
You should provide some errorhandling here, because if the returncode is indicating that the function at line #7 isn’t completed successfully then You shouldn’t execute the lines 8, 9, and 10.
Take a good long look into the API reference guide (found here at LDD - “Technical Library”) for all the explanation of the returncodes for each function.
hth