[Ri...] Posted yesterday at 04:16 PM Share Posted yesterday at 04:16 PM This brings up too many errors, but I think I need to know how to use "while" or if I can with PCM. (AI generated) Any help is appreciated. Blocked_Chars = "~`!@#$%^&*()+={}[]|:;',<>./?" setRecordHead("u_PartNumb",PN) Part_Numb = getRecordHead("u_PartNumb") // or however you retrieve the input i = 1 while (i <= length(Blocked_Chars)) currentChar = substring(Blocked_Chars, i, 1) if (instr(Part_Numb, currentChar) > 0) message("Invalid character '" + currentChar + "' found in part name.") stop() endif i = i + 1 endwhile  Link to comment Share on other sites More sharing options...
[Ri...] Posted yesterday at 04:55 PM Author Share Posted yesterday at 04:55 PM Im learning Copilot isnt very good at PCM. Now I am trying GTP5, but it is still full of errors. What are some of you using for AI and PCM? Link to comment Share on other sites More sharing options...
[Ma...] Posted yesterday at 05:13 PM Share Posted yesterday at 05:13 PM I don't know if while is supported. I found: for next if else endif if endif repeat until selectCase endSelect Calypso_02_PCM 1 Link to comment Share on other sites More sharing options...
[Ri...] Posted yesterday at 07:10 PM Author Share Posted yesterday at 07:10 PM The goal is to create a blacklist of characters when read from variables. u_PartNumb is just one example. Link to comment Share on other sites More sharing options...
[Ma...] Posted yesterday at 07:35 PM Share Posted yesterday at 07:35 PM (edited) I would use FOR cycle and to find occurence of char use "inStr()" From posted link to pcm manual it's on page 1-65 and 1-142 Do you want to just find occurence or substitute / remove them? Edited yesterday at 07:35 PM 1 Link to comment Share on other sites More sharing options...
[No...] Posted 13 hours ago Share Posted 13 hours ago Please sign in to view this quote. I still prefer "NI" over AI. Less hallucinations😄 Couldn't you get the same result with repeat / until? You only need to modify the condition and put it at the end: i=1 repeat currentChar=..... if (instr(..... nessage(.... stop() //???? --> cncBreak() ? endif i=i+1 until (i > length(Blocked_Chars))  1 Link to comment Share on other sites More sharing options...
[Ri...] Posted 9 hours ago Author Share Posted 9 hours ago I do have to go with repeat, Calypso v2017 doesn't support what I posted. Of course that was after trying AI. Link to comment Share on other sites More sharing options...
[Ri...] Posted 5 hours ago Share Posted 5 hours ago // Edit this list with what you don't want NOT_ALLOWED_LIST = list("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "+", "=", "{", "}", "[", "]", "|", ":", ";", "'", ",", "<", ">", ".", "/", "?") NOT_ALLOWED_LIST_NAME = "NOT_ALLOWED_LIST" Part_Numb = getRecordHead("u_PartNumb") // Begin searching for not-allowed strings for not_allowed_index = 1 to NOT_ALLOWED_LIST.size repeat // Get the first not-allowed string to check this_not_allowed_str = getParameterNamed(NOT_ALLOWED_LIST_NAME, not_allowed_index) this_not_allowed_len = len(this_not_allowed_str) // Attempt to find the not-allowed string // - if found, will be non-zero // - if not found, will be zero attempt = inStr(Part_Numb, this_not_allowed_str) // If the not allowed string was found, // - from: the start of the original string (1) // - to: the attempt index (minus 1 to not include the 1st character) // - PLUS // - from: attempt index + the length of the search string // - to: the end of what remains if attempt <> 0 then Part_Numb = subStr(Part_Numb, 1, attempt - 1) + mid(Part_Numb, attempt + this_not_allowed_len) endif until attempt == 0 // repeat for all not-allowed strings next not_allowed_index Someone else wrote this for me when I was trying to strip specific phrases out of header information. I would think this would work for you as well. 2 Link to comment Share on other sites More sharing options...
[An...] Posted 5 hours ago Share Posted 5 hours ago (edited) (Edit: Please sign in to view this username.  & I were writing the same response! He beat me to the reply 😅) I believe the solution you're looking to create exists already in my post here: You will need to: fill out the rest of the NOT_ALLOWED_LIST with characters that are not allowed I did about half of Blocked_Chars Could sneak a " character in with qm() or chr(34), among other methods... replace sourceStr with something more meaningful to your use case  Updated for 2025: // Edit this list with what you don't want NOT_ALLOWED_LIST = list("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")") NOT_ALLOWED_LIST_NAME = "NOT_ALLOWED_LIST" sourceStr = inquireText("Enter something to be filtered:") // Begin searching for not-allowed strings for notAllowedIndex = 1 to NOT_ALLOWED_LIST.size repeat // Get the first not-allowed string to check thisNotAllowedStr = getParameterNamed(NOT_ALLOWED_LIST_NAME, notAllowedIndex) thisNotAllowedLen = len(thisNotAllowedStr) // Attempt to find the not-allowed string // - if found, will be non-zero // - if not found, will be zero attempt = inStr(sourceStr, thisNotAllowedStr) // If the not allowed string was found, // - from: the start of the original string (1) // - to: the attempt index (minus 1 to not include the 1st character) // - PLUS // - from: attempt index + the length of the search string // - to: the end of what remains if attempt <> 0 then sourceStr = subStr(sourceStr, 1, attempt - 1) + mid(sourceStr, attempt + thisNotAllowedLen) endif until attempt == 0 // repeat for all not-allowed strings next notAllowedIndex // Output display(sourceStr) See attached for the above code 😇 general.txt Edited 5 hours ago Richard Shomaker beat me to the punch 1 1 Link to comment Share on other sites More sharing options...
[Ri...] Posted 5 hours ago Share Posted 5 hours ago Please sign in to view this username.  I couldn't have done it without you though, so many thanks once again for the piece of code that you wrote for me. 🙂 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in