2  Interesting QA from various newsgroups
unsorted, uncommented, simply copied from NG - mails (without written permission of the authors)


last updated: Apr-02-1998   index 1QA


   Subject: Re: CR4 Register
      Date: Tue, 24 Mar 1998 02:38:05 -0600
      From: Robert AH Prins <prinsra@wcg.co.uk>
Organization: Deja News - The Leader in Internet Discussion
 Newsgroups: borland.public.turbopascal, comp.lang.pascal.misc, de.comp.lang.pascal.misc, fido.ger.pascal

In article <6f1ci9$gje$1@unlisys.unlisys.net>,
  "Sven Bergemann" <sven.bergemann@berlin.snafu.de> wrote:
>
> Hi Leute,
> wer kann mir ein Programmlisting geben/ schreiben, welches das CR4-Register
> unter BP 7.0 in einem Assemblerblock ausliest und anzeigt ?
> Danke im Voraus,
> Bye
>         Sven

Versuch es mal mit:   try it with

asm
  db $0F,$20,$E0 {mov eax, cr4}
end;

asm
  db $0F,$22,$E0 {mov cr4, eax}
end;

HTH,

Robert
--
Robert AH Prins
prinsra@wcg.co.uk



   Subject: LFNs unter Pascal?  Long Filenames in Pascal
      Date: 25 Mar 1998 13:51:38 GMT
      From: ab@voltage.saar.de (Andreas Bauer)
 Newsgroups: de.comp.lang.pascal.misc

Matthias Bauer <moeffju@mfju.handshake.de> wrote:

> Nun zwei Fragen:
>
>   1) Hat jemand eine Beschreibung des LFN-Systems als Text oder in PAS-
> Source?

$ cat dostools.pas

[...]

TYPE PExtFilerec=^TExtFilerec;
     TExtFilerec=record
        eFlags         :Longint;               (* DWORD *)
        eCreationTime  :array[0..7] of byte;   (* QWORD *)
        eLastAccessTime:array[0..7] of byte;   (* QWORD *)
        eLastChangeTime:array[0..7] of byte;   (* QWORD *)
        eFilesizeHi    :Longint;               (* QWORD-LO *)
        eFilesizeLo    :Longint;               (* QWORD-HI *)
        eReserved      :array[0..7] of byte;   (* QWORD *)
        eLongname      :array[0..259] of char; (* ASCIIZ *)
        eShortname     :array[0..13] of char;  (* ASCIIZ *)
     end;

[...]

(*** überprüft, ob Windows95 läuft   checks if Win95 is running *)
Function IsWindows95:boolean; assembler;
ASM
   PUSH DS
   PUSH BP
   MOV AX,0352Fh
   INT 021h
   OR BX,BX
   JNZ @handler_installed
   MOV BX,ES
   OR BX,BX
   JNZ @handler_installed
   JMP @nowin95
@handler_installed:
   MOV AX,01600h
   INT 02Fh
   OR AL,AL
   JZ @nowin95
   CMP AL,080h
   JAE @nowin95
   CMP AL,4
   JB @nowin95
   MOV AX,1
   JMP @Ende
@nowin95:
   XOR AX,AX
@Ende:
   POP BP
   POP DS
END;

[...]

(*** ermittelt zu einem Shortname einen langen Dateinamen *)
(* establish a long filename from a shortname *)
Procedure GetLongFilename(VAR glfName:String); assembler;
VAR glfFilesearchRecord:TExtFilerec;
ASM

   PUSH DS
   LDS SI,[glfName]
   XOR BX,BX
   MOV BL,DS:[SI]
   OR BL,BL
   JZ @ende
   INC SI
   XOR AL,AL
   MOV DS:[SI+BX],AL
   MOV DX,SI
   XOR SI,SI
   MOV AX,0714Eh
   MOV CX,55
   PUSH SS
   POP ES
   LEA DI,[glfFilesearchRecord]
   INT 021h
   JC @nothingclear
   MOV BX,AX
   MOV AX,071A1h
   INT 021h
   PUSH SS
   POP ES
   LEA DI,[glfFilesearchRecord]
   ADD DI,44
   LDS SI,[glfName]
   MOV BX,SI
   MOV CL,1
