[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::amiga_v1

Title:AMIGA NOTES
Notice:Join us in the *NEW* conference - HYDRA::AMIGA_V2
Moderator:HYDRA::MOORE
Created:Sat Apr 26 1986
Last Modified:Wed Feb 05 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:5378
Total number of notes:38326

591.0. "Dynamic Printer Switching???" by KIRK::KYZIVAT (Paul Kyzivat) Mon Jul 13 1987 13:37

    I just picked up a Canon color printer in addition to my existing LA50.
    Since the LA50 uses the serial port and the Canon uses the parallel
    port, I theoretically have access to both printers simultaneously.
    Unfortunately, because of the interaction of PRT: and Preferences, it
    is necessary to go through a lot of hassle just switch back and forth
    serially, and impossible to use both simultaneously.

    Given that most standard sw uses PRT:, it seems unlikely to be
    practical to use both at once, and I don't forsee much need to do so
    anyway.  However I would like to at least be able to easily select
    which is to be used at any particular time without rebooting and
    without going through Preferences.  It appears that preferences updates
    both a file and an in-memory data structure, so what I think I need is
    my own utility to update just the printer portion of the in-memory
    structure.  But where is this documented?  And when can the printer
    info be changed?

	Paul
T.RTitleUserPersonal
Name
DateLines
591.1Intuition ManualELWOOD::WHERRYCyber PunkMon Jul 13 1987 14:208
    	THE RKM Intuition manual published by Addison & Weslley (sp?)
    has a listing of the Preferences data structure in C (struct)...I
    do believe there is some mention of how to access it as well, but
    I am not positive of the accessing part...anybody got the Intuition
    Manual handy??  There should also be a preferences "Include File"
    on a c-compiler disk...
    
    brad
591.2Find a wheel, don't invent oneTLE::RMEYERSRandy MeyersMon Jul 13 1987 14:599
Re: .0

It sounds like you just need to find an Amiga 500 owner who is willing
to upload a file for you.  As is described in note 586.0, the 500 comes
with a program that does what you want.

>:System/InitPrinter
> 
>	Causes printer to abide newly changed Preferences settings.
591.3Piece o' cakeJON::SANTIAGOEd Santiago, LEDEMon Jul 13 1987 17:2611
    Re: .2
    
    Actually I think what that does is tell the printer that there are
    new Preferences values (ie, probably restart the driver). Doesn't
    seem to actually CHANGE them.
    
    Changing printer is really easy - all you need to do is ReadPrefs(),
    toggle the flag for serial/parallel printer, then write it back.
    You don't even have to touch devs/system-configuration. It's all
    documented in the Intuition manual (I think), or any of the Sybex
    books.
591.4No SetPref from IntuitionNAAD::SWARRLearner's PermitMon Jul 13 1987 21:0127
    I took a look in the Intuition Ref Manual. It looks as though you
    can get Preferences but not set them.
    
    Intuition has two documented  calls
    
    	GetPrefs
    
    	GetDefPrefs
    
    In reading the manual It appears that Preferences must be run. Using
    GetPrefs in your own programs would allow newly defined Preferences
    information to be gathered by your programs.
    
    To furhter automate the process, If you are using IDCMP for input,
    you can set the IDCMP flag NEWPREFS and receive and IntiuMessage 
    indicating a change in the Preferences settings.
    
    Using the GetDefPrefs call will get the Prefernces used to initialize
    the system. (I think). I think what they mean is that it will retrieve
    the parameters from disk. Which means that the last "saved" prefernces
    will be retrieved.
    
    Anyway the above is probably moot as users are encouraged to use
    GetPrefs.
    
    <jim
    
591.5JON::SANTIAGOEd Santiago, LEDETue Jul 14 1987 07:433
    No, there is definitely a way to write preferences without running
    Preferences (argh). I've seen it done. I'll try to bring in an example
    tomorrow.
591.6MORRIS::SMCAFEESteve McAfeeTue Jul 14 1987 09:1811
    
    Why don't you just keep two copies of your system-configuration
    file?  One specifying each printer.  A simple execute can swap the two
    files.  Then what you need is a utility to tell the system that you've
    specified a new printer driver.  I believe I saw that there is an
    AmigaDOS command to do this which is being distributed with the new
    A500's.
    
    regards,
    
    steve mcafee
591.7JON::SANTIAGOEd Santiago, LEDETue Jul 14 1987 13:066
    Even if you swap system-configuration files, you still have to load
    them into memory - the change_printer_driver command probably uses
    the preferences structure in memory. Which means you'd have to go
    into Preferences and click "Restore saved settings", or write a
    program to read in a file and set prefs accordingly (there already
    is one, called SetPrefs, probably on the Fish disks).
591.8SetPrefs sounds like what I wantKIRK::KYZIVATPaul KyzivatTue Jul 14 1987 14:1224
    Re: .6

    As noted in .7, this wouldn't help all that much, although it would be
    better than nothing.  But I would like to retain the ability to mung
    the other preference settings (other than printer) without having to
    remember to do them once in each version of the file.

    Re: .7

    I will look for SetPrefs in the Fish disk listings tonite.  If there
    really is such a program (especially if source is available) and
    someone has it, could you upload it?

    In general:

    Am I missing something?  I find huge voids in the documentation,
    particularly around AmigaDos and the Workbench.  The Rom Kernel and
    Intuition are fairly well documented, but if you want to know how
    anything else works, good luck.  I have all four volumes of the A/W
    books and the Bantam AmigaDos (v1) book.  Is there anything else which
    fills in the gaps?  Would the Developer Seminar materials now available
    from C/A be useful?

	Paul
591.9JON::SANTIAGOEd Santiago, LEDETue Jul 14 1987 17:2410
    Buy "Programmer's Guide to the Amiga" by Rob Peck. Sybex books,
    no clue what the ISBN is. I don't have it, but I've perused it
    and it seems very complete. Also, many people swear by it.
    Note: This is *NOT* the same as Eugene P. Mortimore's book,
    also from Sybex.
    
    Since my modem died a month ago, and I can't get one from my
    cost center, I won't be able to upload SetPrefs. I can bring
    a printout if you like (~3 pages), or just type in the important
    parts and email them to you. 
591.10thanksKIRK::KYZIVATPaul KyzivatTue Jul 14 1987 18:369
    Re: .9

    I'll look for the book.

    Before we start typing, maybe someone else has it.  Otherwise, if it is
    on a Fish disk I can get it with a bit of a drive.

	Thanks,
	Paul
591.11Documentation GapsTLE::RMEYERSRandy MeyersTue Jul 14 1987 20:189
>    Am I missing something?  I find huge voids in the documentation,
>    particularly around AmigaDos and the Workbench.  The Rom Kernel and
>    Intuition are fairly well documented, but if you want to know how
>    anything else works, good luck.

What specific gaps in the documentation have you found regarding the
Workbench and AmigaDOS?  I have so far been able to find just about
anything (that I wanted to know at least) if I poked around in the
documentation enough.
591.12JON::SANTIAGOEd Santiago, LEDEWed Jul 15 1987 07:5112
    Hoo boy, this is hilarious... the SetPrefs() function is,
    yes you guessed it, undocumented. Not too atypical, I guess!
    
    Anyway for those interested the format is:
    
    		SetPrefs(preference_structure, PREF_SIZE, 1L)
    
    which is the same as the GetPrefs() call except for the 1.
    
    I also have the source to SetPrefs (the program) for anyone
    interested, but it really is quite run-of-the-mill apart
    from the SetPrefs() call.
591.13why must they keep secrets?KIRK::KYZIVATPaul KyzivatWed Jul 15 1987 10:2921
    Re: .11

    Reply .12 is an example.  Another example is the whole process of how
    all the junk in an icon is used to start a program - I find pieces of
    this but not a coherent explanation.  I would not be at all surprised
    to learn that the information I am looking for is in the documents I
    have somewhere, but it certainly isn't obvious where, short of reading
    all the manuals cover to cover, which I haven't done.

    Re: .12

    Then SetPrefs() is a supplied function that the linker can find?
    Exactly what does it do: 
    1) update an in-memory copy?
    2) update the disk copy?
    3) update the affected components, like workbench screen colors?

    In any case, thanks for the info.  That may be enough for me to do what
    I want.

	Paul
