Board index » delphi » I'm having trouble with easy problems...

I'm having trouble with easy problems...

  Ok,  here are a couple of seemingly easy questions that I am having
a hell of a time figuring out...  (e-mail me if possible, o.k. if
not.)
_______________
1)      How do you send a print job to a specific server and queue?
For example,  I want to print to
Server:  Sales
Queue:  NJOffice

2)      How would you go about having a main form with an open
database that spawns a thread which utilizes a TQuery object within
that thread?  For example:  I have fMain which has a Timer that waits
for 3 minutes and then checks the contents of a SQL statement through
the Tquery object,  problem is that it must spawn a thread and execute
the SQL statement there.

3)      My program is to be run in a Windows NT environment.  It will
have to run a DOS program to manipulate some data.  That DOS program
takes two files and returns one file that contains the modified data.
How do I go about running this program?  I cannot rewrite the DOS
program if that is the answer.  Worst still...  can I run it without
the neccessity of a form?

4)      I created a thread that is run from the main form and utilizes
some of the information from the main form.  This thread then creates
some other forms which will also need variables from the main form.
Should I just pass the variable names and data to the thread and have
the thread-created forms list only the thread in the uses clause or is
it safe enough to have the main form in the thread-created forms uses
clause.

     Thanks for anyone who had the patience to read through all that
and a special thanks in advance to anyone who takes the time to answer
them,
         Finsta.

 

Re:I'm having trouble with easy problems...


Quote
In article <35d11ef6.3362...@NEWS.NDI.NET>, fin...@netscape.net writes:
>1)  How do you send a print job to a specific server and queue?
>For example,  I want to print to
>Server:  Sales
>Queue:  NJOffice

I think we're going to take these questions on at a time (if you hit the NG
with all these at once you might find _none_ of them are answered anyway).
Since I'm the first to answer, by all appearances, I'll claim the privilege of
answering what seems to be the easiest question! Perhaps you can respond with
the next question and confirmation of success upon receiving a successful
response...

1. Printers are identified by name rather than server so
if the printer you wanted were called NJPrinter you could say:

Printer.PrinterIndex := Printers.IndexOf('NJPrinter:')

Careful - these names seem to all end in colons

Charles Johnson

btw - sorry - don't know about queue management

Re:I'm having trouble with easy problems...


Quote
> 3) My program is to be run in a Windows NT environment.  It will
> have to run a DOS program to manipulate some data.  That DOS program
> takes two files and returns one file that contains the modified data.
> How do I go about running this program?  I cannot rewrite the DOS
> program if that is the answer.  Worst still...  can I run it without
> the neccessity of a form?

You might try ExecuteFile, which is in the FMXUtils unit, or the win API
function ShellExecute (need to look up the particulars of the parameters).
I am not sure how this will handle your DOS program in NT, but maybe it will
help.

As far as developing without a form, you can create a console application -
open a new app (or open Delphi), close the form1, close the Unit1 (don't save
anything) and open the Application source (view/project source).

From here you can write your application, starting from the main program
block, like any non-windows app.  When you are finished, you can compile with
the linker (found in project/options) set to generate a console app, or you
can write the APPTYPE directive at the top of the program.

for example:

{$APPTYPE CONSOLE}

program Project1;

uses
  Forms;

{$R *.RES}

begin
     writeln('hit any key to continue');
     readln;
end.

I removed the Application.Initialize and Application.Run lines (not really
sure what leaving them in would do.)

Hope this helps

Stephen Carpenter
Application Developer
iMarket Inc
Waltham, MA

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

Re:I'm having trouble with easy problems...


Quote
In article <6r256m$hg...@nnrp1.dejanews.com>, emuls...@my-dejanews.com writes:
>> 3)     My program is to be run in a Windows NT environment.  It will
>> have to run a DOS program to manipulate some data.  That DOS program
>> takes two files and returns one file that contains the modified data.
>> How do I go about running this program?  I cannot rewrite the DOS
>> program if that is the answer.  Worst still...  can I run it without
>> the neccessity of a form?

ShellExecute(Handle,'open','DOSApp.exe','Filename1 Filename2',SW_HIDE);
Memo1.Lines.LoadFromFile(DOSAPPOutputFile.txt);

Charles Johnson

Other Threads