Quickly Impressed
I wrote my first program in REBOL today. It was something simple, but I really thought it would take longer than it did. I wanted a way to display my current IP address. This was something I could use at work too. We use VNC and I usually have to try and tell someone how to hover over the icon in the taskbar tray to see the IP address, so I can connect to their computer. This is a LAN IP I need, not an outside IP, just to clarify. We also have Windows XP, so I was aiming for it.
I started by using REBOL’s “call” command to execute the DOS command ipconfig. I learned how REBOL handled paths and learned the options to call, like call/output. I used it to write the output to a text file. Then I wanted to get some advice from some Reboler’s before going further. I was thinking I would need to parse the output someway. I fired up AltMe and connected to the REBOL3 World. AltMe is what Reboler’s use to communicate, instead of an IRC channel. I posted my question and received help very quickly. The “parse” command was mentioned with some other options. Then Ashley, a well known REBOL developer posted about using a system/network/host-address function in REBOL. This is exactly what I needed, because it displayed the IP address I needed without even using the ipconfig command. This shaved my time down considerably. Then all I had to do was figure out how to display this in a nice pop-up window.
I used the “View Layout” command. I played around with this using different options. Then I was having some trouble displaying the output of system/network/host-address in the window. Nothing was showing. I figured I needed to convert this into a string, but I wasn’t real sure. After researching, I still didn’t find anything concrete, but I did find a “to-string” command. So I tried it and bingo it worked. So I just need to do some more cosmetic changes and I’ll have it finished.
I was truly amazed at how quickly REBOL can do things. Plus, I am enjoying coding in it. The code is making a lot of sense to me, but I still have a lot to learn. It is very cool so far though.
Here is the code I wrote today.
REBOL [
Title: "IPCommand"
Version: 1.0
Author: "NovaBurst"
Purpose: {To display your local IP address in a window using a large font.}
]
myip: system/network/host-address
view layout [
title to-string myip
button "Quit" [quit]
]
No comments yet
Leave a reply