[comp.sys.amiga] Lattice 5.02

chas@gtss.gatech.edu (Charles Cleveland) (02/07/89)

On February 2nd, about half a Megabyte of 5.02 update files in arc form was
posted to the Lattice bulletin board.  Perhaps this means that the mailing
to registered owners of 5.0 is imminent.  If you can't wait and can stand
the phone call, you may want to go for the download.
-- 
-  It is better for civilization to be going down the drain than to be  -
-  coming up it.                                        -- Henry Allen  -
Charles Cleveland  Georgia Tech School of Physics  Atlanta, GA 30332-0430
UUCP: ...!gatech!gtss!chas                INTERNET:  chas@gtss.gatech.edu

sie@fulcrum.bt.co.uk (Simon Raybould) (10/20/89)

When a tool compiled with Lattice C 5.02 is executed from workbench,
It automatically opens an output window. The program then opens a
window with gadgets, menus e.t.c.

Can someone tell me how to tell the startup stuff not to open a default
window. I appreciate that this is probably in the documentation but I
am still wading through that as I only purchased the compiler last week.
I think that a quicker answer will come from an experienced user of 5.02.

If you think that I am using a pirated copy then to prove you wrong, a page
number in the manuals will do (Gnn) e.t.c.

Many thanks,

	SJR

S.J.R

+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-=-=-=-+-=-=-=-=-=-=-=-=-=-=-=-=-=-+
|   Simon Raybould                |  BT Fulcrum   | Are all your pets called  |
|   path : sie@fulcrum.bt.co.uk   |  Birmingham   |      Eric ??? - Python    |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-=-=-=-+-=-=-=-=-=-=-=-=-=-=-=-=-=-+

