forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


LAN chat program...

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code
View previous topic :: View next topic  
Author Message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sat Aug 03, 2002 9:27 am    Post subject: LAN chat program... Reply with quote

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
View user's profile Send private message Send e-mail
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sat Aug 03, 2002 3:07 pm    Post subject: Reply with quote

You can also find your computer name by using
Code:
@env(computername)

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sat Aug 03, 2002 3:12 pm    Post subject: Reply with quote

You can also add support for computers with multiply usernames with @env(username)...
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sat Aug 03, 2002 6:03 pm    Post subject: Reply with quote

Sorry guys, but @env(username) and
@env(computername) both return
absolutely nothing in Windows 95...

Cheers, Mac Smile

_________________
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
View user's profile Send private message Send e-mail
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sat Aug 03, 2002 6:19 pm    Post subject: Reply with quote

Sorry... Embarassed

I didn't know that.

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sat Aug 03, 2002 6:22 pm    Post subject: Reply with quote

No problem, Wink

Apparently some newer operating systems set DOS env
vars with useful info. I'm just still in the stone age...

Cheers, Mac Smile

_________________
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
View user's profile Send private message Send e-mail
LOBO
Valued Contributor
Valued Contributor


Joined: 14 Mar 2002
Posts: 241
Location: Wilmington, Delaware, USA

PostPosted: Sat Aug 03, 2002 9:31 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sat Aug 03, 2002 9:38 pm    Post subject: Reply with quote

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. Wink

Thanks, Mac Smile

_________________
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
View user's profile Send private message Send e-mail
LOBO
Valued Contributor
Valued Contributor


Joined: 14 Mar 2002
Posts: 241
Location: Wilmington, Delaware, USA

PostPosted: Sat Aug 03, 2002 9:51 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sat Aug 03, 2002 9:58 pm    Post subject: Reply with quote

Thanks Lobo, Smile

I changed it to use with your code. I never know how
much of this stuff I use is Win95 specific...

Cheers, Mac Smile

_________________
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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group