@copyloop:
   INC SI
   MOV AL,ES:[DI]
   OR AL,AL
   JZ @storelength
   MOV DS:[SI],AL
   INC DI
   INC CL
   JNZ @copyloop
@storelength:
   DEC CL
   MOV SI,BX
   MOV DS:[SI],CL
   JMP @ende
@nothingclear:
   LES DI,[glfName]
   XOR AX,AX
   MOV ES:[DI],AL
@ende:
   POP DS
END;

>   2) Funktioniert das auch im Plain-DOS, d.h. DOS-Modus von DOS 7.x

Nein. Das kann z.B. plain-Linux.

tschau,
       Andreas



   Subject: Re: TJpegImage and TFileStream:many images (Delphi)
      Date: Sat, 28 Mar 1998 10:08:17 +0200
      From: seppo sarlos <sarlos@sci.fi>
 Organization: verde arctico oy
 Newsgroups: borland.public.delphi.graphics

thanks Nick for anwering!
the stream to read is type TFileStream.

there is a simple test program on my home page
http://www.sci.fi/~sarlos. There two jpeg-images are first transfered
from file to memory using TJpegImage.loadFromFile (works well), written
to a new stream using TJpegImage.SaveToStream(both images seem to go to
the stream , at least the stream size grows logically), but when the
program  reads the stream back with TJpegImage.loadFromStream, the first
image is transfered ok and is visible. But the second image is not
transfered with a second call to TJpegImage.loadFromStream (no error
message in this method), the stream is positioned to the end of stream,
not to the beginning of the second image.
In short the writing is done like this:
  fileStream1:=TFileStream.create('logostream',fmCreate or
fmShareDenyNone);
  try
     jpegImage1.SaveToStream(fileStream1);
     jpegImage2.SaveToStream(fileStream1);
     finally
     fileStream1.Free;

and the reading like this:

  fileStream1:=TFileStream.create('logostream',fmOpenRead or
fmShareDenyNone);
    try
     jpegImage1.loadFromStream(fileStream1);
     jpegImage2.loadFromStream(fileStream1);
     try // the  error message is got  inside this try**************
        BitMap1.assign(jpegImage1);
        image1.Picture.Assign(BitMap1);//
        showMessage('image1 should be seen (and it is seen...)');
        BitMap2.assign(jpegImage2); //here we have 'jpeg error #41'
        image2.Picture.Assign(BitMap2);
        showMessage('image2 should be seen, but it is not! ');
        except on E:Exception do showMessage('bitmap assignment error '+
                  E.message);
        end;//try
      finally
      fileStream1.Free;
 

Nick Hodges (TeamB) wrote:
>
> Seppo --
>
> What is the  nature of the file that you are trying to read?  What
> does the code look like that is not working?
>
> Nick Hodges
> TeamB
--
with kind regards Seppo Sarlos /Verde Arctico Oy  sarlos@sci.fi (remove xxx)



   Subject:  Re: Is a file open ?
      Date: Sun, 29 Mar 1998 10:01:47 +0100
      From: Pedt Scragg <newsmaster@pedt.demon.co.uk>
 Newsgroups: comp.lang.pascal.borland

In article <w6foWAAZrgH1EwxX@johnmatthews.demon.co.uk>, John Matthews
<john@johnmatthews.demon.co.uk> writes
>
>How can I discover if a file is open? Is it possible to know if a text
>file is open for writing or reading?

function  FileIsOpen(var f):boolean;
var fl : text absolute f;
begin
     FileIsOpen := (textrec(fl).mode <> fmclosed);
end;
 

The above will only tell you that the file is open. You can pass file
variables of any type.
 

To check which mode the file is open with, you can use

fmInput : Text File open for reading (Reset)
fmOutput: Text file open for writing (Rewrite or Append)
fmInOut : Anything but a Text File is open.

--
Pedt Scragg                    <newsmaster@pedt.demon.co.uk>



