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 


Code Save - snippet editor/manager (VDS3-4).

 
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: Sun Mar 09, 2003 5:31 pm    Post subject: Code Save - snippet editor/manager (VDS3-4). Reply with quote

I've been using this over a year with no problems. Feel free to
use any/all of the code as you see fit.

The top line of the edit box on the right is the title shown on the
left. Click the item on the left to load that file.

It allows ya to edit/copy/paste snippets on the fly. I have it in
VDS\TOOLS folder and it shows up on the menu. Saves files as
code000.txt, code001.txt, etc. No limit on number of files.

Here's a screen shot if ya wanna see it in action:

http://www.trinex.net/users/mac/untitled2.jpg
_____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Code:

rem -- Thanks to Chris Gingerich (aka LiquidCode) for this idea --
rem -- VDS3 & VDS4 compatible --
rem -- %f, %g, %m, %p ,%q are used --
%p = @path(%0)

OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,Code Save,-1,0,@sysinfo(SCREENWIDTH),320
  DIALOG ADD,STYLE,Style1,Courier New,10,,WHITE
  DIALOG ADD,LIST,L1,30,0,155,265,,,CLICK
  DIALOG ADD,EDIT,E1,30,155,@diff(@sysinfo(SCREENWIDTH),155),265,,,MULTI,SCROLL,Style1
  DIALOG ADD,BITBTN,Save,5,5,50,22,,Save," Save Text To File "
  DIALOG ADD,BITBTN,Copy,5,60,50,22,,Copy," Copy Selected Text To Clipboard "
  DIALOG ADD,BITBTN,CopyAll,5,115,50,22,,"Copy All"," Copy All Text To Clipboard "
  DIALOG ADD,BITBTN,Clear,5,170,50,22,,Clear," Clear Edit Box "
  DIALOG ADD,BITBTN,Delete,5,225,50,22,,Delete," Delete This File "
  DIALOG ADD,BITBTN,Help,5,285,50,22,,Help," Help "
  DIALOG ADD,STATUS,Stat
DIALOG SHOW

rem -- Get ID of edit element for use in @sendmsg() --
%q = @winexists(~E1)

rem -- Add horizontal scroll to list --
%z = @sendmsg(@winexists(~L1),$0194,2000,0)

LIST CREATE, 1
GOSUB LoadList
LIST SEEK, L1, 0
goto L1CLICK

:EVLOOP
  WAIT EVENT, "0.1"
  goto @event()

:TIMER
  rem -- Get line number (use %c to get a start point) --
  %c = @sendmsg(%q,$0BB,-1,0)
  %l = @succ(@sendmsg(%q,$0C9,%c,0))
  rem -- Get total number of lines in document --
  %n = @sendmsg(%q,$0BA,0,0)
  rem -- Check if document has been modified --
  if @zero(@sendmsg(@winexists(~E1),$0B8,0,0))
     %m = ""
  else
     %m = Modified
  end
  DIALOG SET, Stat, "Line " %l" of "%n" lines     size: "@len(@dlgtext(E1))" bytes     "%f"     "%m
  goto EVLOOP

:L1CLICK
  if %m
     if @ask(Save changes to %f?@tab())
        goto SaveBUTTON
     end
  else
     DIALOG CLEAR, E1
     rem -- Clear "text modified" flag --
     %z = @sendmsg(%q,$0B9,0,0)
  end
  %x = @index(L1)
  GOSUB FormatNumber
  %f = code%x.txt
  if @file(%p%f)
     LIST LOADFILE, 1, %p%f
     DIALOG SET, E1, @text(1)
  end
  goto EVLOOP

:CopyBUTTON
  rem -- Copy selected text --
  %z = @sendmsg(@winexists(~E1),$0301,0,0)
  %%info = Selected Text Copied To Clipboard.
  GOSUB InfoWindow
  goto EVLOOP

:CopyAllBUTTON
  rem -- Select all text --
  DIALOG FOCUS, E1
  %z = @sendmsg(%q,$0B1,0,-1)
  rem -- Copy selected text --
  %z = @sendmsg(@winexists(~E1),$0301,0,0)
  %%info = All Text Copied To Clipboard.
  GOSUB InfoWindow
  goto EVLOOP

:SaveBUTTON
  GOSUB SaveFile
  goto EVLOOP

:ClearBUTTON
  if @ask(Clear all text?@tab())
     DIALOG CLEAR, E1
     rem -- Clear "text modified" flag --
     %z = @sendmsg(%q,$0B9,0,0)
  end
  goto EVLOOP

:DeleteBUTTON
  if @file(%p%f)
     if @ask(Delete this file?@cr()@cr()%p%f@tab())
        FILE DELETE, %p%f
        DIALOG CLEAR, E1
        rem -- Clear "text modified" flag --
        %z = @sendmsg(%q,$0B9,0,0)
        if @not(@file(%p%f))
           GOSUB LoadList
           %%info = File Deleted...@cr()@cr()%p%f
           GOSUB InfoWindow
        else
           WARN Error - %p%f not deleted!@tab()
        end
     end
  else
     WARN "Cannot delete, file does not exist."@tab()
  end
  goto EVLOOP

:HelpBUTTON
  INFO "Add your snippets of code to the edit box."@cr()@cr()"The first line should be title or descriptive name."@tab()@cr()@cr()"Click list item to load existing file."@cr()@cr()"'Save' button saves code to file."@cr()@cr()"'Copy' button copies selected text to clipboard."@cr()@cr()"'Copy All' button copies all text to clipboard."@cr()@cr()"'Clear' button clears text from edit box."@cr()@cr()"'Delete' button removes file selected in list box."
  goto EVLOOP

