Jumping in here with a correction and clarification:
The GetTerminalNameWithDevPrefix function is a port of "Get Terminal Name with Device Prefix.vi" from LabVIEW\examples\DAQmx\_Utility\_Utility.llb, which looks like the attached image. The purpose of the while loop is to find the first device in the task that is neither a C Series module nor an SCXI module, and then output "/<device name>/<terminal name>" for that device (not "/<terminal name>").
An if-statement would cause it to always use the name of the first device in the task, which might be a C Series module or an SCXI module (neither of which would have the desired terminal, such as "ai/StartTrigger"). However, since the names of the devices in the task are sorted alphabetically, that would only happen if you are using CompactDAQ or SCXI and you are not using the default device names (since "cDAQ1" comes before "cDAQ1Mod1" and "Dev1" or "PXI1Slot4" comes before "SC1MD1").
In summary, the answer to your original question (
"Should the last 3 lines be enclosed in brackets (i.e. {})?") is yes. The indentation reflects the intended behavior, but the lack of curly braces causes the code to work incorrectly. The while loop is necessary to skip past multiple C Series or SCXI modules.
Thank you for bringing this issue to our attention, and my apologies for the confusion.
Brad
---
Brad Keryan
NI R&D