Betreff:        Re. Koch curve
  Datum:        Mon, 30 Mar 1998 19:33:08 +0200
    Von:        Jörg Teubl <friedrich.saurer@kfunigraz.ac.at>
  Firma:        Karl-Franzens-Universitaet Graz, Austria
  Foren:        comp.lang.pascal.borland

Hi Kim

You asked for a Koch source code. Here it is!
If you need help or if you want the source code of other types
(for example Mandelbrot) let me know.
Joerg Teubl
======================================
ATTENTION: My Address is jorg@hehe.com
======================================

program Koch;
{Joerg Teubl}

uses crt,graph;

var treiber,modus  : integer;
    grad           : real;

procedure zeichnen(grad: real;s:integer);
var h,v :word;
begin
 h:=round(s*cos(grad));
 v:=round(s*sin(grad));
 linerel(h,v);
end;

procedure Generator(Stufe,s :integer);
begin

if stufe > 0 then
  begin
    generator(stufe-1,s div 3);
    grad:=grad-pi / 3;
    generator(stufe-1,s div 3);
    grad:=grad+(pi/3)*2;
    generator(stufe-1,s div 3);
    grad:=grad-pi/3;
    generator(stufe-1,s div 3);
  end
             else zeichnen(grad,s);
end;

begin
 treiber:=detect;
 initgraph(treiber,modus,'c:\bp\bgi');
 setcolor(0);
 lineto(0,400);
 setcolor(7);
 grad:=0;
 generator(4,650);
 readln;
end.



    Betreff: Re: EBCDIC to Ascii
      Datum: Tue, 31 Mar 1998 07:48:28 -0600
        Von: Robert Henningsgard <rhenn@fastec.com>
      Foren: borland.public.turbopascal

Byron:

Hopefully this will help you with your translation:

function EBCDICtoASCII(EBC : byte) : byte;
type
  TLookupTable = array[byte] of byte;
const
  LookupTable : TLookupTable =
    ($00,$01,$02,$03,$04,$05,$06,$07,$08,$09,$0A,$0B,$0C,$0D,$0E,$0F,
     $10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$1A,$1B,$1C,$1D,$1E,$1F,
     $20,$21,$22,$23,$24,$0A,$26,$27,$28,$29,$2A,$2B,$2C,$2D,$2E,$2F,
     $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$3A,$3B,$3C,$3D,$3E,$3F,
     $20,$41,$42,$43,$44,$45,$46,$47,$48,$49,$4A,$2E,$3C,$28,$2B,$4F,
     $26,$51,$52,$53,$54,$55,$56,$57,$58,$59,$21,$24,$2A,$29,$3B,$5F,
     $2D,$2F,$62,$63,$64,$65,$66,$67,$68,$69,$6A,$6B,$2C,$6D,$3E,$3F,
     $70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$3A,$2A,$40,$60,$3D,$22,
     $80,$61,$62,$63,$64,$65,$66,$67,$68,$69,$8A,$8B,$8C,$8D,$8E,$8F,
     $90,$6A,$6B,$6C,$6D,$6E,$6F,$70,$71,$72,$9A,$9B,$9C,$9D,$9E,$9F,
     $A0,$A1,$73,$74,$75,$76,$77,$78,$79,$7A,$AA,$AB,$AC,$AD,$AE,$AF,
     $B0,$B1,$B2,$B3,$B4,$B5,$B6,$B7,$B8,$B9,$BA,$BB,$BC,$BD,$BE,$BF,
     $C0,$41,$42,$43,$44,$45,$46,$47,$48,$49,$CA,$CB,$CC,$CD,$CE,$CF,
     $D0,$4A,$4B,$4C,$4D,$4E,$4F,$50,$51,$52,$DA,$DB,$DC,$DD,$DE,$DF,
     $E0,$E1,$53,$54,$55,$56,$57,$58,$59,$5A,$EA,$EB,$EC,$ED,$EE,$EF,
     $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$FA,$FB,$FC,$FD,$FE,$FF);
begin
  EBCDICtoASCII := LookupTable[EBC];
end;

