'Use variables for host and address in gdbinit function

I'm writing up some gdb functions in my gdbinit that can help me connect to various remote targets, but I haven't been able to use the variables correctly. The variables don't seem to get expanded/ defined correctly, how do I do this correctly?

set variable HOST1="127.0.0.0"
set variable PORT1="1234"

define connect_host1
    target remote $HOST1:$PORT1
end

gdb


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source