Is XP/Vista Themes (llol and fee) supported by HMG ?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

CCH4CLIPPER
Posts: 130
Joined: Tue Mar 03, 2009 8:59 am
Been thanked: 1 time

Re: Is XP/Vista Themes (llol and fee) supported by HMG ?

Post by CCH4CLIPPER »

Hi Rathinagiri

I am anxiously awaiting your UDF :-)

CCH
http://cch4clipper.blogspot.com

User avatar
Rathinagiri
Posts: 5324
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 200 times
Been thanked: 210 times
Contact:

Post by Rathinagiri »

Sorry for the delay,

Here comes my udf.

call it main.prg

Code: Select all

# include "minigui.ch"

function main

define window sample at 0,0 width 800 height 600 main
   define button button1
      row 10
      col 10
      caption "Click here"
      action showtext("readme.txt")
   end button
end window
sample.center
sample.activate
return nil
call it udf.prg

Code: Select all

#include "minigui.ch"

function showtext(_filename)
local _pointchar := at(".",_filename)
local _winname := ""
private _winwidth := 700 //getdesktopwidth() - 60
private _winheight := 550 //getdesktopheight() - 60
if _pointchar > 0
   _winname := substr(_filename,1,_pointchar - 1)
else
   _winname := _filename
endif
if iswindowdefined(&_winname)
   release window &_winname
endif
define window &_winname at 0,0 width _winwidth height _winheight title _filename modal nosize on init textshow(_filename,_winname)
   @ _winheight - 60,int(_winwidth /2)-90  button exit1  caption "Exit" width 80 action textshowexit(_winname)
   @ _winheight - 60,int(_winwidth /2)+10  button print1  caption "Print" width 80 action textfileprint(_filename)
end window
center window &_winname
activate window &_winname
return nil

function textshowexit(_winname)
release window &_winname
return nil

function textshow(_filename,_winname)
local lines := {}
local handle := fopen(_filename,0)
local size1 := 0
local size2 := 0
local sample := 0
local lineno := 0
local eof1 := .f.
local linestr := ""
local c := ""
local len1 := 0
local x := 0
local finished := .f.
local m := 0
local length1 := 0
local totpages := 0
local linecount := 0
local length2 := 0
local pagecount := 0
local start := 0
local end := 0
local v := 0
local v1 := 0
if handle == -1
   return nil
endif
size1 := fseek(handle,0,2)
size2 := size1
if size1 > 65000
   sample := 65000
else
   sample := size1
endif
fseek(handle,0)
lineno := 1
aadd(lines,"")
c := space(sample)
eof1 := .f.
linestr := ""
len1 := 0
do while .not. eof1
   x := 0
   x := fread(handle,@c,sample)
   len1 := len1 + sample
   if x < 1
      eof1 := .t.
      lines[lineno] := linestr
   else
      finished := .f.
      do while .not. finished
         m := at(chr(13),c)
         if m > 0
            if m == 1
               linestr := ""
               lineno := lineno + 1
               aadd(lines,"")
               c := substr(c,m+1,len(c))
            else
               if len(alltrim(linestr)) > 0
                  linestr := linestr + substr(c,1,m-1)
               else
                  linestr := substr(c,1,m-1)
               endif
               c := substr(c,m+1,len(c))
               lines[lineno] := linestr
               linestr := ""
               lineno := lineno + 1
               aadd(lines,"")
            endif
         else
            linestr := c
            finished := .t.
         endif
      enddo
      c := space(sample)
   endif
enddo
fclose(handle)
define tab pages of &_winname at 10,10 width _winwidth - 20 height _winheight - 90
length1 := len(lines)
if length1 <= 10000
   totpages := 1
else
   totpages := 0
   length2 := length1
   do while length2 > 0
      length2 := length2 - 10000
      totpages := totpages + 1
   enddo
endif
if totpages > 15
   return nil
endif
for pagecount := 1 to totpages
   start := ((pagecount-1) * 10000) + 1
   if pagecount == totpages
      end := len(lines)
   else
      end := start + 9999
   endif
   page "Page "+alltrim(str(pagecount))
      v := "lb"+alltrim(str(pagecount))
      v1 := "page"+alltrim(str(pagecount))
      &v1 := {}
      for linecount := start to end
         aadd(&v1,{substr(lines[linecount],2,len(lines[linecount]))})
      next j
      @ 25,10 grid &v width _winwidth - 50 height  _winheight - 120 headers {_filename} widths {800} items &v1 value 1 font "courier new" size 10 nolines
   end page
next pagecount
end tab
return nil

function textfileprint(_filename)
copy file (_filename) to lpt1
return nil

I had attached the same for your kind reference. Compile using HMG-IDE and tell me about your comments. The udf can show a text file as read only.
Attachments
showtext.zip
User Defined Function to show a text file as read only.
(1.97 KiB) Downloaded 220 times
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

CCH4CLIPPER
Posts: 130
Joined: Tue Mar 03, 2009 8:59 am
Been thanked: 1 time

