To loop over the registration table and retrieve clients mac-address and ip-address from dhcp server
:foreach i in=[/caps-man registration-table find] do={
:local mac [/caps-man registration-table get $i mac-address]
:local ip [/ip dhcp-server lease get [/ip dhcp-server lease find where mac-address="$mac"] address]
:put "$mac - $ip"
}
Try to play arround in the console and see what output you get from different commands.
"find" for example returns the id for all the clients in the registration table using that id you can then retrieve the mac-address for that client.
If you type "/caps-man registration-table find" in to the console nothing will happen but if you type :put [/caps-man registration-table find] you will get all the id's.
Check the wiki, its a great resource while learning mikrotik scripting
https://wiki.mikrotik.com/wiki/Manual:Scripting