Easy A
Would you like to react to this message? Create an account in a few clicks or log in to continue.


 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  

Share
 

 Very useful simple coding tip - how to save time working with lists

View previous topic View next topic Go down 
AuthorMessage
WhiteHat
Member
Member
WhiteHat

Posts : 2
Join date : 2011-06-16

Very useful simple coding tip - how to save time working with lists Empty
PostSubject: Very useful simple coding tip - how to save time working with lists   Very useful simple coding tip - how to save time working with lists EmptyThu Jun 23, 2011 8:41 am

I was working on a list for a list box, which drives me nuts, till I found a very simple solution, just using 'notepad' and 'excel'!
Just wanted to share it with anyone who would like to use it. This procedure can be used for many types of coding and building lists.

The problem:

I had a list that goes like this given below. It is a list of supported LG mobile phones which I need to code for a list box:

LG-B2050
LG-BL40-Orange
LG-C1100
LG-C3300
LG-C3310
LG-C3320
LG-F2250
LG-GB220
LG-GC900
LG-GC900-orange
LG-GD900 Obigo
LG-GT500-v10b Browser
LG-GT505-Orange
LG-GW300
LG-GW300-Orange
LG-GW520
LG-GW520 Teleca
LG-GW520-orange
LG-KC550 Teleca
LG-KC780 Teleca
LG-KC910

Now the code for the list box that I need goes like this - <option> LG-B2050</option> and so on. My first option was to copy <option> and paste it before each model and </option> after. Doing it manually just get me nuts more so since I have a much much lengthier list than the eg. above. So I decided I had to find a more 'auto' way using simple tools that I have on my pc.

The method:

Copy the whole list and paste it on a 'notepad'. Now press Ctrl H or Edit-Replace. Replace all LG with </option><option>LG. Now it looks like this:

</option><option>LG-B2050
</option><option>LG-BL40-Orange
</option><option>LG-C1100
</option><option>LG-C3300
</option><option>LG-C3310
</option><option>LG-C3320
</option><option>LG-F2250
</option><option>LG-GB220
</option><option>LG-GC900
</option><option>LG-GC900-orange
</option><option>LG-GD900 Obigo
</option><option>LG-GT500-v10b Browser
</option><option>LG-GT505-Orange
</option><option>LG-GW300
</option><option>LG-GW300-Orange
</option><option>LG-GW520
</option><option>LG-GW520 Teleca
</option><option>LG-GW520-orange
</option><option>LG-KC550 Teleca
</option><option>LG-KC780 Teleca
</option><option>LG-KC910

Copy the first </option> at the beginning to the last part. Now delete the line breaks and you got the completed code:

<option>LG-B2050</option><option>LG-BL40-Orange</option><option>LG-C1100</option><option>LG-C3300</option><option>LG-C3310</option><option>LG-C3320</option><option>LG-F2250</option><option>LG-GB220</option><option>LG-GC900</option><option>LG-GC900-orange</option><option>LG-GD900 Obigo</option><option>LG-GT500-v10b Browser</option><option>LG-GT505-Orange</option><option>LG-GW300</option><option>LG-GW300-Orange</option><option>LG-GW520</option><option>LG-GW520 Teleca</option><option>LG-GW520-orange</option><option>LG-KC550 Teleca</option><option>LG-KC780 Teleca</option><option>LG-KC910</option>

Now in another list I had no common strings like 'LG' used above. It goes like below:

5300
6233
6300
N70
N80
1680c-2
2330c-2
2600c
2600c-2
2610
2630
2680s
2680s-2
2730c-1
2760
3100
3109c
3110c
3120

In this case, first paste the list to a new excel file. Insert a column on the left. fill the left column with '1' or whatever by dragging the bottom right corner '+' sign to fill upto your list. Now copy both the column to notepad and replace all '1' with </option><option> and follow the same method as above. That's it.

This has saved me lots of time. And the method can be used for many different situations when working with lists or databases. I certainly found it useful. Hope someone will find it useful too. If anyone wants to see the result in action - Mobile Poker.
Back to top Go down
HazordExcell
Member
Member
HazordExcell

Posts : 1
Join date : 2011-06-16

Very useful simple coding tip - how to save time working with lists Empty
PostSubject: Re: Very useful simple coding tip - how to save time working with lists   Very useful simple coding tip - how to save time working with lists EmptyThu Jun 23, 2011 8:42 am

Another option:

If your editor has Macro recording (record a series of keystrokes to rerun later on) you could record a macro to set up one line as you want and then simply rerun the macro on the other lines in the list that need editing.
Back to top Go down
Dimension
Member
Member
Dimension

Posts : 3
Join date : 2011-06-05

Very useful simple coding tip - how to save time working with lists Empty
PostSubject: Re: Very useful simple coding tip - how to save time working with lists   Very useful simple coding tip - how to save time working with lists EmptyThu Jun 23, 2011 8:43 am

Assuming that your text editor can handle new-line characters:
Code:

1. Make sure there is a new-line before the first item.
2. Change <nl> to </option><nl><option> for these items.
3. Delete the first line junk and, if needed, the last line.
Back to top Go down
Scene<3
Member
Member
Scene<3

Posts : 3
Join date : 2011-06-05

Very useful simple coding tip - how to save time working with lists Empty
PostSubject: Re: Very useful simple coding tip - how to save time working with lists   Very useful simple coding tip - how to save time working with lists EmptyThu Jun 23, 2011 8:44 am

I'm a fan of Excel

Bung the list in column A and add the function

="<option>"&A1&"</option>"

to B1. Drag the formula down (or double-click the fill handle) to copy it down the column. Then copy/ paste special - values.
Back to top Go down
Sponsored content




Very useful simple coding tip - how to save time working with lists Empty
PostSubject: Re: Very useful simple coding tip - how to save time working with lists   Very useful simple coding tip - how to save time working with lists Empty

Back to top Go down
 

Very useful simple coding tip - how to save time working with lists

View previous topic View next topic Back to top 
Page 1 of 1

 Similar topics

-
» Save the pictures from google images search page
» Working with DOM Element
» Enhanceviews.net not working right now?
» Windows 7 ....not working...
» working web flood

Permissions in this forum:You cannot reply to topics in this forum
Easy A :: Very useful simple coding tip - how to save time working with lists Edit-trash Useless :: Trash-