Jump to content

Data Validation for Report Header Parameters


---
 Share

Recommended Posts

---

I am working in Calypso 2025. I have a variable I created called u_Work_Order. I have enabled this parameter under Run and Measurement for my report header. I have also enabled Force Input at Start. A pop-up box appears right after the user hits run that asks them to enter in the WO. I would like to validate that the WO they entered is exactly 10 characters. 

I have been told I need to use PCM for this. I have tried creating my PCM program two different ways: first is by placing the code in a .txt file and then placing it in the root of the measurement plan program. I have also tried placing the code in the pre-settings with a global scope. 

I have tried every possible variation of code. Below are some I have tried. I always get an error like u_Work_Order is not defined or Temp_Variable is not defined. 

 

u_wo_number = ""
repeat
  u_wo_number = inquireText("Please enter 10-digit WO Number")
  if len(u_wo_number) != 10 then
    message("Error: Must be 10 characters. You entered: ", len(u_wo_number))
  endif
until len(u_wo_number) == 10

 

 

u_wo_number = ""
while len(u_wo_number) != 10 do
  u_wo_number = inquire( "Please enter 10-digit WO Number" )
  if len(u_wo_number) != 10 then
    display( "Error: Must be 10 characters. You entered: ", len(u_wo_number) )
  endif
endwhile

 

 

u_wo_number = ""
while len(u_wo_number) != 10 do
  u_wo_number = inquireText("Please enter the 10-digit WO Number:")
  
  if len(u_wo_number) != 10 then
    message("Error: The WO number must be exactly 10 characters. You entered ", len(u_wo_number))
  endif
endwhile

message("WO ", U_wo_number, " accepted. Starting measurement.")
Link to comment
Share on other sites

---

Be careful with Repeat commands because you do not have a break condition, so it will run indefinitely. 

Link to comment
Share on other sites

---

Please sign in to view this username.

 GPT gives me this:

 

wo = getRecordHead("u_Work_Order")

IF STRLEN(wo) <> 10 THEN
    MESSAGE("WO must be exactly 10 characters.")
    STOP
ENDIF

 

Since the variable (wo) already exists ("u_Work_Order", entered manually at Run), you just need to validate it, not ask for it again. I do not have PCM to verify (might not be STOP, I think it is CNCBreak()?), but the logic makes sense. Been quite awhile since I have used PCM. From this core code, you can expand on it and enforce more rules (for instance, not allowing someone to just type '0000000000' 🤣)

Edited
Link to comment
Share on other sites

---

endInspection() is better than cncBreak(). cncBreak will redlight the machine. There are cases though where cncBreak is the only thing that will stop a loop though. 

  • Like! 1
Link to comment
Share on other sites

---

you're definitely on the right path, just remember Calypso uses it's own version of small talk programming language. Your code appears right for python and similar languages, I haven't yet got GPT to spit out any useable smalltalk code for Calypso.

 I no longer have PCM access directly otherwise I would test it out for you.

 

Link to comment
Share on other sites

 Share

×
×
  • Create New...