591.14JON::SANTIAGOEd Santiago, LEDEWed Jul 15 1987 13:349
    Since this C code compiles, I assume the linker is able to
    find SetPrefs().
    
    Probably what you want to do is read the Preferences structure
    (with GetPrefs(), *not* GetDefPrefs()), toggle the PrinterPort
    field (SERIAL_PRINTER or PARALLEL_PRINTER), then do SetPrefs().
    This will use the current Preferences settings and only modify
    the printer type. Reading the documentation for GetPrefs()
    should explain more clearly.
591.15GetPrefs won't linkKIRK::KYZIVATPaul KyzivatMon Jul 20 1987 18:2313
    I think I must be missing something obvious here, but ...

    As an experiment I just coded up a little routine to call GetPrefs and
    print out some things from the returned structure.  But I can't get it
    to link - the linker has an unsatisfied reference to _IntuitionBase.

    This reference is not coming from my routine, it is in GetPrefs itself.
    I have the feeling that this isn't supposed to be an external reference
    at all, but I am not sure of this.  Is there someplace I should be
    searching to get this reference satisfied?  I find it hard to believe I
    am supposed to define an external with that name.

	Paul
591.16JON::SANTIAGOEd Santiago, LEDETue Jul 21 1987 07:489
    Try declaring a global:
    
    	struct IntuitionBase *Intuitionbase;
    
    and in your initialization coed, er, code:
    
    	IntuitionBase = OpenLibrary("intuition.library",<rev #, or NULL>);
    
    (and of course making sure you don't get NULL in return).
591.17Thanks - that did itKIRK::KYZIVATPaul KyzivatWed Jul 22 1987 09:288
    re: .16

    That did the trick.  One more black mark for the documentation.
    I was able to get GetPrefs and SetPrefs to do their thing, though so
    far only in a test program.  SetPrefs takes effect immediately - at
    least color changes do.

	Paul
591.18I wonder???NAAD::SWARRLearner&#039;s PermitWed Jul 22 1987 21:144
    That makes me wonder if there is a SetDefPrefs to match the
    GetDefPrefs?

    <jim	z    {
591.19SetPrefs() documentationTLE::RMEYERSRandy MeyersSun Aug 02 1987 20:0453
Re: .12

What follows is the official SetPrefs documentation from Commodore.

The reason why this function wasn't documented was do to an error in
commenting.  The function descriptions in the Addison-Wesley manuals
are automatically extracted from the source files.  A handful of
functions had mangled function headers, and were not extracted by
the program that built the Addison-Wesley manuals.

intuition.library/SetPrefs                           intuition.library/SetPrefs

    NAME
        SetPrefs  -�  Set Intuition Preferences.

    SYNOPSIS
        Prefs = SetPrefs(PrefBuffer, Size, Inform)
        D0               A0          D0    D1

        struct Preferences *Prefs;
        struct Preferences *PrefBuffer;
        int    Size;
        BOOL   Inform;

    FUNCTION
        Sets new Preferences values.  Copies the first 'Size' bytes
        from your Preferences buffer to the system Preferences table,
        and puts them into effect.

        The 'Inform' parameter, if TRUE, indicates that a NEWPREFS
        message is to be sent to all Windows that have the NEWPREFS
        IDCMPFlag set.
   
        It is legal to set a partial copy of the Preferences structure.
        The most frequently changed values are grouped at the beginning
        of the Preferences structure.

    INPUTS
        PrefBuffer = pointer to the memory buffer which contains your
            desired settings for Intuition Preferences
        Size = the number of bytes in your PrefBuffer, the number of bytes
           you want copied to the system's internal Preference settings
        Inform = whether you want the information of a new Preferences
            setting propagated to all windows.

    RESULT
        Returns your parameter PrefBuffer.

    BUGS

    SEE ALSO
        GetDefPrefs(), GetPrefs()