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 


"Help" file for idiots (customizable text viewer).

 
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: Thu Aug 22, 2002 12:36 am    Post subject: "Help" file for idiots (customizable text viewer). Reply with quote

You can also use it as a custom README file display, or
as a file viewer. It's designed to be run from another VDS
program, but could be easily modified. It uses several
routines from the VDS text editor.

I wanted a simple text file viewer for my own use, especially
for my VDS C++ IDE which uses more than one text file (I
copy/paste from Borland or the Win32SDK help file to get
topics I use most). With this I can open several text files at
once from the C++ IDE menu if needed. I could use notepad
(or the VDS editor), but I usually have several files open and
it's nice to have a different looking window for the help files
(plus I won't be deleting anything accidentally). It's also easy
to add info (edit the text file, or add another one)...

Features:
- Uses the @name() of the file as the window title (if a valid file).
- Customizable text (font, font size, font color) from the command line.
- Resizable.
- "Find" and "Find Next" routine.
- "Select All" routine.
- "Copy Selected" routine.
- Print routine.
- Under 10k size (when compiled with VDS3).
- It's "READ ONLY" so user (or you) can't destroy data.

Limitations:
- 32k max file size (started with a LIST, but prefer selectable text).

There's example RUN and SHELL commands to use the program
once it's compiled (they should open the VDS "readme" file if you
run it from your VDS directory). Modify them if you don't compile
it as "HELP.EXE".

REMEMBER, it's designed to be run from another VDS program.

NOTE: Use an all-chars-same-width font such as "Courier New"
to display columns accurately.
__________________________________________________________________________________________________________________________
Code:

rem -- Loads text file used as command arg %1 (use full path) --

rem -- For CUSTOM TEXT, use @chr(34)FONT|SIZE|ATTRIB|BKGRND|FOREGRND@chr(34) as %2 --
rem -- CUSTOM TEXT EXAMPLES (assuming you compile this as HELP.EXE)
rem      Custom using hex colors:
rem        run @path(%0)help.exe @path(%0)"readme.txt" @chr(34)Comic Sans MS|14|B|$0099CC00|$00CC00CC@chr(34)
rem      Custom using VDS color names:
rem        run @path(%0)help.exe @path(%0)"readme.txt" @chr(34)Courier New|14|B|DKBLUE|WHITE@chr(34)
rem      Use program defaults:
rem        run @path(%0)help.exe @path(%0)"readme.txt"
rem      System defaults (anything in %2 skips program defaults):
rem        run @path(%0)help.exe @path(%0)"readme.txt" |
rem      System defaults, make it bold only:
rem        run @path(%0)help.exe @path(%0)"readme.txt" @chr(34)||B||@chr(34)
rem      Using SHELL OPEN:
rem        SHELL OPEN, @path(%0)help.exe, @path(%0)"readme.txt" @chr(34)Comic Sans MS|14|B|$003399FF|BLACK@chr(34)

rem -- Change this if ya want (remove it for system defaults to be program defaults) --
if %2
   PARSE "%%font;%%size;%%attrib;%%bkgrnd;%%foregrnd", %2
else
  rem -- Program defaults --
  %%font = "Courier New"
  %%size = "10"
  %%attrib = ""
  %%bkgrnd = "$00CCFFFF"
  %%foregrnd = "BLACK"
end

if @not(@file(%1))
   %1 = "  ERROR - File Not Found"
end
TITLE By Mac
DIALOG CREATE,@name(%1),-1,0,600,330,CLASS MacHelpWindow,RESIZABLE
  DIALOG ADD,STYLE,Style1,%%font,%%size,%%attrib,%%bkgrnd,%%foregrnd
  DIALOG ADD,MENU,&Options,&Find|Ctrl+F,Find &Next|F3,-,&Select All|Ctrl+A,&Copy Selected|Ctrl+C,-,&Print|Ctrl+P,-,&Exit
  DIALOG ADD,EDIT,E1,0,0,600,315,,,MULTI,SCROLL,READONLY,Style1
DIALOG SHOW
rem -- Edit element ID for @sendmsg() --
%q = @winexists(~E1)

if @file(%1)
   LIST CREATE, 1
   LIST LOADFILE, 1, %1
   DIALOG SET, E1, @text(1)
   LIST CLOSE, 1
end

:EVLOOP
  WAIT EVENT
  goto @event()

:RESIZE
  PARSE "%h;%w", @dlgpos(,HW)
  DIALOG SETPOS,E1,0,0,%w,%h
  goto EVLOOP

:FindMENU
  %t = @input(Enter text to search for:)
  if %t
     %s = @pred(@pos(%t,@dlgtext(E1)))
     if @greater(%s,-1)
        gosub SelectText
     else
        INFO Text not found @tab()
     end
  end
  goto EVLOOP

:Find NextMENU
  if %t
     %p = @pos(%t,@strdel(@dlgtext(E1),1,@succ(%s)))
     if @greater(%p,0)
        %s = @sum(%s,%p)
        gosub SelectText
     else
        INFO Text not found @tab()
     end
  end
  goto EVLOOP

:Select AllMENU
  rem -- Select all text --
  DIALOG FOCUS, E1
  %z = @sendmsg(%q,$0B1,0,-1)
  goto EVLOOP

:Copy SelectedMENU
  %z = @sendmsg(%q,$0301,0,0)
  goto EVLOOP

:PrintMENU
  if @dlgtext(E1)
     LIST CREATE, 1
     LIST ASSIGN, 1, @dlgtext(E1)
     LIST PRINT, 1, %%font, %%size
     LIST CLOSE, 1
  end
  goto EVLOOP

:ExitMENU
:CLOSE
  EXIT

rem ------------------ SUB ------------------

:SelectText
  rem -- Select text found --
  %z = @sendmsg(%q,$0B1,%s,@sum(%s,@len(%t)))
  rem -- Scroll selected text (caret) into view --
  %z = @sendmsg(%q,$0B7,0,0)
  exit

EDIT - Optimized PRINT procedure and tested it.
Also had omitted a "@path(%0)" on some of the examples.

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