Newsgroups: comp.sys.atari.programmer From: d...@ritter.demon.co.uk (david knight) Date: 1996/12/29 Subject: TEDINFO I am trying to learn how to program GEM applications in assembler but I'm having trouble finding out what text was entered in editable fields from dialogue boxes. Can anyone help me with this or point me to somewhere that I can get more info on the structure of TEDINFO? (on line preferable as I can't really afford to buy any books on the subject) -- ---------------------------------------------------------------------- ----- d...@ritter.demon.co.uk ---------------------------------------------------------------------- ----- Newsgroups: comp.sys.atari.programmer From: rdupuy5...@aol.com (RDupuy5596) Date: 1996/12/29 Subject: Re: TEDINFO The TEDINFO structure lets a user edit formatted text. The object types G_TEXT, G_BOXTEXT, G_FTEXT, and, G_FBOXTEXT use their ob_spec pointers to point to TEDINFO structures. +----------+------------+-----------+------------+ | te_ptext | +----------+-----------+------------+------------+ | te_ptmplt | +----------+------------+-----------+------------+ | te_pvalid | +----------+------------+-----------+------------+ | te_font | te_resvdl | +----------+------------+-----------+------------+ | te_just | te_color | +----------+------------+-----------+------------+ | te_resvd2 | te_thickness | +----------+------------+-----------+------------+ | te_txtlen | te_tmplen | +----------+------------+-----------+------------+ te_ptext - A POINTER to the actual text. If the first text character is "@", the field is blank, and the application can use any characters for the remainin character posistions in the field. For example, a te_ptext string "@xyzpdq" is seven blank spaces. te_ptmplt - A POINTER to a text string template for any further data entry. The editable portion of the field is represented by underscores. te_pvalid - A POINTER to a text sting containing characters that validate any entered text. 9 - allow only digits 0 - 9 A - allow only uppercase A - Z plus space a - allow upper- and lowercase A- Z, plus space N - allow 0 - 9 and uppercase A- Z, plus space n - allow 0 - 9 upper- and lowercase A- Z, plus space F - allow all valid DOS filename characters, plus ? * : P - allow all valid DOS pathname characters, plus \ : ? * p - allow all valid DOS pathname characters, plus \ : X - allow anything te_font - A WORD identifying the font used to draw the text. 3 - system font: used in menus, dialogs, etc. 5 - small font: used in icons te_resvdl - Reserved for future use te_just - A WORD identifying the type of text justification desired. 0 - left-justified 1 - right justified 2- centered te_color - A WORD identifying the color and pattern of box-type objects. te_resvd2- Reserved for future use te_thickness - A WORD containing the thickness in pixels of the border of the text box. This WORD can have the following values: 00 = no thickness 1 - 128 (positive values) = inside thickness: inward from the object's edge -1 - (-127) (negative values) = outside thickness: outward from the object's edge te_txtlen - A WORD containing the length of the string pointed to by te_ptext. te_tmplen - A WORD containing the length of the string pointed to by te_ptmplt. The following example illustrates how the TEDINFO structure works. - te_ptext is a string of raw data for a date. Its value is "061384". - te_ptmplt, also a sting, is a template that shows how to display the data in te_ptext. Its value is "Enter Date: __/__/__". - te_pvalid is a string of input validation characters. Its value is "999999". - The editable text facility merges all the above data in one sting, "Enter Date: 06/13/84". - If the user types "1004", the string becomes "Enter Date: 10/04/84". - If the user presses the Backspace key after typing "1004", the string become "Enter Date: 10/0_/84". - If te_ptext has no data or not enough data to fill out the template, the unfilled parts of the template show underscores Newsgroups: comp.sys.atari.programmer From: Peter Rottengatter Date: 1996/12/30 Subject: Re: TEDINFO On Sun, 29 Dec 1996, david knight wrote: > I am trying to learn how to program GEM applications in assembler but > I'm having trouble finding out what text was entered in editable > fields from dialogue boxes. > Can anyone help me with this or point me to somewhere that I can get > more info on the structure of TEDINFO? (on line preferable as I can't > really afford to buy any books on the subject) The TEDINFO structure has three entries, te_ptmplt, te_pvalid, and te_ptext, that are responsible for the strings. The te_ptmplt is a template that shows the structure of the edit field, where in fact characters can be edited on the screen. Fixed characters are here, and underscores show where the user can edit a character. The fixed characters are omitted in both te_pvalid and te_ptext, there are places only for the editable characters ! The te_pvalid determines what sort of characters are allowed at the corresponding place. A '9' for instance allows only digits. The te_ptext contains the edited characters. This is the entry which is of most interest here. A good example is what I had the other day when working on STiK : An edit field for an IP address was needed. An IP address is four numbers between 0 and 255, separated by dots. The TEDINFO strings are : te_ptmplt : "IP Address : ___.___.___.___" te_pvalid : "999999999999" te_ptext : "@___________" You'll see the structure from the te_ptmplt. The underscores are the places the cursor may roam about. For each of the underscores there is a character in both te_pvalid and te_ptext : The character in te_pvalid (`9') means only digits are allowed (as numbers are to be entered). The te_ptext holds the finally entered characters. The `@' in the first position of the te_ptext is a trick to have the field cleared and the cursor in the first position when calling form_do, for instance. Now form_do does all the work, and you only need to evaluate the te_ptext string. Cheers Peter --------------------------------------------------------------------- Peter Rottengatter p...@pallas.amp.uni-hannover.de --------------------------------------------------------------------- Newsgroups: comp.sys.atari.programmer From: d...@ritter.demon.co.uk (david knight) Date: 1996/12/31 Subject: Re: TEDINFO In article <19961229210400.QAA18...@ladder01.news.aol.com> rdupuy5...@aol.com (RDupuy5596) wrote:- >te_ptext - A POINTER to the actual text. So let me see if I've got this correct. I'm finding out the address of the te_ptext by using rsrc_gaddr() Is the address returned by doing this the actual address of the text or does the returned address just hold the address of the text? -- ---------------------------------------------------------------------- ----- d...@ritter.demon.co.uk ---------------------------------------------------------------------- ----- Newsgroups: comp.sys.atari.programmer From: rdupuy5...@aol.com (RDupuy5596) Date: 1996/12/31 Subject: Re: TEDINFO I believe the original question was about the structure of TEDINFO and so I copied some information regarding the structure out of a GEM manual that I recently bought, in an attempt to be helpful. I hope someone else can answer your question, because I am just now learning myself. sorry. Newsgroups: comp.sys.atari.programmer From: gmil...@inca.co.nz (Gaven Miller) Date: 1997/01/01 Subject: Re: TEDINFO david knight (d...@ritter.demon.co.uk) wrote: > In article <19961229210400.QAA18...@ladder01.news.aol.com> > rdupuy5...@aol.com (RDupuy5596) wrote:- > >te_ptext - A POINTER to the actual text. > So let me see if I've got this correct. > I'm finding out the address of the te_ptext by using rsrc_gaddr() > Is the address returned by doing this the actual address of the text > or does the returned address just hold the address of the text? Given code of the form: TEDINFO *tip; /* TedInfo Pointer */ rsrc_gaddr( R_TEDINFO, itemnum, &tip ); /* get address of TEDINFO structure associated with TEDINFO #itemnum */ This call is useless, as it (and R_TEPTEXT, R_TEPTMPLT and R_TEPVALID) will not work as they requies the TEDINFO item number within the whole TEDINFO block in the resource file. This itemnum is not returned by most (all?) resource editors I know of. Instead you need to use something of the form: OBJECT *tree; rsrc_gaddr( R_TREE, treenum, &tree ); /* get treee pointer */ tip = (TEDINFO *)tree[itemnum].ob_spec; This will load tip with the address of the TEDINFO structure within that tree. You can then get at the te_pvalid, te_ptext &c via "tip -> te_ptext" &c. -- Quote For The Month: "I wanna buy you some sunglasses - the kind you can see through" Newsgroups: comp.sys.atari.programmer From: d...@ritter.demon.co.uk (david knight) Date: 1997/01/01 Subject: Re: TEDINFO In article <117cd$ef10.294@HERMES> gmil...@inca.co.nz (Gaven Miller) wrote:- >Given code of the form: >TEDINFO *tip; /* TedInfo Pointer */ >rsrc_gaddr( R_TEDINFO, itemnum, &tip ); /* get address of TEDINFO structure > associated with TEDINFO #itemnum */ >This call is useless, as it (and R_TEPTEXT, R_TEPTMPLT and R_TEPVALID) >will not work as they requies the TEDINFO item number within the whole >TEDINFO block in the resource file. This itemnum is not returned by most >(all?) resource editors I know of. >Instead you need to use something of the form: >OBJECT *tree; >rsrc_gaddr( R_TREE, treenum, &tree ); /* get treee pointer */ >tip = (TEDINFO *)tree[itemnum].ob_spec; >This will load tip with the address of the TEDINFO structure within that >tree. >You can then get at the te_pvalid, te_ptext &c via "tip -> te_ptext" &c. Thanks for the C code for this but unfortunately (as I stated in the original posting) I'm using assembler and I do not know enough C to work out what is happening in the above. -- ---------------------------------------------------------------------- ----- d...@ritter.demon.co.uk ---------------------------------------------------------------------- ----- Newsgroups: comp.sys.atari.programmer From: g...@swampdog.demon.co.uk (Guy Harrison) Date: 1997/01/02 Subject: Re: TEDINFO In article <35932880_000008_OASIS_N...@ritter.demon.co.uk> d...@ritter.demon.co.uk (david knight) said:- > In article <19961229210400.QAA18...@ladder01.news.aol.com> > rdupuy5...@aol.com (RDupuy5596) wrote:- >>te_ptext - A POINTER to the actual text. >So let me see if I've got this correct. >I'm finding out the address of the te_ptext by using rsrc_gaddr() >Is the address returned by doing this the actual address of the text >or does the returned address just hold the address of the text? I dunno if it's the call itself or just my compiler binding but I've found most of the rsrc_gaddr() options do not work correctly. Thus, all I tend to use is R_TREE and some macros. If you do it the same way then ... #define TePtext(ob,x) ((TEDINFO*)ob[x].ob_spec)->te_ptext OBJECT *ob; char *p; rsrc_gaddr(R_TREE,tree_idx,&ob); p = TePtext(ob,obi); __ Guy Harrison Email g...@swampdog.demon.co.uk swamp...@dial.pipex.com Web http://www.swampdog.demon.co.uk/index.html Newsgroups: comp.sys.atari.programmer From: g...@swampdog.demon.co.uk (Guy Harrison) Date: 1997/01/02 Subject: Re: TEDINFO In article <43511354_000008_OASIS_N...@ritter.demon.co.uk> d...@ritter.demon.co.uk (david knight) said:- > In article <117cd$ef10.294@HERMES> > gmil...@inca.co.nz (Gaven Miller) wrote:- >>Given code of the form: >>TEDINFO *tip; /* TedInfo Pointer */ >>rsrc_gaddr( R_TEDINFO, itemnum, &tip ); /* get address of TEDINFO structure >> associated with TEDINFO #itemnum */ >>This call is useless, as it (and R_TEPTEXT, R_TEPTMPLT and R_TEPVALID) >>will not work as they requies the TEDINFO item number within the whole >>TEDINFO block in the resource file. This itemnum is not returned by most >>(all?) resource editors I know of. >>Instead you need to use something of the form: >>OBJECT *tree; >>rsrc_gaddr( R_TREE, treenum, &tree ); /* get treee pointer */ >>tip = (TEDINFO *)tree[itemnum].ob_spec; >>This will load tip with the address of the TEDINFO structure within that >>tree. >>You can then get at the te_pvalid, te_ptext &c via "tip -> te_ptext" &c. >Thanks for the C code for this but unfortunately (as I stated in the >original posting) I'm using assembler and I do not know enough C to >work out what is happening in the above. Once you've got the tree address , index into the OBJECT array ... p = tree + (itemnum * sizeof(OBJECT)); ^^^^^^^^^^^^^ 24 bytes iirc Now add the ob_spec offset ... p = p + 12 and fetch the TEDINFO structure address ... p = *p /* ie something like move.l (a0),a0 */ Now you can access any of the TEDINFO members by adding the desired offset. The te_ptext offset is zero so a move.l (a0),d0 will leave you with the address of its nul terminated string in d0. As my assember knowledge is pretty vague here's another example in case I've screwed up the above ... Fetch TEDINFO address for object item 5 say, p = ob[5].ob_spec ... p = ob + (5 * 24) + 12 move.l (p),te_ptext __ Guy Harrison Email g...@swampdog.demon.co.uk swamp...@dial.pipex.com Web http://www.swampdog.demon.co.uk/index.html Newsgroups: comp.sys.atari.programmer From: Peter Rottengatter Date: 1997/01/02 Subject: Re: TEDINFO On Tue, 31 Dec 1996, david knight wrote: > In article <19961229210400.QAA18...@ladder01.news.aol.com> > rdupuy5...@aol.com (RDupuy5596) wrote:- > >te_ptext - A POINTER to the actual text. > So let me see if I've got this correct. > I'm finding out the address of the te_ptext by using rsrc_gaddr() > Is the address returned by doing this the actual address of the text > or does the returned address just hold the address of the text? It depends. With rsrc_gaddr you find the address of a specified structure, but you need it's index in the corresponding array. For TEDINFO you'll rarely have it. I normally use the following sequence of lines to get the address of the te_ptext : OBJECT *tree; TEDINFO *ted; char *ptext_ptr; rsrc_gaddr (R_TREE, MY_TREE, & tree); ted = tree[MY_TED].ob_spec.tedinfo; /* this is Pure C */ /* ted = (TEDINFO *) tree[MY_TED].ob_spec; should almost always work */ ptext_ptr = ted->te_ptext; The first line gives you the address of the root object of the object tree, the name of which is assumed here MY_TREE, and which is specified inside your resource construction set. From that address, using the index of your TEDINFO object MY_TED, again set in the resource construction set, the address of the TEDINFO structure is gained. Note that this notation depends on how your compiler defines the OBJECT structure. You may need to use the notation commented out. Using the address of the TEDINFO you immediately have the te_ptext, as well as any other component of the TEDINFO, like te_pvalid, te_ptmplt, etc. Cheers Peter --------------------------------------------------------------------- Peter Rottengatter p...@pallas.amp.uni-hannover.de --------------------------------------------------------------------- Newsgroups: comp.sys.atari.programmer From: d...@ritter.demon.co.uk (david knight) Date: 1997/01/02 Subject: Re: TEDINFO Thanks to everyone who has helped me on this. I have now managed to read the text from the te_ptext. One point however. Someone mentioned that putting '@' at the start of the field resets the cursor to the start of the field. I have found that this works fine under normal TOS but under Magic (on my falcon and Magic PC for that matter) it doesn't seem to work. The solution to this appears to be to put a null at the start of the field instead of @. Is there any reason why I shouldn't do this? -- ---------------------------------------------------------------------- ----- d...@ritter.demon.co.uk ---------------------------------------------------------------------- ----- Newsgroups: comp.sys.atari.programmer From: JRich...@nest.demon.co.uk (John Richardson) Date: 1997/01/03 Subject: TEDINFO Dave, > Can anyone help me with this or point me to somewhere that I can get > more info on the structure of TEDINFO? (on line preferable as I can't > really afford to buy any books on the subject) Ok the start of the TEDINFO structure is pointed to by the OBJECT.ob_spec field of the object structure, the text of the actual object (the edited) text is pointed to by the TEDINFO.te_ptext field. Below is a macro I wrote many moons ago to calculate the start address of the TEDINFO structure of an object. Field \1 contains the address the resource tree and field \2 contains the address of the object. a5 will then contain the address of the TEDINFO structure. Because TEDINFO.te_ptext field is at the top of the structure to read the text all you have to do is - move.l (a5),a5 - and then copy from the address stored in a5. Example shown below. To find other information fron the TEDINFO structure reference the the table shown below. ;---- ;tedinfo_str macro ;Calculates address of tedinfo structure! ;---- tedinfo_str macro move.l \1,a5 add.l #(\2*24)+12,a5 move.l (a5),a5 endm get_text: tedinfo_str dial_addr,obj move.l (a5),a5 lea string,a4 loop tst.b (a5) * tst for null beq .done move.b (a5)+,(a4)+ bra .loop done move.b #0,(a4) * add null ; a similar method maybe used to write text to the dialogue field. TEDINFO: te_ptext: ds.l 1 ; Pointer to text te_ptmplt: ds.l 1 ; Pointer to template te_pvalid: ds.l 1 ; Pointer to string containing valid chars. te_font: ds.w 1 ; Font used, 3=sys font, 5=small font. te_junk1: ds.w 1 ; reserved te_just: ds.w 1 ; text justification, 0=left,1=right,2=centre te_color: ds.w 1 ; object colour and pattern te_junk2: ds.w 1 ; reserved te_thick: ds.w 1 ; border thickness te_txtlen: ds.w 1 ; length of te_ptext (inc. NULL) te_tmplen: ds.w 1 ; length of te_ptmplt (inc. NULL) Hope you find this information useful. Jr, -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Via the Net2Net NeST gateway - 90:100/999 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Newsgroups: comp.sys.atari.programmer From: Peter Rottengatter Date: 1997/01/03 Subject: Re: TEDINFO On Thu, 2 Jan 1997, david knight wrote: > Thanks to everyone who has helped me on this. I have now managed to > read the text from the te_ptext. > One point however. > Someone mentioned that putting '@' at the start of the field resets > the cursor to the start of the field. > I have found that this works fine under normal TOS but under Magic (on > my falcon and Magic PC for that matter) it doesn't seem to work. > The solution to this appears to be to put a null at the start of the > field instead of @. Is there any reason why I shouldn't do this? Doesn't cause harm. However one of the many bugs with normal TOS leads to the situation that an edit field filled with underscores is shown, which is the same as an empty field but the cursor is at the end. I use MagiC too, and I'm pretty sure I used the trick and it worked under MagiC ... Cheers Peter --------------------------------------------------------------------- Peter Rottengatter p...@pallas.amp.uni-hannover.de --------------------------------------------------------------------- Newsgroups: comp.sys.atari.programmer From: g...@swampdog.demon.co.uk (Guy Harrison) Date: 1997/01/04 Subject: Re: TEDINFO In article <28431808_000008_OASIS_N...@ritter.demon.co.uk> d...@ritter.demon.co.uk (david knight) said:- >Thanks to everyone who has helped me on this. I have now managed to >read the text from the te_ptext. >One point however. >Someone mentioned that putting '@' at the start of the field resets >the cursor to the start of the field. >I have found that this works fine under normal TOS but under Magic (on >my falcon and Magic PC for that matter) it doesn't seem to work. >The solution to this appears to be to put a null at the start of the >field instead of @. Is there any reason why I shouldn't do this? None at all as far as I know. My own library routines walk the trees and replace the '@' with NUL on startup and I've had no complaints! __ Guy Harrison Email g...@swampdog.demon.co.uk swamp...@dial.pipex.com Web http://www.swampdog.demon.co.uk/index.html Newsgroups: comp.sys.atari.programmer From: "Alastair J. Houghton" Date: 1997/01/06 Subject: Re: TEDINFO The rsrc_gaddr() function *does* work entirely as specified in the GEM documentation - that is, it will find any of the specified objects in a resource file, given that you have their index. As I don't have the article that started this thread, I can only guess that what you want to do is change the te_ptext field of the TEDINFO structure. The TEDINFO structure may be found by: (TEDINFO *)(tree[obj].ob_spec) This may then be dereferenced to obtain the te_ptext field: ((TEDINFO *)(tree[obj].ob_spec))->te_ptext te_ptext is simply a pointer to a C-style string, and may be altered or manipulated as you see fit. I seem to recall that there may be a text length field in the TEDINFO structure... but I can't quite remember (my documentation is in my hall of residence, and I'm sitting at a Sun Sparc machine typing this). ____________________________________________________________ Alastair Houghton a...@ic.ac.uk Imperial College, London .