Regards, Rob Henningsgard



   Betreff: Re: W95, WNT, not the same display in TImage
     Datum: Tue, 31 Mar 1998 08:30:40 -0600
       Von: Wayne Herbert <wherbert@keymaps.com>
     Foren: borland.public.delphi.graphics

I have discovered that on my machines, it is necessary to include the following
API call to make Win 95 and Win NT behave the same.

I am copying into a bitmap called OutBmp

SetStretchBltMode(OutBmp.Canvas.Handle,COLORONCOLOR);
OutBmp.Canvas.CopyRect(DestRect,InBmp.Canvas,SrcRect);

The parameters for SetStretchBltMode are BLACKONWHITE, WHITEONBLACK, and
COLORONCOLOR.  You will find that if you play with these settings, you can
recreate all your odd looking screens.

PS:  I am assuming you have the same number of bits per pixel under 95 and NT,
else you are dealing with a palette problem!

Valerie Molins wrote:
> I make a program under D3, WNT 4 which put the contain of the clipboard in a
> TImage (stretch=true, center=true), the result is really different under NT
> and under W95, for the image in back and white, the quality is very bad
> under 95!
> Do you know why?
> Thanks in advance > Valérie > VMolins@Orli.fr
--
Wayne Herbert Manager, Computer Products
Key Maps, Inc. 1411 West Alabama Houston, TX  77006
Vox:  713.522.7949 Fax:  713.521.3202 Email:  wherbert@rice.edu
"Why is it only drug dealers and software developers call their clients `users'?"



   Betreff: Re: what exactly causes RTE 163 (sharing violation)?
     Datum: Tue, 31 Mar 1998 18:21:29 +0200
       Von: "Ing. Franz Glaser" <office@meg-glaser.biz>
     Foren: comp.lang.pascal.borland

Bernd Heutling schrieb:
>
> Hi all,
>
> lately I converted a program so that it writes a log-file to a
> server directory. So, I am able to read this log-file from another
> client and get an impression on the internal behaviour of my program.
>
> Under not repeatable circumstances (since I don't know them) the
> computer
> hangs after causing an run-timer-error 163 which indicates a sharing
> violation if remember it right.
>
> What I want to know is under which circumstances a sharing violation
> (rte 163) is caused (by the way: share.exe was loaded).
>
> Thanx in advance.
>
> Bernd Heutling
>
> P.S.: Would you be so kind to answer by EMail as well? Thank you.

As long as the file is open for writing (textfile!) it cannot be read by
another user. I modified some inner code in my src to make that
possible, but it is not suggested for common use.

There is a solution, but it has some disadvantages. You can
Flush(T) as often as possible,
then copy the file with YOUR program to a second one in "binary form",
i.e. with BlockR/W. Set the FileMode variable to $42 when you open the
second file. Note that it is not good to open the second file any time
with Rewrite, but with Reset(F,1); else Filemode would not work
properly. If it could happen that the file is shortened, you will have
to write some EOF mark at the end. I do not remember a system command in
Pascal to shorten a binfile.

The other program shall open the file with $40 (Read only mode).

But I sometimes had the problem that my own file could not be opened
twice, in this case you need a "duplicate handle" trick. I said above,
that it is not easy.

The MOST easy way is: write strings only to the file in binary form, so
you have not the benefits of the Write(T,xxx:nn) features, but you can
open the file in $42 filemode and use it in the network.

  BlockWrite(F,S[1],length(S),HaveRead));

http://geo.meg-glaser.at/tp.html

Regards, Franz Glaser, Austria http://www.meg-glaser.biz



   Betreff: Re: video + delphi
     Datum: Tue, 31 Mar 1998 22:33:40 +0200
       Von: "Ing. Franz Glaser" <office@meg-glaser.biz>
     Foren: comp.lang.pascal.delphi.misc

Juergen schrieb:
> Hallo,
> is there anybody who knows, how to show a video screen with the
> hauppauge win TV card.
> I want to show the video information in a window, freeze/save a
> grabbed picture and save an avi video film to disk.
> I´m a student and a part of my project is to show in Delphi a video
> information from an external device.
> Thanks for your help
> Regards  J.Sonnemann

http://www.hauppaugue.inter.net/html/service.htm

