Trying to set the PAN ID and Node Identifier on a XBee S2B via programming from the microcontroller

Using XBee S2B units, I am trying to get them so I can set the PAN ID and Node Identification strings using rotary switches built into the device. The rotary switch (10 position) has 4 outputs.
I have figured out the programming (in C) to determine the value of the PAN ID variable by setting of the switch, and I have confirmed this by running the program in Code Blocks program (At this time, I am simulating the switches in the program so no physical switches are being used yet).
After confirming the code works in Code Blocks, I copied it to the project in the Code Warrior where I am trying to get it to work in the XBee units. I have the XBee S2B unit connected through the debugger and USB cables

signed long int panid;
// This declares the panid variable, that will get the actual value from the switches

xbee_cmd_simple(&xdev, “ID”,panid);
// This will send the value of panid to the ID in the Xbee
xbee_cmd_execute(&xdev, “NI”, panid,0x10);
//This will set the Node Identifier to the same as the panid
xbee_cmd_execute(&xdev, “WR”, NULL, 0);
// This will write the changes to the XBee X2B module

When I run the program using this code, I will get a PAN ID of 0, and some funny hieroglyphics in the Node Identification field

If I hard code the PAN ID in the program ,like this, it will set the PAN ID somewhat correctly (it will convert whatever number is entered here to a HEX value

signed long int panid=1234;
// This is a hard coded variable, that will be used as the PAN ID

xbee_cmd_simple(&xdev, “ID”,panid);
// This will send the value of panid to the ID in the Xbee
xbee_cmd_execute(&xdev, “NI”, panid,0x10);
//This will set the Node Identifier to the same as the panid
xbee_cmd_execute(&xdev, “WR”, NULL, 0);
// This will write the changes to the XBee X2B module

So, I have the 2 problems I am trying to figure out. The setting of the PAN ID, and the setting of the Node Identification string.

I am sure it is something fairly simple to get this to work, but the simplicity of it seems to be eluding me

I guess both problems are with input formats.

Although XBee accepts most of the parameters as Hex input (including PAN ID), it takes NI parameter as ASCII input.

If you pre-convert your inputs according to respective parameter, then it should resolve your issue.

Thanks for the reply.
I should have mentioned that I am relatively new to programming.
I know the problems lay with the format of the data. However, I seem to be at a loss to find the information to convert it to the correct format. Even a link to relevant code would be greatly appreciated .

Thank you