mwm@eris.berkeley.edu (Mike (I'll think of something yet) Meyer) (10/21/89)

In article <217@masalla.fulcrum.bt.co.uk> sie@fulcrum.bt.co.uk (Simon Raybould) writes:
<When a tool compiled with Lattice C 5.02 is executed from workbench,
<It automatically opens an output window. The program then opens a
<window with gadgets, menus e.t.c.
<
<Can someone tell me how to tell the startup stuff not to open a default
<window.

No, I don't think you're a pirate. That's one of the most asked
questions on the Lattice BBS, and they only get registered users.
Since you're new to Lattice, I'll point out that the BBS is an
_excellent_ resource, and you should use it. Updates, pathces &
work-arounds appear there long before they appear here.

Anyway, in answer to your question, there are two ways to do this.

If you've got a file for BLINK, you specify "DEFINE _main=_tinymain"
in that file. They also claim you can do it on the command line to
BLINK, but I've never tried that. This documented on page L264.

If you want to roll your own, find umain.c in the source tree (I
forget exaclty where), and compile that -dTINY, then link the
resulting .o file in before you c.o. This isn't documented, but is the
way I do things, because I have other changes to that startup code I
want to include much of the time.

For even smaller results, you can change your main routine to _main.
That does away with the all the startup code, including CLI command
line parsing. But look at umain.c yourself.

Side note to Jonas Flygare: have you tried the 5.02 BLINK with 5.04?

	<mike

--
Es brillig war. Die schlichte Toven			Mike Meyer
Wirrten und wimmelten in Waben;				mwm@berkeley.edu
Und aller-mumsige Burggoven				ucbvax!mwm
Die mohmem Rath' ausgraben.				mwm@ucbjade.BITNET

riley@batcomputer.tn.cornell.edu (Daniel S. Riley) (10/21/89)

In article <1989Oct21.032150.23093@agate.berkeley.edu> mwm@eris.berkeley.edu (Mike (I'll think of something yet) Meyer) writes:
>In article <217@masalla.fulcrum.bt.co.uk> sie@fulcrum.bt.co.uk (Simon Raybould) writes:
><Can someone tell me how to tell the startup stuff not to open a default
><window.

>If you've got a file for BLINK, you specify "DEFINE _main=_tinymain"
>in that file. They also claim you can do it on the command line to
>BLINK, but I've never tried that. This is documented on page L264.

That should probably be __main=__tinymain (two underscores instead of
one.  You're replacing the routine _main, and Lattice prepends an
underscore to every routine name, hence __main).  The names may also be 
different if you are using registerized parameters, since Lattice 
prepends an @ instead of an _ when you use them.  If you use one
underscore, I expect that blink would complain about no module
_tinymain and multiple definitions of _main.

If you do this, you do lose several features of the startup code.  No
control-c handler is established for you, and the standard i/o files
(stdin, stdout, stderr) are *not* opened.  You have to open these
yourself (or use lower level/AmigaDOS io calls) if you want to read
or write something to the console window, even if you're running under
a CLI.

>For even smaller results, you can change your main routine to _main.
>That does away with the all the startup code, including CLI command
>line parsing. But look at umain.c yourself.

This is good advice--look at umain.c and see what it does.

>Side note to Jonas Flygare: have you tried the 5.02 BLINK with 5.04?

Gee, I don't even have 5.04 yet.  Sounds like it's time to check my
mailbox.

-Dan Riley (riley@tcgould.tn.cornell.edu, cornell!batcomputer!riley)
-Wilson Lab, Cornell U.

phi@goanna.oz (Philip Hingston) (10/25/89)

In article <217@masalla.fulcrum.bt.co.uk>, sie@fulcrum.bt.co.uk (Simon Raybould) writes:
> When a tool compiled with Lattice C 5.02 is executed from workbench,
> It automatically opens an output window. The program then opens a
> window with gadgets, menus e.t.c.
> 

If you don't need standard input/output, command line parsing etc, call your
main program _main() rather than main(). This will override the provided
_main() which does startup stuff (including opening the window) and then
calls your main().
_main() takes a single argument, a pointer to a string containing the command
line if started from CLI. (You can tell whether you were started from workbench
by examining a structure which is set up for you --- forget the exact name and
type, think it's WBenchMsg.)
If you do need some of the startup stuff, then you can edit and recompile the
source. Think the standard startup is called c.o, with source c.a. Lattice
also provided other flavours of startup for load-and-stay-resident code etc.
Have fun.
							phi

-- 
Philip Hingston, Computer Science,ACSnet: phi@goanna.cs.rmit.oz
R.M.I.T.                          ARPA:   phi%goanna.cs.rmit.oz.au@uunet.uu.net
GPO BOX 2476 V,                   CSNET:  phi%goanna.cs.rmit.oz.au@australia
Melbourne, 3001, AUSTRALIA        UUCP:   ...!uunet!goanna.cs.rmit.oz.au!phi

mxj2361@ultb.UUCP (M.X. Jen) (10/27/89)

	I was toying around with my Amiga, and I was wonder if it would
be possible to mount the Amiga 500 motherboard into a slimline 286 case,
the board will fit inside, but the problem lies with the powersupply, is
it ok for me to hook up the IBM 200 watt powersupply into the mb.  Also
is there an easy way to make the Amiga 500 keyboard detachable. 

-Mike

P.S. Commodore should put out an upgrade to the 500 in a slimline case,
with a beefier p/s and 2 or more 1/2 ht drive bays, and detachable 
keyboard.

sie@fulcrum.bt.co.uk (Simon Raybould) (11/09/89)

First of all many thanks to everyone who replied to my last Lattice
question, it has saved much time. I am now the proud owner of the ROM
kernel ref manual which I am finding completly invaluable.

I am trying to find out the size of a file in lattice C V5.02.
I have found the command to get the modification time and various other
file attributes, but not the file size. What I want to do is find out the
file size, malloc() the memory and read the file in. I can't find the call
to do this in the Lattice docs or the Kernel reference manual. Is there a
DOS library call for this ??

Also being a UK resident user, I have not registered with the Lattice user
group. Am I still able to register and will I recieve updates such as the 5.04
update that is floating around the states ??. I am prepared to pay any 
necessary shipping costs etc.

	Many thanks



+---------------------------------------------------------------------------+
|      #                                            Simon Raybould          |
|     # #    #    #     #     ####     ##                                   |
|    #   #   ##  ##     #    #    #   #  #          B.T.Fulcrum             |
|   #     #  # ## #     #    #       #    #         CS4.2                   |
|   #######  #    #     #    #  ###  ######         Birmingham              |
|   #     #  #    #     #    #    #  #    #                                 |
|   #     #  #    #     #     ####   #    #   path: sie@fulcrum.bt.co.uk    | 
|                                                                           |
+---------------------------------------------------------------------------+

cmcmanis%pepper@Sun.COM (Chuck McManis) (11/10/89)

Simon Raybould writes:
>I am trying to find out the size of a file in lattice C V5.02.
>I have found the command to get the modification time and various other
>file attributes, but not the file size. 

This is UNIX history affecting the Amiga. Actually, there is no such
subroutine. Instead, you simply look at the return value from lseek().
Try this :
		fd = open("some file name", O_RDONLY);
		/* seek to the end of the file */
		size = lseek(fd, 0L, 2);

--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.
"If I were driving a Macintosh, I'd have to stop before I could turn the wheel."

usenet@cps3xx.UUCP (Usenet file owner) (11/10/89)

In article <127655@sun.Eng.Sun.COM> cmcmanis@sun.UUCP (Chuck McManis) writes:
->Simon Raybould writes:
->>I am trying to find out the size of a file in lattice C V5.02.
->>I have found the command to get the modification time and various other
->>file attributes, but not the file size. 
->
->This is UNIX history affecting the Amiga. Actually, there is no such
->subroutine. Instead, you simply look at the return value from lseek().
->Try this :
->		fd = open("some file name", O_RDONLY);
->		/* seek to the end of the file */
->		size = lseek(fd, 0L, 2);

This way can be slooow for big files, especially for floppies.

There is a direct way through DOS to get this info.

	FileLock=Lock(filename);
	Examine(FileLock,&FileInfoBlock);
	size=FileInfoBlock.Length; /* I think, check the includes */

The definitions you need are in
<libraries/dos.h> and <libraries/dosextens.h>

Info about Lock and Examine is in "AmigaDOS Developers Manual".

If you don't have this, I may be able to send the info to you tomorrow.
 Joe Porkka   porkka@frith.egr.msu.edu

cmcmanis%pepper@Sun.COM (Chuck McManis) (11/10/89)

In article <5321@cps3xx.UUCP> porkka@frith.UUCP (Joe Porkka) writes:
>	size=FileInfoBlock.Length; /* I think, check the includes */

Last time I checked the DOS ignored this value but that was some time
ago so it may have been fixed. 

--Chuck
--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.
"If it didn't have bones in it, it wouldn't be crunchy now would it?!"

usenet@cps3xx.UUCP (Usenet file owner) (11/11/89)

In article <127700@sun.Eng.Sun.COM> cmcmanis@sun.UUCP (Chuck McManis) writes:
>In article <5321@cps3xx.UUCP> porkka@frith.UUCP (Joe Porkka) writes:
>>	size=FileInfoBlock.Length; /* I think, check the includes */
>
>Last time I checked the DOS ignored this value but that was some time
>ago so it may have been fixed. 
>
>--Chuck

I use this in HyperHelp to find out how much memory to Alloc.
I this value with debug_flags_on, and it does agree with
what "list" reports.

Here is working and tested (though not complete) example code:

#include <libraries/dos.h>
#include <libraries/dosextens.h>

	struct FileInfoBlock *fileinfo=0;
	struct  Lock *lock=0,*Lock();        /* to get info about the disk */
	long len;

	if( (fileinfo=(struct FileInfoBlock *)AllocMem(sizeof(struct FileInfoBlock),0))==0) {
		goto fail;
	}
	if( (lock=Lock(name,ACCESS_READ))==0) {
		goto fail;
	}
	if(0==Examine(lock,fileinfo)){
		goto fail;
	}
	if(fileinfo->fib_DirEntryType>=0){ /* Is it a regular file? */
		goto fail; /* Nope, must be a directory */
	}

	len = fileinfo->fib_Size;

	if (fileinfo) FreeMem(fileinfo,sizeof(struct FileInfoBlock));
	fileinfo=0;
UnLock(lock);
 Joe Porkka   porkka@frith.egr.msu.edu

mlelstv@immd4.informatik.uni-erlangen.de (Michael van Elst ) (11/20/89)

sie@fulcrum.bt.co.uk (Simon Raybould) writes:

>I am trying to find out the size of a file in lattice C V5.02.

Try a fseek() to the end of your file and call ftell() to give the
position in your file (i.e. the length). This should work with any
implementation of stdio.

				Michael van Elst

E-mail: UUCP: ...uunet!unido!fauern!immd4!mlelstv