They support C and Basic only. But this shall not be the biggest problem?

Regards, Franz Glaser http://www.meg-glaser.biz



   Betreff: sort by...
     Datum: Wed, 01 Apr 1998 15:17:05 GMT
       Von: rdonais@southeast.net (R.E.Donais)
     Firma: Southeast Network Services, Inc.
     Foren: comp.lang.pascal.borland

In reference to sorting "Ing. Franz Glaser" <office@meg-glaser.biz> suggested using Turbo Vision and asked --
>... Why not sort the list in the moment of filling?
Sorting a list into a balanced binary tree while loading would provide satisfactory performance.  However, using Turbo Vision to sort while loading implies that the sort would be accomplished by inserting into a tSortedCollection.  Inserting a few items might be
okay, but using tSortedCollection.Insert to sort any appreciable number of records gives very poor performance.  It would be better to append items with AtInsert(Count, ...), then sort the list after all items have been loaded.

Try adding the following method to a tSortedCollection:

Procedure TSortedCollection.QSort;
    Procedure Sort(Lft,Rgt: integer);
    VAR Lo,Hi: integer;
        p    : Pointer;
    Begin
       Lo := Lft; Hi := Rgt;
       p := KeyOf(Items^[(Lft+Rgt) DIV 2]);
       REPEAT
          While Compare(KeyOf(Items^[Lo]), p) < 0 do Lo := Lo + 1;
          While Compare(p, KeyOf(Items^[Hi])) < 0 do Hi := Hi - 1;
          If Lo <= Hi Then
          Begin
             Exchange(Items^[Lo], Items^[Hi], Sizeof(Pointer));
             Lo := Lo + 1; Hi := Hi - 1;
          End;
       UNTIL Lo > Hi;
       If Lft < Hi Then Sort(Lft, Hi);
       If Lo < Rgt Then Sort(Lo, Rgt);
    End;
Begin {quicksort};
    Sort(0, Count-1);
End;

The exchange procedure is defined in the UTIL Unit at http://users.southeast.net/~rdonais/tpascal.htm  You can use it, something similar, or write the code necessary to exchange the two pointers.

I missed the original post, but the title appears to imply that the goal is to have a single list that would have more than one possible sequence that could be selected by the user.  This could be accomplished by adding an integer or enumerated field to a sorted collection to indicate the sorted order.  Keep the default action of having KeyOf return the original item pointer and modify compare, or add a key method that will construct the appropriate key based on the value of the order field.

For example, given a list of marriage records, order 0 could be the original record number sequence, 1 could be date+location, 2 could be location+date, 3 groom's name, 4 bride's name, etc...
    ...red

Addendum Franz Glaser: It shall be possible to TCollection.Insert(P:Pointer) to circumvent the InsertAt(....) to insert unsorted.



   Betreff: Re: extract R/G/B values
     Datum: Wed, 01 Apr 1998 13:49:25 -0600
       Von: Wayne Herbert <wherbert@keymaps.com>
     Foren: borland.public.delphi.graphics

Looks like a color separation to me.  Try the following.  Assume the input
is in InBmp, and your three output images are SRBmp, SGBmp, SBBmp, and are
the same size.

type
  TRGB = array[0..1500] of TRGBTriple;  // define access to the RGB values
  PRGB = ^TRGB;
var
  Row, Col : integer;
  InColor, SRColor, SGColor, SBColor : PRGB;  // create variables for all 4
images
begin
  for Row := 0 to InBmp.Height - 1 do
    begin
    InColor := InBmp.ScanLine[Row];
    for Col := 0 to InBmp.Width - 1 do
      begin
      SRColor[Col].rgbtRed := InColor[Col].rgbtRed;  // do the output red
image
      SRColor[Col].rgbtGreen := 0;
      SRColor[Col].rgbtBlue := 0;
      SGRColor[Col].rgbtRed := 0;  // do the output green image
      SGRColor[Col].rgbtGreen := InColor[Col].rgbtGreen;
      SGRColor[Col].rgbtBlue := 0;
      SBRColor[Col].rgbtRed := 0;  // do the output blue image
      SBRColor[Col].rgbtGreen := 0;
      SBRColor[Col].rgbtBlue := InColor[Col].rgbtBlue;
      end
    end

