View previous topic :: View next topic |
Author |
Message |
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sat Aug 03, 2002 9:27 am Post subject: LAN chat program... |
|
|
Here's a very simple LAN chat program. You'd prolly
want to add more features (such as multiple message
capability) if you wanted to make a serious program
with it.
It saves a file on drive C (LANchat.txt) for the message
(which is deleted when viewed). Each message must be
viewed before you can receive another one, and it warns
that the target computer has a pending message if it
hasn't been read (and deleted) yet. It will NOT overwrite
a message. The message includes a line showing which
computer name it's from, plus the name in the "From:"
edit box (in case you want to add your name).
You can run the program minimized. It will activate with
a new message.
To check if the target computer is on the LAN, it attempts
to load a dir list (using FILELIST with the "D" parameter)
of the target's C: drive. If there's no list, the target is not
on the LAN...
In the Win95 registry, the network computer names are
within key names under:
"HK_CURRENT_USER\Network\Recent"
These are all the computers that have been accessed by
the local computer (which may not be all the computers
on the LAN). This program attempts to load these.
If this method doesn't work on your system, the code
is between the "rem ======================"
lines in case you want to change it (or remove it completely
and code in the computer names to the COMBO element
C1). Don't use any "/./." stuff, the program makes the
necessary additions. Just use computer names.
It also loads the local computer name in the %%local var.
Once again, if yours doesn't show up correctly you may have
to change this.
Obviously this program must be on both the sending and
receiving computers...
Have fun...
__________________________________________________________________________________________________________________________
Code: |
OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,"LAN Chat By Mac",-1,0,300,200
DIALOG ADD,STYLE,Bold,MS Sans Serif,9,B
DIALOG ADD,TEXT,T1,9,5,,,"From:"
DIALOG ADD,EDIT,E1,5,35,150,20
DIALOG ADD,TEXT,T2,34,15,,,"To:"
DIALOG ADD,COMBO,C1,30,35,150,20,,,LIST
DIALOG ADD,BUTTON,View,5,190,105,22,"View Message"
DIALOG ADD,BUTTON,New,30,190,50,22
DIALOG ADD,BUTTON,Send,30,245,50,22
DIALOG ADD,EDIT,E2,60,5,290,120,,,MULTI,WRAP
DIALOG ADD,STATUS,Stat,"No message...",Bold
DIALOG SHOW
LIST CREATE, 1
rem =================================================================
rem -- Load computer names from HK_CURRENT_USER\Network\Recent --
rem -- Only has those that have been accessed by this computer --
LIST CREATE, 2, SORTED
LIST REGKEYS, 1, "CURUSER", "Network\Recent"
%x = 0
REPEAT
%%name = @substr(@item(1, %x), 5, @diff(@len(@item(1, %x)), 3))
LIST ADD, 2, %%name
%x = @succ(%x)
UNTIL @equal(%x, @count(1))
LIST ASSIGN, C1, 2
LIST CLEAR, 1
LIST CLOSE, 2
%x = ""
rem =================================================================
rem -- Get local computer network name --
%%local = @regread(LOCAL,System\CurrentControlSet\Control\ComputerName\ComputerName,ComputerName)
DIALOG SET, E1, %%local
:EVLOOP
WAIT EVENT, 1
goto @event()
:TIMER
if @file(c:\LANchat.txt)
WINDOW ACTIVATE, "LAN Chat By Mac"
DIALOG SET, Stat, "You have a new message..."
end
goto EVLOOP
:SendBUTTON
if @not(@dlgtext(E2))
DIALOG SET, Stat, "Nothing to send..."
goto EVLOOP
end
if @not(@dlgtext(C1))
DIALOG SET, Stat, "Choose a recipient..."
goto EVLOOP
end
GOSUB CheckLAN
if %%on
if @file("\\"@item(C1)"\C\LANchat.txt")
DIALOG SET, Stat, @item(C1)" has a pending message..."
else
LIST ASSIGN, 1, @dlgtext(E2)
LIST INSERT, 1, ""
LIST INSERT, 1, "From computer: "%%local
LIST INSERT, 1, "Message from: "@dlgtext(E1)
LIST SAVEFILE, 1, "\\"@item(C1)"\C\LANchat.txt"
DIALOG SET, Stat, "Message sent to "@item(C1)"..."
LIST CLEAR, 1
end
end
goto EVLOOP
:NewBUTTON
if @dlgtext(E2)
if @ask(Clear text window?@tab())
DIALOG CLEAR, E2
end
end
DIALOG FOCUS, E2
goto EVLOOP
:ViewBUTTON
if @not(@file(c:\LANchat.txt))
DIALOG SET, Stat, "No message to view..."
goto EVLOOP
end
LIST LOADFILE, 1, c:\LANchat.txt
DIALOG SET, E2, @text(1)
FILE DELETE, c:\LANchat.txt
LIST CLEAR, 1
DIALOG CLEAR, Stat
goto EVLOOP
:CLOSE
EXIT
rem --------------- GOSUB ---------------
:CheckLAN
if @dlgtext(C1)
DIALOG SET, Stat, "Checking LAN - Please Wait..."
LIST CLEAR, 1
LIST FILELIST, 1, "\\"@item(C1)"\C", D
if @item(1)
DIALOG SET, Stat, @item(C1)" is on LAN..."
%%on = 1
else
DIALOG SET, Stat, @item(C1)" is NOT on LAN...
%%on = ""
end
LIST CLEAR, 1
end
exit
|
[EDIT] Changed code that finds local computer name (thanks to Lobo).
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Last edited by Mac on Sat Aug 03, 2002 9:55 pm; edited 1 time in total |
|
Back to top |
|
|
FreezingFire Admin Team
Joined: 23 Jun 2002 Posts: 3508
|
Posted: Sat Aug 03, 2002 3:07 pm Post subject: |
|
|
You can also find your computer name by using _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
Back to top |
|
|
Skit3000 Admin Team
Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Sat Aug 03, 2002 3:12 pm Post subject: |
|
|
You can also add support for computers with multiply usernames with @env(username)... |
|
Back to top |
|
|
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sat Aug 03, 2002 6:03 pm Post subject: |
|
|
Sorry guys, but @env(username) and
@env(computername) both return
absolutely nothing in Windows 95...
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
FreezingFire Admin Team
Joined: 23 Jun 2002 Posts: 3508
|
Posted: Sat Aug 03, 2002 6:19 pm Post subject: |
|
|
Sorry...
I didn't know that. _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
Back to top |
|
|
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sat Aug 03, 2002 6:22 pm Post subject: |
|
|
No problem,
Apparently some newer operating systems set DOS env
vars with useful info. I'm just still in the stone age...
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
LOBO Valued Contributor
Joined: 14 Mar 2002 Posts: 241 Location: Wilmington, Delaware, USA
|
Posted: Sat Aug 03, 2002 9:31 pm Post subject: |
|
|
Mac,
Here is another way to get the computer name without using the @env() that I use in one of my programs for work as we had a few 95 machines still around when I created it.
Code: | %%ComputerName = @regread(LOCAL,System\CurrentControlSet\Control\ComputerName\ComputerName,ComputerName) |
- Mark |
|
Back to top |
|
|
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sat Aug 03, 2002 9:38 pm Post subject: |
|
|
Hey Lobo,
I used this code (I'm hopin' this is accurate, it is on the two I tried...)
%%local = @regread("LOCAL", "Network\Logon", "username")
But your example also works.
Thanks, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
LOBO Valued Contributor
Joined: 14 Mar 2002 Posts: 241 Location: Wilmington, Delaware, USA
|
Posted: Sat Aug 03, 2002 9:51 pm Post subject: |
|
|
Mac wrote: |
%%local = @regread("LOCAL", "Network\Logon", "username")
|
Mac that above returned nothing on my system. Just to let you know I am using XP pro. My code did return my computer's name.
Last edited by LOBO on Sat Aug 03, 2002 10:00 pm; edited 1 time in total |
|
Back to top |
|
|
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sat Aug 03, 2002 9:58 pm Post subject: |
|
|
Thanks Lobo,
I changed it to use with your code. I never know how
much of this stuff I use is Win95 specific...
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|