![]() ![]()
|
Home PUBz Grafx Pax Tips & Trix Neo-Linx Neo-Talk NeoDezign-Filez Search NeoDezign
|
![]() |
FileRead... FileWrite... By using these two simple commands you can create a chat client that will operate on any Local Area Network. However, if you happen to see blue smoke rolling out of the back of your fileserver... then you can pretty well bet this chat program probably will not work. You see, the smoke is the "magic blue smoke" that is in all our computers. It is the what keeps them working. Once you let loose the magic blue smoke, most often, things stop working. See? You learned something today! This example is just that, an example. Your chat program might end up looking totally different than this example. That's great! Chances are, though, the concept will be the same. Hmm... unless, of course, someone comes up with an AddOn that does PPTP on the net... (hint-hint) The chat client program you create will be used by two or more people on a network to write to and read from a text file that exists on the fileserver. A large text entry object displays the chat text. A smaller text entry object will be used to type in what you want to say and, beside it, a button that writes your chit-chat to the text file on the server. The chat proggy will, in turn, read the chat text file and display it's contents in the large text entry box. Something to keep in mind while you write your chat proggy is that sometimes network users in different departments have mappings to the same folder but the drive letter and path might be different. For example, George and Nancy both work for CompanyX and share the same fileserver. George in Sales might have a mapping of "F:\OfcApps\" but Nancy in Accounting might have "H:\CompX\OfcApps". Keep your chat program "open-minded" and assume nothing will be the same for each chat user. Again, keep in mind, this example is only intended to describe the concept of how to create a LAN chat program of your own. Although the example does in fact work, the actual coding is really up to you. Using your imagination and inginuity you'll come up with ways to add all sorts of bells and whistles! |
![]() Getting Started : Create the following pages
![]() First, your chat program will need to learn where to read and write from. In the Page Action of the "Intro" page FileRead a local data file that will reside in the same folder with your chat program. We'll call this data file chat.ini. INTRO
Page
.///
the 1st time the program is run chat.ini will not exist
START
Page
SETUP
PATHS Page
ExecuteAddOn "[PubDir]external.exe" "'FileOpenDialog' 'Find Chat.dat' 'Chat.dat|chat.dat'" SetVar "[chat_dat]" "[FileOpenDialog]"
./// write the full path and filename of chat.dat GotoPage "Start"
F:\CompX\OfcApps\chat.dat
LOGIN
Page
FileRead "chat.ini" "2" "handle"Create a dialog on this page that resembles the one shown below. Use this to ask the user for the name they will use in chat.
FileWrite "chat.ini" "2" "[handle]" ./// insert two blank lines at the top of chat.dat FileInsLine "[chat_dat]" "1" FileInsLine "[chat_dat]" "1" ./// write your entrance to chat FileWrite "[chat_dat]" "1" "[handle] enters Chat" FileWrite "[chat_dat]" "2" "" GotoNextPage F:\CompX\OfcApps\chat.dat
CHAT
Page
If "[asklogout]" "=" "1" ./// insert blank lines at the top FileInsLine "[chat_dat]" "1" FileInsLine "[chat_dat]" "1" ./// write that you've exited chat FileWrite "[chat_dat]" "1" "[handle] exits Chat" FileWrite "[chat_dat]" "1" "" ./// break the While loop SetVar "[doloop]" "0" GotoPage "Start" EndIf FileInsLine "[chat_dat]" "1" FileWrite "[chat_dat]" "1" "<[handle]> [saythis]" FileWrite "[chat_dat]" "2" "" SetVar "saythis" ""
Obviously, the "Chat" page does most of the work. There are other conditions that could be detected and used to initiate a FileRead action but for this example I'll just use a While loop to read the chat.dat file every so many seconds. Enter the following commands into the "Chat" Page Actions SetVar "doloop" "1"Okay! Go back to the Intro page and hit the Run button... |