guest (166.164.157.165)
Apr 2, 2009
<span class="wiki_link_new"> </span> =Submit Articles Here for Liberty BASIC Programmer's Encyclopedia= [[home|Liberty BASIC Programmer's Encyclopedia]]Rearranging a listbox and repeating butonsAnybody can submit articlesThe following demo shows two different programming features, the first is a way to rearrange a list box to theLiberty BASIC Programmer's Encyclopedia. You douser's preference, notneednecessarily alphabetically or in ascending or descending numerical order. The second feature is tobe a member of Wikispacesuse repeating buttons to move the items in the listbox up orof this site.down.**License** By adding content toThe repeating buttons are actually two bitmaps available in the LibertyBASIC Programmer's Encyclopedia, youBasic 4.03 bmp folder that arebound byplaced in a graphic box to look similar to a spinner control. When thelicense. Ifleft mouse is clicked down, it is detected in the graphic box using when LeftButtonDown. Using the MouseX and MouseY commands youdo not wantcan tell if the cursor is on the up or down button and the selected item will move. If the left mouse button is held down, the selected item will continue torelease your work under this license, do not submit articles. [[License|Click HEREmove. This eliminates the need toreadrepeatable click an up or down arrow to move an item a long distance. When theLicense.]]LeftButtonUp is detected by the scan in the [moveup] or [movedown] sections, the program will go to [stopmove] and wait.**Article Guidelines** The Liberty BASIC Programmer's Encyclopedia is a place for full-length technical articles. Authors should make sure that articles are well-structured, that words are spelled correctly, and that all code works properly. [[tech.writing|Click HERE for help on technical writing.]]When you submit an article, be aware this is not the end of your involvement. Few of us get it Just Right the very first time. Expect an LBPE editor to contact you with questions, suggestions, possible edits, etcetera for you to look over and take the proper action.**Adding Articles** # Click the edit button at the top of this page. # Add your article to the [[Submit#list|list at the bottom of this page]] . If you are using the formatted text editor, simply click the link button (a globe with chain links in the foreground) and invoke'Rearranging adialog to add the link. Type the name of your new page in the "wiki link" arealistbox contents andclick the "okay" button.If you are using the plain text editor, do this by typing a name for your page inside of double square brackets. If your article is called "Using Arrays", your link would look like this: ``* [[Using Arrays]] `` Save the editing of this page. # View this page and click on the link you just created. # On the new page, click the edit link and type or paste your article. # Please place your name and the date at the top of your article, along with a descriptive title. # Save your edits. That's all there is to it!Repeating buttons demo**Editing Articles** To learn how to use WikiText markup to edit site content, click [[www:wikitext|HERE.]] You don't need to know WikiText, though. When you are editing a page, there is a button nearnomainwin dim array$(10) 'This fills thebottom to "Use Visual Editor." If you want to try some editing inlistbox array, but it could be filled from asafe place where you can do no harm, play in the [[TestArea|Test Area]]. Before finalizing the article, you can click the "Preview" button to see how your article will appear, and make changes as needed.file. array$(1)="Pigeon" array$(2)="Donkey" array$(3)="Horse" array$(4)="Rabbit" array$(5)="Dog" array$(6)="Cat" array$(7)="Goat" array$(8)="Mule"**Additional Files** If your article requires imagesNUMBERRECORDS=8 'Number of records in the array orother additional files, simply upload themthe file 'This demo uses an up andinclude links in your article. When youdown arrow bitmap button from Liberty Basic's bmp folder. 'They areediting a page there is a link in the upper right for "Images". Click this to view a list of all available files and images.20 x 20 pixels each. loadbmp "upbutton", "C:\Program Files\Liberty Basic v4.03\bmp\MAXBX.bmp" loadbmp "dnbutton", "C:\Program Files\Liberty Basic v4.03\bmp\MINBX.bmp"**Article Placement** One of the organizers of the Liberty BASIC Programmer's EncyclopediaWindowWidth =400 WindowHeight=400 'This graphicbox willtag your article for editing. If the organizers find itbe used tobeplace both buttons. 'If you use aviable article fordialog window, theencyclopedia, it willgraphic box should beaddedabout 4 pixels wider 'and 4 pixels deeper toall the appropriate categories.look best. graphicbox #main.gb1, 345,160,20,40 listbox #main.lb1, array$(, [selectitem], 10, 30, 305, 300 statictext #main.st1, "", 20, 5, 300, 20 open "Reorganize a List" for window as #main**Confirmation** Organizers of#main.lb1, "singleclickselect" #main, "trapclose [quit]" currec=0 'Used to contain theLiberty BASIC Programmer's Encyclopedia will make any modifications they feel are needed. Authors may accept or reject these changes before articles are listedcurrent element in theappropriate categoriesarray. flag=0 'This flag is used to determine if an item has been moved. 'Put the pen down andlocked.draw the up button at the top of the graphic box. #main.gb1, "down;drawbmp upbutton 0 0" 'Draw the down button in the bottom of the graphis box. #main.gb1, "drawbmp dnbutton 0 20;flush" 'When the left button is depressed in the graphic box. #main.gb1, "when leftButtonDown [leftdown]" 'When the left button is released. #main.gb1, "when leftButtonUp [stopmove]" wait**Article Modification[selectitem] 'When an item is double clicked for selection in theFuture** Onelistbox #main.lb1, "selection? item$" 'get the name of theadvantagesitem selected. #main.lb1, "selectionindex? currec" 'Get the current record number ofthis format is that it affords ustheability to updateselected item. #main.st1, "Moving - "+item$ 'Indicates which item you will move. 'If an item has been moved andmodifya second item selected 'put the first item into the array at the last spot. if flag=1 then array$(lastmove)=origitem$ flag=0 'reset theinformation. Organizers reserveflag end if origitem$=item$ 'Save theright to modify, expand, or delete articles as they determine such actions to be appropriate.newly selected item's name. wait**Who Can Edit Articles** Articles can[leftdown] 'When the left mouse button is depressed while in the graphic box. 'If the left button was depressed while in the lower 1/2 of the graphicbox. if MouseY > 20 then 'Mouse in lower half of graphic box goto [movedown] else 'Mouse was in the upper half of graphic box. goto [moveup] end if [moveup]'up button loop if currec=0 then wait 'If no item was selected when left button down in graphic box. if currec>1 then 'The current record must beedited by2 or more or a move can't be done. a$=array$(currec-1) 'Get the item above the currently seleted item. array$(currec-1)=item$ 'Put the currently selected item in the array element above. array$(currec)=a$ 'Put the item from above into the current element. #main.lb1,"reload" 'Reload the array so it shows the move. 'Subtract one from the current record to indicate the current element of the array. currec=currec-1 'Select the new current array element. 'This is the new position of the selected item. #main.lb1,"selectindex ";currec end if 'Set the lastmove = to the current element so that if another item is 'selected, the item being moved will be replaced with the originalauthorsname 'in the [selectitem] section above. lastmove=currec 'and set the flag to 1 so it will know a move has been effected. flag=1 'Make this API call as a 300 millisecond delay. 'This avoids an almost instant move to the top of the listbox. calldll #kernel32, "Sleep", 300 as ulong, result as void scan 'This scan is necessary to see when the left button is released 'while in this loop. goto [moveup] 'By looping to the beginning of this section, holding the left button 'down will continue to effect movement. [movedown]'down button loop if currec=0 then wait 'If no item was selected when left button down in graphic box. 'The current record must be less than the number of record or a move can't be done. if currec<NUMBERRECORDS then a$=array$(currec+1) 'Get the item below the currently seleted item. array$(currec+1)=item$ 'Put the currently selected item in the array element below. array$(currec)=a$ 'Put the item from below into the current element. #main.lb1,"reload" 'Reload the array so it shows the move. 'Add one from the current record to indicate the current element of the array. currec=currec+1 'Select the new current array element. 'This is the new position of the selected item. #main.lb1,"selectindex ";currec end if 'Set the lastmove = to the current element so that if another item is 'selected, the item being moved will be replaced with the original name 'in the [selectitem] section above. lastmove=currec flag=1 'and set the flag to 1 to indicate a move has been effected. 'Make this API call as a 300 millisecond delay. 'This avoids andbyalmost instant move to the top of the listbox. calldll #kernel32, "Sleep", 300 as ulong, result as void scan 'This scan is necessary to see when the left button is released 'while in this loop. goto [movedown] 'By looping to the beginning of this section, holding the left button 'down will continue to effect movement. [stopmove] 'If the left button is released. 'break out of the loop and wait. wait [quit]'Close or Cancel 'At this point the array can be saved to a file in thesite organizers. Others should suggest changes vianew order. #main.gb1, "cls" 'Unload thesite's dicussion feature.bitmaps from memory. unloadbmp "dnbutton" unloadbmp "upbutton" close #main end---- [[#list]] **LIST ARTICLES HERE** * [[Creating an Image Map]] [[user:marcuslee]] - added to [[graphics|Graphics and Games]] * [[UsingTheFilesStatement|Using the FILES Statement]] [[user:alix]] - added to [[files|Using Files]] * [[GPFiles|Using Files as a General Purpose Interface]] [[user:BillBlack]] - added to [[files|Using Files]] * [[ImageConversion|Image conversion, window and screen dumps for LB4]] - by Mike Bradbury * [[FastFAQ|Fast FAQ: New to Liberty BASIC? Read this!]] - [[user:RodBird]] * [[SerialPortPropeller|Hardware Control with the Serial Port and Propeller]] - [[user:rabaggett]] * [[Hardware Control with the Serial Port and Propeller II]] - [[user:rabaggett]] * [[IntroToFiles|An Introduction to Working with Files]] - [[user:GordonR]] * [[Custom Controls in a Box]] - [[user:lbjoseph]]