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 


FileManager

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 4 Source Code
View previous topic :: View next topic  

Is this good coding for a newbie?
Yes
100%
 100%  [ 5 ]
No
0%
 0%  [ 0 ]
Total Votes : 5

Author Message
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Sat Jun 14, 2003 2:01 am    Post subject: FileManager Reply with quote

Here's a simple little file manager I've written. It's nothing fancy, but it was a nice way to learn a few things and practice alittle VDS while I'm waiting for VDS 5 Wink

I've been thinking about adding a dropdown box with valid drive letters but I haven't gotten that far yet. If you make any updates, please remember to ADD your name to the top of code, remember, ADD, not replace Wink

Currently it allows you to Copy files, Rename, Delete and launch files. And you can select extension to view. By entering * in the extension field all files are displayed.
Code:
rem ****************************************************************************
rem *  FileManager written in VDS 4.5 by Robert Olsen. <robert@geotrail.no>
rem *  Last update: 03:57 CET June 14th 2003.
rem *  Updated by: GeoTrail
rem ****************************************************************************

%%TITLE = FileManager
TITLE %%TITLE
  DIALOG CREATE,%%TITLE,-1,0,615,339
REM *** Modified by Dialog Designer on 14.06.2003 - 03:00 ***
  DIALOG ADD,LIST,FILES,8,8,600,232,,DBLCLICK,CLICK
  DIALOG ADD,EDIT,DIR,248,8,472,21
  DIALOG ADD,BUTTON,BROWSE,248,488,40,21,...,Browse
  DIALOG ADD,BUTTON,LIST,248,544,64,21,LIST,,DEFAULT
  DIALOG ADD,BUTTON,EXIT,288,544,64,21,EXIT
  DIALOG ADD,EDIT,EXT,288,480,32,21,txt
  DIALOG ADD,TEXT,TEXT1,296,392,,,List extensions:
  DIALOG ADD,STATUS,STATUS1
  DIALOG ADD,BUTTON,DELETE,280,8,64,21,Delete
  DIALOG ADD,BUTTON,COPY,280,80,64,21,Copy
  DIALOG ADD,BUTTON,RENAME,280,152,64,21,Rename
  DIALOG SHOW
  DIALOG DISABLE,DELETE
  DIALOG DISABLE,COPY
  DIALOG DISABLE,RENAME
 
  %D = @REGREAD(CURUSER,Software\GeoTrail Corporation\Experiment,Last directory)
  IF @NOT(@NULL(%D))
    DIALOG SET,DIR,%D
   %E = @REGREAD(CURUSER,Software\GeoTrail Corporation\Experiment,Last extension)
   DIALOG SET,EXT,%E
    LIST CLEAR,FILES
    LIST FILELIST,FILES,@DLGTEXT(DIR)\*.@DLGTEXT(EXT)
   DIALOG SET,STATUS1,@COUNT(FILES) files.
  ELSE
    %D = C:\
    DIALOG SET,DIR,%D
   DIALOG SET,EXT,*
    LIST CLEAR,FILES
    LIST FILELIST,FILES,C:\*.*
   DIALOG SET,STATUS1,@COUNT(FILES) files.
  END


:EVLOOP
  WAIT EVENT
  GOTO @EVENT()

:COPYBUTTON
  %%FILE =
  %%FILE = @NAME(@DLGTEXT(FILES)).@EXT(@DLGTEXT(FILES))
  IF @NOT(@NULL(%%FILE))
    %%COPYTO = @DIRDLG(Select where to copy %%FILE)
   IF @NOT(@NULL(%%COPYTO))
      FILE COPY, @DLGTEXT(FILES),%%COPYTO
      IF @NOT(@OK())
        WARN An error occured while trying to@CR()copy %%FILE to@CR()%%COPYTO
      END
   END
  END
  GOTO EVLOOP

:RENAMEBUTTON
  %%RENAMEFROM = @DLGTEXT(FILES)
  %%RENAMEFROMPATH = @PATH(%%RENAMEFROM)
  %%RENAMEFILE = @NAME(@DLGTEXT(FILES)).@EXT(@DLGTEXT(FILES))
  %%RENAMETO = @INPUT(Rename %%RENAMEFILE to:,%%RENAMEFILE)
  IF @NOT(@EQUAL(%%RENAMEFILE,%%RENAMETO))
    %%PATH = @PATH(@DLGTEXT(FILES))%%RENAMETO
    FILE RENAME,@DLGTEXT(FILES),%%RENAMEFROMPATH%%RENAMETO
    IF @NOT(@OK())
      WARN An error occured while trying to rename@CR()@DLGTEXT(FILES) to %%RENAMETO
    ELSE
     DIALOG DISABLE,RENAME
      LIST CLEAR,FILES
      LIST FILELIST,FILES,@DLGTEXT(DIR)\*.@DLGTEXT(EXT)
     DIALOG SET,STATUS1,@COUNT(FILES) files.
    END
  END
  GOTO EVLOOP

