I have a created a function that is behaving inconsistently, seems like some type of race condition.
I am parsing script in a function and sending back a string. Sometime the strng is being received, sometimes it receives a zero. I have used WrileLn to try to analyze this. The function is being called 9 times in a row, no delay between calls. Seven lines come back correctly, but two always come back with a zero. The problem is repeatable and is always zero for the same result, not the nth return.
Here is edited otuput showing good and bad lines using WriteLn:
Quote:(Good)
1. vEnvValueString SESAME_REPORT_PATH=C:\Windows\Temp had vPos value of 19
3. vPos = not zero4. Sending vEnvValueString = C:\Windows\Temp
5. Received C:\Windows\Temp
(Bad)
1. vEnvValueString BAD-BAD-BAD had vPos value of 0
2. vPos = zero
4. Sending vEnvValueString = Environment variable SESAME_ROOTDIRS_PATH not found
5. Received 0
(Good)
1. vEnvValueString BAD-BAD-BAD had vPos value of 0
2. vPos = zero
4. Sending vEnvValueString = Environment variable SESAME_PRINT_COMMAND not found
5. Received Environment variable SESAME_PRINT_COMMAND not found
(Bad)
1. vEnvValueString BAD-BAD-BAD had vPos value of 0
2. vPos = zero
4. Sending vEnvValueString = Environment variable SESAME_PRINT_PREVIEW_COMMAND not found
5. Received 0
Lines 1-4 are from function code. Line 5 is from program calling the function.
If Line 1 =0, should go to Line2. This works OK
If Line1 <>0 should go to Line3. This works OK
Line 4 is the value of the function being sent back to the calling program (last line in function code)
Line 4 is the function value being received by the function. (immediately after running function in mass update code)
Note that in the first group, the line "4....." did not start on a new line, symptom of race condition?.
This is a Mass Update that is being done.
The function is in the Global Code section of the MUD program. It is in the Global Code of Main program, but I found that the Mass Update could not call the function from the Main Global Code. So I copied the code from the Main Program into the Mass Update Global Code section. Hmmmm, perhaps that is the problem, cannot normally use Global Code for Mass Updates, perhaps I need to put the function before the Mass Update code..... I will try that next......