Although I can't see anything wrong with that code, I did note that your original dialog has 8 PID locations, and you're only accounting for 7 here. That may be due to my error. The dialog ID that is missing from the $gettok is 40.. this corresponds with the text entry of SYS DOW 96

Are you sure that the dialog is open when that code was run? If it wasn't, then it can't update the dialog.