Changes

Jump to: navigation, search

BIO Functions oop344 20111

2,262 bytes added, 10:09, 17 February 2011
int bio_flag(..........)
== Due date ==
=== Simple Functions ===
* Simple bio functions due on Mon Jan 31 23:59Wed Feb 2nd
** Create directories under branches named as your learn id.
** Branch trunk into your branches/learnID directory and start working.
=== complex Functions ===
* Complex io functions: due on ??Wed, Feb 16th 23:59.
== Tester Program and demo ==
* R0.91:
*:[svn://zenit.senecac.on.ca/oop344/trunk/Testers/biotestR0_2.c svn://zenit.senecac.on.ca/oop344/trunk/Testers/biotestR0_2.c]
===Demo===
On Matrix login and:
<big><pre>
$ ~fardad.soleimanloo/biotest
</pre></big>
 
===Bugs===
===DemoFixes===- R0.91 added IsTextEditor and Readonly Selection to test 10 upon asotoude's (irc nick) request- R0.911 fixed line 264, <pre>if(key != F5_KEY & key != F6_KEY)</pre> to <pre>if(key != F5_KEY && key != F6_KEY)</pre>
== File Names ==
You must use platform-specific and <u>unique non-ASCII</u> values for the keys, and then you must use these specific symbolic names in your definitions.
 
'''''Mac OS X Key-Codes'''''
* #define '''UP_KEY''' 259
* #define ''' DOWN_KEY''' 258
* #define ''' LEFT_KEY''' 260
* #define ''' RIGHT_KEY''' 261
* #define ''' PGUP_KEY''' 6 ''/* Control + f */''
* #define ''' PGDN_KEY''' 2 ''/* Control + b */''
* #define ''' ENTER_KEY''' 10
* #define ''' TAB_KEY'''
* #define ''' BACKSPACE_KEY''' 127
* #define ''' DEL_KEY''' 330 ''/* FN + Delete */''
* #define ''' HOME_KEY''' 1 ''/* Control + a */''
* #define ''' END_KEY''' 5 ''/* Control + e */''
* #define ''' ESCAPE_KEY''' 27
* #define ''' INSERT_KEY''' 16 ''/* Control + p*/''
* #define ''' SPACE_KEY''' 32
 
''FN + ALT + Function Keys with Mac Special Function Key Setup''
 
''ALT + Function Keys as Standard Function Keys Setup''
 
* #define ''' F1_KEY''' 270
* #define ''' F2_KEY''' 271
* #define ''' F3_KEY''' 272
* #define ''' F4_KEY''' 273
* #define ''' F5_KEY''' 274
* #define ''' F6_KEY''' 275
* #define ''' F7_KEY''' 276
* #define ''' F8_KEY''' 277
* #define ''' F9_KEY''' 278
* #define ''' F10_KEY''' 279
* #define ''' F11_KEY''' 280
* #define ''' F12_KEY''' 281
=== void bio_curpos(int r, int c) ===
== Complex Functions (Platform independent functions) ==
=== void bio_display(const char* str, int row, int col, unsigned int len) ===
Outputs the null-terminated string pointed to by "str" on the screen starting at row "row" and column "col", up to "len" characters. As with bio_movecur(), 0 is the top row and 0 is the left-most column. If the string is longer than "len", then only "len" characters are displayed, but if it is shorter than "len", then the entire string is displayed left-justified in the field. However, if "len" is 0 or less, then the field length is considered to be the actual length of the string (i.e. the entire string is displayed). Afterwards, the cursor is positioned after the last character of the field. (Note that on systems where output is buffered, this function should not flush the output buffer). The results are undefined if the specified values indicate a field that does not fit on the screen.
=== Line Editor: int bio_edit(........) ===
int* '''curpos''', int '''IsTextEditor''', int '''ReadOnly''')</big>
<br />
<table align="center">
<tr align="center">
<td>[[Image:bio_edit_variables.png|||]]</td>
</tr>
</table>
Allows the user to perform full screen editing of the null-terminated string pointed to by '''"str"'''. The parameter '''"row"''' identifies the row of the screen for the field (0 is the top row), while '''"col"''' indicates the starting column of the field (0 is the left-most column). The parameter '''"maxdatalen"''' specifies the maximum length of the string '''"str"'''. The parameter '''"fieldlen"''' specifies the length of the field in which editing is to be performed (visible area of '''“str”'''). The pointer '''"offset"''' points to an integer holding the index of the first character of'''"str"''' shown in the field. The pointer '''"curpos"''' points to an integer holding the position of the cursor in the field (0 is the first position). '''"insertmode"''' is a pointer pointing to an integer flag that is true (1) for insert mode being on, or false (0) for insert mode being off.<br />
# If '''"*curpos"''' is greater than or equal to the value of fieldlen, correct the '''"*curpos"''' so that cursor stands at the last position inside the field.
# If '''"*offset"''' is greater than the length of the string, set the '''"*offset"''' so the “last character of str” is hidden right before the first space in the field. (See '''“[[Iolib functions 20103 - OOP344BIO Functions oop344 20111#IsTextEditor:|IsTextEditor Section #1]]”''' for more)
# After the above, if cursor is past the last character of '''“str”''', set '''"*curpos"''' so the cursor stands right after the last character of "str".
<u>Editing is terminated by pressing ENTER, TAB, UP, DOWN, PGUP, PGDN or any of the function keys (F1 to F12)</u>. Pressing<u>ESCAPE will terminate the bio_edit() and abort editing</u>: '''"str"'''will contain originally passed data when leaving function.
Note that the conditions of termination are changed if the '''“IsTextEditor”''' flag is true (non-zero). See '''“[[Iolib functions 20103 - OOP344BIO Functions oop344 20111#IsTextEditor:|IsTextEditor]]”'''section for detail.
If '''"ReadOnly"''' has a true value (non-zero), then any attempt to change the content of '''"str"''' should end the function and return the key. Note that all other keys should work (Function and Non-ASCII keys). This makes the '''bio_edit()''' funciton "read only", but the user still can scroll the text to left or right and etc....
* '''RIGHT''' - move cursor right one character. If cursor is at the end of the field but not at the end of the string, then scroll one to left.
* '''HOME''' – move cursor to the beginning of the string. Scroll all the way to right if necessary. (i.e. if there is hidden data at the beginning)
* '''END''' - go to the end of the data in the string, i.e. just past the last character in the string. Scroll all to the way left to left bring the end of the data within the field if necessary.
* '''DEL''' – eat the current character above the cursor and move all subsequent characters one position to the left.
* '''BACKSPACE''' - move the rest of the field (including the cursor) one position to the left, eating the previous character.
* '''TAB''':
** if '''IsTextEditor''' is false, TAB will simply terminate the function like a Function key
** if '''IsTextEditor''' is true, TAB will insert '''BIO_TAB_SIZE''' number of spaces into the string.'''BIO_TAB_SIZE''' should be a defined "tab size" value in bio.h. If '''BIO_TAB_SIZE''' spaces cannot be inserted into the string for any reason then the inputted tab should be ignored. (See '''“[[Iolib functions 20103 - OOP344BIO Functions oop344 20111#IsTextEditor:|IsTextEditor Section #2]]”''' for more)* '''ESCAPE''' - Terminates bio_edit() and aborts editing: '''"str"''' will contain originally passed data when leaving function. (See '''“[[Iolib functions 20103 -OOP344BIO Functions oop344 20111#IsTextEditor:|IsTextEditor Section #3]]”''' for exception)
* '''INSERT''' - toggle Insert/Overstrike mode (toggles the value of *insertmode)
**<u>In Insert mode</u>, printable characters are inserted into the string, moving the remainder of the string to the right to make room.
Note that at the beginning of the execution of bio_edit(), validating '''*offset''' may require the value of '''*offset''' to change. If so, make sure to correct the offset and then terminate the function before any editing happens returning the default value of key.
 