Post by CCH4CLIPPER »

Hi Rathinagiri

TQVM for the codes, which I will definitely check out.

Whilst waiting for you, I was EXECUTE 'notepad.ex ' PARAMETERS <'textfilename'>


Regards

CCH
http://cch4clipper.blogspot.com

User avatar
esgici
Posts: 4538
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 410 times
Been thanked: 118 times
Contact:

Post by esgici »

rathinagiri wrote: Here comes my udf.

The udf can show a text file as read only.

Hi Rathi

Reading a text file is a challenging issue and your work is very nice ( as always ).

But sorry, we have a comprehensive library module for this purpose ( in the our mysterious treasure of course ). Moreover it is documented !

But don't worry, me too discovered it after writing my own.

I hope help you.

--

Regards

---

TFILEREAD
Read a file one line at a time Previous Top Next

--------------------------------------------------------------------------------

SYNTAX : TFileRead():New( <cFileName> [, <nReadSize> ] ) ==> oFile


ARGUMENTS :


<cFileName> is the required name of the file to be read.
<nReadSize> is the optional size to use when reading from the file. The default value is 4096 and the allowed range is 1 through 65535. Any value outside of this range causes the default value to be used.


RETURNS : An instance of the File Reader class


DESCRIPTION :


TFileRead() is used to access a file one line at a time. You must specify the name of the file when an instance of the class is created.

The class data should be considered private to the class.

The class methods are as follows:

New() : Creates a new instance of the TFileRead class.

Open([<nFlags>]) : Opens the file for reading. The optional nFlags parameter can use any of the FOPEN() flags from fileio.ch. The default is FO_READ + FO_SHARED. Calling this method when the file is already open causes the next ReadLine() to start over from the beginning of the file.

Close() : Closes the file.

ReadLine() : Returns one line from the file, stripping the newline characters. The following sequences are treated as one newline:
1) CR CR LF;
2) CR LF;
3) LF; and
4) CR.

Note: LF CR is 2 newlines.

Name() : Returns the name of the file.
IsOpen() : Returns .T. if the file is open.
MoreToRead() : Returns .T. if there are more lines to be read (think of it as an inverse EOF function).
Error() : Returns .T. if an error has occurred.
ErrorNo() : Returns the current error code.
ErrorMsg([<cPre>]) : Returns a formatted error message.


EXAMPLES :


#include "fileio.ch"

PROCEDURE Main( cFile )

LOCAL oFile := TFileRead():New( cFile )

oFile:Open()
IF oFile:Error()
QOUT( oFile:ErrorMsg( "FileRead: " ) )
ELSE
WHILE oFile:MoreToRead()
OUTSTD( oFile:ReadLine() )
OUTSTD( NEW_LINE )
END WHILE
oFile:Close()
END IF
QUIT


FILES :


Library is libmisc


SEE ALSO :


TClass()

---
Viva INTERNATIONAL HMG :D

User avatar
Rathinagiri
Posts: 5324
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 200 times
Been thanked: 210 times
Contact:

Post by Rathinagiri »

Hi Esgici,

As you have said, we would discover a helpful module once we write it on our own. :)

Thanks a lot.

However, I am not using txt files to show reports in any of my software and am using grid2print.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
sudip
Posts: 1446
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 5 times
Been thanked: 2 times

Post by sudip »

Hello Rathinagiri,

I also downloaded your showtext program. It's very good. For 'tab' we need to add some codes (I suppose).

BTW, you mentioned Grid2print. I can't find it in HMG. Is it included in HMG or user defined function?

With best regards.

Sudip
With best regards,
Sudip

User avatar
sudip
Posts: 1446
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 5 times
Been thanked: 2 times

Post by sudip »

Hello ESGICI,

Thanks for tFileread. I didn't know it. (Actually there are most of the things in the world which we don't know)

And thank you very much again for simplicity of code.

With best regards.

Sudip
With best regards,
Sudip

User avatar
Rathinagiri
Posts: 5324
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 200 times
Been thanked: 210 times
Contact:

Post by Rathinagiri »

sudip wrote:Hello Rathinagiri,
BTW, you mentioned Grid2print. I can't find it in HMG. Is it included in HMG or user defined function?
Sudip
Hi Sudip,

FYKI Grid2print is an user defined function which is shared here. Please download the latest version and use it.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
sudip
Posts: 1446
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 5 times
Been thanked: 2 times

Post by sudip »

Hi Rathinagiri,

Thank you very much!

The link you mentioned goes to a message, where I read usage and excellent screen shot of your program. But I couldn't find the link to download Grid2Print(). May be I missed it ;( . Can you please tell me where can I download it.

With best regards.

Sudip Bhattacharyya
With best regards,
Sudip

User avatar
Rathinagiri
Posts: 5324
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 200 times
Been thanked: 210 times
Contact:

Post by Rathinagiri »

Ya. It can be downloaded here.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

Post Reply