PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Associative array as a method arg  (Read 935 times)

ChrisKCAi

  • Silver Member
  • ***
  • Posts: 38
    • View Profile
Associative array as a method arg
« on: May 28, 2020, 09:20:50 AM »
PxPlus 15.10
Is there a way to pass an associative array as an argument to an object method?

Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Associative array as a method arg
« Reply #1 on: May 28, 2020, 10:36:57 AM »
You can do it if in the function definition you declare varname${All} as in the following object:

Code: [Select]
def class "a"
  function dump(v${all})
  enter var${all}
  dump
  return 1
end def

You can then use it as follows:

  begin
  abc$["first"]="one"
  abc$["second"]="two"
  a=new("a")
  a'Dump(abc${all})

Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com