Function Return: Map Values

Started by stanl, July 24, 2022, 07:48:54 AM

Previous topic - Next topic

stanl

Assume I have a UDF that accepts an SFTP sever ID and a task number. Within the UDF the appropriate user, password, SFTP server login ID and passphrase will be sent to a WinSCP function for execution.


Question is: I know I can place the multiple return values into an array, but wonder if instead I create a Map [retvals] can that be returned and sent to WinSCP function so that rather than WinSCP sessions having


user = Array[0]


it would be


user = retvals["user"]


All based on request for more 'readability' from code.  Anything for work has to be compiled exe so practice is limited. :o


Or I could have just asked "Can a map be create in one function and sent as a parameter  to another function and still be treated as a map"?

td

Assuming I have decyphered your post correctly and as long as the "user" values are unique, the map should work just like the regular indexed WIL array.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Quote from: td on July 25, 2022, 07:17:31 AM
Assuming I have decyphered your post correctly and as long as the "user" values are unique, the map should work just like the regular indexed WIL array.


Pretty easy for basic test. Thanks. The purpose is more complicated but question was answered
Code (WINBATCH) Select


#DefineSubRoutine get_User(mapval)
   Message("User Value",mapval)
#EndSubRoutine
#DefineSubRoutine get_map(map)
   Get_User(map["user"])
#EndSubRoutine
server = "user,user1":@tab:"password,password1":@tab:"passphrase,C:\temp\001.sys"
map = MapCreate(server)
get_map(map)