:CLOSE
  if %m
     GOSUB SaveFile
  end
  EXIT

rem ----------- GOSUB ROUTINES -----------

:SaveFile
  if @both(@dlgtext(E1), %m)
     if %f
        if @ask(Save %f?@tab())
           LIST ASSIGN, 1, @dlgtext(E1)
           LIST SAVEFILE, 1, %p%f
           LIST CLEAR, 1
           %%info = File Saved...@cr()@cr()%p%f
           GOSUB InfoWindow
           GOSUB LoadList
           rem -- Clear "text modified" flag --
           %z = @sendmsg(%q,$0B9,0,0)
        end
     else
        WARN "No file number selected from list."@tab()
     end
  else
     %%info = Nothing new to save.
     GOSUB InfoWindow
  end
  exit

:LoadList
  rem -- Allow enough space in list for new code files,
  rem -- when 100th item is used, we add another 100.
  LIST CLEAR, 1
  LIST CLEAR, L1
  %x = 100
  REPEAT
    if @file(%pcode%x.txt)
       %x = @sum(%x, 100)
    end
  UNTIL @not(@file(%pcode%x.txt))
  %t = %x
  %x = 0
  REPEAT
    GOSUB FormatNumber
    if @file(%pcode%x.txt)
       LIST LOADFILE, 1, %pcode%x.txt, WAIT
       %g = @item(1, 0)
       LIST ADD, L1, %x"-"%g
       LIST CLEAR, 1
    else
       LIST ADD, L1, %x"-"
    end
    %x = @succ(%x)
  UNTIL @greater(%x, %t)
  exit

:FormatNumber
  rem -- Add zeroes to make numbers 3 digit minimum -
  if @equal(@len(%x), 1)
     %x = 00%x
  end
  if @equal(@len(%x), 2)
     %x = 0%x
  end
  exit

:InfoWindow
  rem -- Let's us know if we fail to init %%info --
  if @not(%%info)
     %%info = "Oops, no message..."
  end
  %%infoheight = 16
  rem -- Adjust height if @cr() found --
  %%tmp = %%info
  %%longest = @pos(@chr(13), %%info)
  REPEAT
     if @greater(@pos(@chr(13),%%tmp), 0)
        if @greater(@pos(@chr(13), %%tmp), %%longest)
           %%longest = @pos(@chr(13), %%tmp)
        end
        %%tmp = @strdel(%%tmp,1,@pos(@chr(13), %%tmp))
        %%infoheight = @sum(%%infoheight, 16)
     end
  UNTIL @equal(0, @pos(@chr(13), %%tmp))
  if @greater(@len(%%tmp),%%longest)
    %%longest = @len(%%tmp)
  end
    %%infowidth = @prod(%%longest, 8)
  rem End of new section
  rem -- Create the message window --
  DIALOG CREATE,"InfoWindow",-1,-1,@sum(%%infowidth,60),@sum(%%infoheight,42),NOTITLE,ONTOP
    DIALOG ADD,STYLE,StyleInfo,Courier New,10,BC,DKBLUE,WHITE
    DIALOG ADD,STYLE,StyleInfoTrim,,,,WHITE
    DIALOG ADD,TEXT,Info1,1,1,@sum(%%infowidth,58),@sum(%%infoheight,40),,,StyleInfoTrim
    DIALOG ADD,TEXT,Info2,4,4,@sum(%%infowidth,52),@sum(%%infoheight,34),@cr()%%info,,StyleInfo
  DIALOG SHOW
  WAIT "2"
  rem -- Closes info window since it's the current one --
  DIALOG CLOSE
  rem -- Always kill extra CLOSE event --
  %e = @event()
  %%info = ""
  %%tmp = ""
  %%longest = ""
  %%infowidth = ""
  %%infoheight = ""
  exit

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 Sun Mar 09, 2003 5:52 pm; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1711
Location: Space and Time

PostPosted: Sun Mar 09, 2003 5:39 pm    Post subject: Reply with quote

Hey Mac, I forgot about this. I have it tucked away somewhere. I may have to start using it again. Thanks for the memories! Smile
_________________
Chris
Http://vdsfreak.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
GeoTrail
Valued Contributor
Valued Contributor


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

PostPosted: Sun Mar 09, 2003 5:42 pm    Post subject: Reply with quote

Cool Mac.
Any possibilities of compiling it and mailing it to me? Pretty please? Wink robert@geotrail.no

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


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

PostPosted: Sun Mar 09, 2003 5:46 pm    Post subject: Reply with quote

Hiya Chris, Smile

I use it constantly - it's just too handy. Not sure, but you may
have made some modifications that I'm not using. Feel free
to post 'em if you did. Wink

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
Mac
Professional Member
Professional Member


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

PostPosted: Sun Mar 09, 2003 5:49 pm    Post subject: Reply with quote

Geotrail - don't you have a registered version of VDS?
This should compile with VDS3 or VDS4.

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
GeoTrail
Valued Contributor
Valued Contributor


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

PostPosted: Sun Mar 09, 2003 5:59 pm    Post subject: Reply with quote

No, I'm affraid not Crying or Very sad Crying or Very sad

But I've set my heart on getting the money for it.
I'm hoping to get payed for a job next week, so I'm crossing my fingers till then Very Happy

_________________
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 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