An easy way to accomplish this is to store the value of '''*offset''' in a temporary variable (eg. tempOffset) at the start of the function (after the opening while), and check at the end of the loop whether the two values are eqeal. If they are not, set done to 1. The loop exits.
'''[Section #2]'''<br/>
bio_flag() begins the selection by displaying the checkbox according to its '''“*status”'''. (Remember that the value of'''"*status"''' is corrected before the editing begins). Then the function waits for the user input.
* If the user input is any of the printable keys excluding space (' ' < key <= i.e. greater than space or less than or equal '~') excluding space, it should be ignored (no action takenor maybe you can beep!! ). If the user input is any of the function keys, the function is terminated returning the key.
* If the user input is SPACE:
** If '''“radio”''' is true, then the '''"*status"''' is set to one, checkbox is displayed and function is terminated returning space.
bio_menuItem() begins the selection by displaying the menu item according to its '''“*status”'''using [[#void io displayMenuItem.28...........29|bio_displayMenuItem()]]. (Remember that the value of '''"*status"''' is corrected before the editing begins). Then the function waits for the user input.
* If the user input is any of the printable keys excluding space (' ' < key <= i.e. greater than space or less than or equal '~') excluding space, it should be ignored (no action taken), and wait the user to input again.
* If the user input is any of the non-ASCII keys, the function is terminated returning the key.
* If the user input is SPACE, then the *status is set to one, menu item is displayed and function is terminated returning the ASCII value of space character.
=== Windows Visual C++ ===
* To Download Visual studio from [https://acs.senecac.on.ca/pages/download.php Seneca/ACS download page] Seneca students should first login using their Seneca account, click on MSDN and scroll down to the DVD Downloads subheading. Download the file "(Dual Layer) Visual Studio 2008 Professional Edition, MSDN Library for Visual Studio 2008 ".<br />:(Note that the image does not include [http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&displaylang=en Service Pack 1])  * Users also have the option of downloading Microsoft Visual C++ 2008 Express Edition from the[http://www.microsoft.com/express/download/ Microsoft Visual Studio Express Downloads page]. Users will eventually need to register the product, free of charge, in order to continue usage beyond the trial period. To register, open Visual C++, select 'Help' from the top tool bar and select 'Register Product'. Follow the instructions displayed on the screen and a registration key will be issued following successful registration.<br />:If you have other MS Visual Studio products (eg. Visual Basic) installed you may be asked to first uninstall them before installing the Visual C++ Express Edition.  * [https://acs.senecac.on.ca/pages/download.php Seneca/ACS download page] now actually offer Visual Studio 2010 Ultimate Edition, and no registration key required (full version)
(Note that the image does not include [http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&displaylang=en Service Pack 1])
Users also have the option of downloading Microsoft Visual C++ 2008 Express Edition from the[http://www.microsoft.com/express/download/ Microsoft Visual Studio Express Downloads page]. Users will eventually need to register the product, free of charge, in order to continue usage beyond the trial period. To register, open Visual C++, select 'Help' from the top tool bar and select 'Register Product'. Follow the instructions displayed on the screen and a registation key will be issued following successful registration.
<br/>
If you have other MS Visual Studio products (eg. Visual Basic) installed you may be asked to first uninstall them before installing the Visual C++ Express Edition.
==== Creating a Project for console application in Visual C++ 2008 ====

Navigation menu