Jump to content

Help with dynamic operator name selection using inquireList and addToFile


---
 Share

Recommended Posts

Hi,

I'd like to change how operator names are entered in our program. Currently, we use inquireText to let users type in their name, but this allows them to enter anything. I'd prefer to offer a selectable list of names instead.

I know I can use something like:
inquireList("Operator:", "Arnold", "Bob", "Charlie", "Derek")

However, I want the list to be dynamic. Ideally, I'd like to include an "Other" option. If the user selects this, it should:

  1. Prompt with inquireText for their full name

  2. Use addToFile() to save this name to a .txt file

  3. Add that name to the list for next time

This way, the list grows as new users are added, and the file also serves as a log of who has used the program or CMM.

The part I’m stuck on is using the list from the .txt file as input to inquireList. I’ve tried using list() but it seems to treat the entire list as a single option, not separate names.

So I think I need a way to:

  • Read the file into a list

  • Count the names

  • Use those names individually as arguments for inquireList

  • If "Other" is selected, add the resulting text to the .txt for next time

Any help on how to do this would be appreciated.

Thanks in advance!

Link to comment
Share on other sites

Here is a simpel example to push you forward..

savedOps = readListFile("c:\temp\operators.txt").sorted
opList = "inquireList(" + qm() + "Operator:" + qm() + ", " + qm() + getParameterNamed(savedOps,1) + qm()
for i = 2 to savedOps.size
	opList = opList + ", " + qm() + getParameterNamed(savedOps,i) + qm()
next i

repeat
	choise = compute(opList + ", " + qm() + "Other" + qm() + chr(41))
until choise <> ""

if choise == "Other"
	newOp = inquireText("Add operator:")
	addToFile("c:\temp\operators.txt",newOp)
	choise = newOp
endif
setRecordHead("operid",choise)

 

Edited
  • Like! 2
  • Thank you! 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...