This writes input red value to the red value of output image 1 and zeros the
green and blue, and then does similar thing for other output images

David Skogvold wrote:

> I need help on extracting some color values.
>
> I have an application with four images, one "original" and three
> sub-images.
> How do I extract the red/green/blue colours from the orig. and put it
> into one of the sub-images?
> E.g.:
>
> A pixel in the original has the RGB value (128, 128, 128)
> I want the according pixel in the "red" image to have the value (128, 0,
> 0)
>
> I know that the "pixel" or "scanline" functions return the color values
> of the pixels in images,
> but how do I remove the two color values I don't need from the RGB
> value?
>
> Any ideas?
--
Wayne Herbert
Manager, Computer Products
Key Maps, Inc. 1411 West Alabama Houston, TX  77006
Vox:  713.522.7949 Fax:  713.521.3202 Email:  wherbert@rice.edu



   Betreff: Re: Internal Format of 16 Bit Bitmaps
     Datum: Wed, 01 Apr 1998 22:33:05 GMT
       Von: timr@probo.com (Tim Roberts)
     Firma: Providenza & Boekelheide, Inc.
     Foren: borland.public.delphi.graphics

David Ullrich <ullrich@math.okstate.edu> wrote:

>Tim Roberts wrote:
>>
>> Well, neither of them are "standard".  Standard DIBs come in 1, 4, 8 and 24
>> bits only.  When Microsoft added the multimedia enhancements for DIBs, they
>> added the 15, 16 and 32-bit formats, but not all display drivers support
>> them.
>
>       Ok. Whether it's "standard" or not the 15-bit thing does seem more
>standard than 16-bit - I haven't had any problems with 15-bit and all sorts
>of weird stuff with 16-bit.
>
>       You may well be right, but I'm curious where your definition of
>"standard" comes from? All I know is what it says in Win32.hlp:

Perhaps "standard" is too strong a word.  Mine is a historical perspective,
and comes from what display drivers are required to support.

When DIBs were introduced, which was in Windows 3.0, the only possible
formats were 1, 4, 8 and 24.  Cards that did 15 and 16-bit modes converted
to 24-bit DIBs.  Windows 3.1 kept this list.  In fact, Visual Basic 3.0 has
a bug in that it does not correctly display bitmaps on all 15 and 16-bit
systems, precisely because it assumes it can create DIBs at whatever depth
the display card is currently running.

When Video For Windows came around, Microsoft introduced a series of DIB
format extensions, including the 15, 16 and 32-bit modes and the compressed
formats like Cinepak and Indeo.  The Windows NT display driver model used
ALL of these, so I guess they're ALL standard on NT.

- Tim Roberts, timr@probo.com  Providenza & Boekelheide, Inc



   Betreff: Re: Focus ListBox.
     Datum: Wed, 1 Apr 1998 17:42:47 -0600
       Von: "Steve Harman" <harmdog@ne.uswest.net>
     Foren: comp.lang.pascal.delphi.misc

Try adding a line:

    ListBox1.Selected[ListBox1.ItemIndex] := TRUE;

Christophe Delancker wrote in message
<3522D4F7.3086@btmaa.bel.alcatel.be>...
>Hey ,
>
>I am having the following problem.
>
>I am scrolling in a ListBox and on an Onclick event I give focus to an
>DbEdit box which is linked to an underlying Database. When I am typing
>something in this DbEdit box I use the OnkeyDown event to detect when
>the VK_RETURN key is pressed. On this event I give the ListBox again
>focus. The problem is that it's not showing the blue horizontal bar from
>the item where I previously clicked on. It's showing a transparant
>horizontal bar with small borders instead.
>
>Help will be welcome ..... Thanx ...
>Regards, Christophe




  tpqa  index    tpqa_1 back   tpqa_3 forward

will be continued. Send me hints to your e-mails if you wish them to be included here...  meg-glaser@eunet.at





Get your own FREE HOMEPAGE