:GETFILEINFO
  %V = @VERINFO(@DLGTEXT(FILES),V)
  IF @NOT(@NULL(%V))
    %V = | Version %V
  END
  %C = @VERINFO(@DLGTEXT(FILES),C)
  IF @NOT(@NULL(%C))
    %C = "| Company: "%C " "
  END
  %%FILE = @NAME(@DLGTEXT(FILES)).@EXT(@DLGTEXT(FILES))
  parse "%S",@file(@DLGTEXT(FILES),Z)
  IF @NOT(@GREATER(%S,1024))
    DIALOG SET,STATUS1,@COUNT(FILES) files. | %%FILE %V %C| %S bytes.
  ELSIF @GREATER(%S,1048576)
    %S = @DIV(%S,1024)
    %S = @DIV(%S,1024)
    DIALOG SET,STATUS1,@COUNT(FILES) files. | %%FILE %V %C| %S mb.
  ELSE
    %S = @DIV(%S,1024)
    DIALOG SET,STATUS1,@COUNT(FILES) files. | %%FILE %V %C| %S kb.
  END
EXIT

:FILESCLICK
  GOSUB GETFILEINFO
  DIALOG ENABLE,DELETE
  DIALOG ENABLE,COPY
  DIALOG ENABLE,RENAME
  GOTO EVLOOP

:DELETEBUTTON
  IF @ASK(Are you sure you want to delete@CR()the file @NAME(@DLGTEXT(FILES)).@EXT(@DLGTEXT(FILES))?)
    FILE DELETE,@DLGTEXT(FILES)
   IF @OK()
     DIALOG DISABLE,DELETE
      LIST CLEAR,FILES
      LIST FILELIST,FILES,@DLGTEXT(DIR)\*.@DLGTEXT(EXT)
     DIALOG SET,STATUS1,@COUNT(FILES) files.
   ELSE
     WARN An error occured while trying@CR()to delete @NAME(@DLGTEXT(FILES)).@EXT(@DLGTEXT(FILES))
   END
  END
  GOTO EVLOOP

:FILESDBLCLICK
  %F = @EXT(@DLGTEXT(FILES))
  SHELL OPEN,@DLGTEXT(FILES)
  GOTO EVLOOP

:BROWSEBUTTON
  %D = @DIRDLG(Select directory to list:,@DLGTEXT(DIR))
  IF @NULL(%D)
    GOTO EVLOOP
  END
  DIALOG SET,DIR,%D
  GOTO LISTBUTTON

:LISTBUTTON
  rem Added a check to see if the DIR edit box is empty.
  IF @NULL(@DLGTEXT(EXT))
    WARN No extension entered!
  ELSE
    IF @NULL(@DLGTEXT(DIR))
      WARN No directory to list.
    ELSE
      LIST CLEAR,FILES
      LIST FILELIST,FILES,@DLGTEXT(DIR)\*.@DLGTEXT(EXT)
     DIALOG SET,STATUS1,@COUNT(FILES) files.
     REGISTRY  WRITE,CURUSER,Software\GeoTrail Corporation\Experiment,Last directory,@DLGTEXT(DIR)
     REGISTRY  WRITE,CURUSER,Software\GeoTrail Corporation\Experiment,Last extension,@DLGTEXT(EXT)
    END
  END
  DIALOG DISABLE,DELETE
  DIALOG DISABLE,COPY
  DIALOG DISABLE,RENAME
  GOTO EVLOOP

:CLOSE
:EXITBUTTON
  EXIT

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sat Jun 14, 2003 5:08 am    Post subject: Reply with quote

GeoTrail, there's a file search program in the vds 5 code section. I kind
of posted it there for you really, as you may find some of it's code
useful to your questions about listing files and their information.

Also, I've got a seriously old file manager program here I can post the
code for you to use if you want. It has the drop down drive combo
and other things.

-Garrett

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Sat Jun 14, 2003 6:33 am    Post subject: Reply with quote

Hi Geotrail,

good work Very Happy

a couple of suggestions if i may

- in the status bar, don't use "|" as i mistook it for a 1...i tend to use "<>"

- include a directory box where people can click on the directory to view rather than using the "..."

just a couple of ideas if you don't mind

otherwise looks great...and runs great (from the quick run i did)

Serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Sat Jun 14, 2003 12:30 pm    Post subject: Reply with quote

Thanks Garrett. I'l have a look at that Smile

Thanks to you to Serge. The statusbar is just something I made in a hurry to see how I could add more information to it. Would be cool if it was possible to add more "tabs" or what it's called in the status. I know you can do it with extensions, but... that's not the same.

I want to make a directory click feature too, just haven't figured out how yet Wink

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Sat Jun 14, 2003 11:26 pm    Post subject: Reply with quote

Hi Geotrail,

do you know that you can use @tab() in the status bar to left align, center and right align content? i think it works like this,

Code:

dialog set, status1, left@tab()centre@tab()right



Serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Sat Jun 14, 2003 11:58 pm    Post subject: Reply with quote

Thanks Serge.
That worked. Only with 3 tabs, but it worked Wink

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Sun Jun 15, 2003 12:49 am    Post subject: Reply with quote

glad to help geotrail

serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 4 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