Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > VB.NET > VB.NET General Discussion

VB.NET General Discussion VB.NET general discussion area

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-08-2010, 10:10 AM
VB.NET Forum Fanatic
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Mar 2009
Age: 19
Posts: 131
Reputation: 17
Johnson is on a distinguished programming path ahead
Default Putting anchor points in a text file

Basically i have a 500 line javascript file i made that runs in grease monkey (a add on for firefox ) I'm using vb.net to "compile" this script depending on certain check boxes.

So for example. (this is part of my script)

Code:
#RegionCapsEnforcer

var array=document.evaluate("//*[contains(@class, 'postbody')]", document, null, 6, null);
for(let i=0,item; (item=array.snapshotItem(i)); i++) item.innerHTML=item.innerHTML.toLowerCase()

#RegionRevealURLs

var postAs = document.querySelectorAll('.postbody a')
for(var i in postAs){
    var c = postAs[i];
    if(c.hasAttribute('href')){
        var np = document.createElement('p');
        np.innerHTML=c.getAttribute('href');
        var p = c.parentNode;
        var pl = c.nextElementSibling;
        if(!pl){
            p.appendChild(np);
        }
        else{
            p.insertBefore(np, pl);
        }
    }
}
and so on. So if chkCapsEnforcer was not checked it would skip that part and go to chkRevealUrl and if that was checked would get that bit. Then once it has gone through all the checkboxes it would write the enabled bits to a text file.

make sense?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-10-2010, 8:12 AM
VB.NET Forum Fanatic
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Mar 2009
Age: 19
Posts: 131
Reputation: 17
Johnson is on a distinguished programming path ahead
Default

any ideas any one????
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-10-2010, 9:10 AM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,316
Reputation: 1315
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

The thread title suggest you want to insert "anchors", but the post content indicates you want to retrieve them. Perhaps you can clarify?
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-10-2010, 9:26 AM
VB.NET Forum Fanatic
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Mar 2009
Age: 19
Posts: 131
Reputation: 17
Johnson is on a distinguished programming path ahead
Default

Sorry for the title. I didnt know how else to explain it.

If you look at this form below. You will see there are a few options.



Each of them chkboxes has a anchor (thats just what im calling it) in my script.

I have a compile button now depending on what checkboxes are selected i want to be able to read each section of the script (if its checkbox is checked)

Grab the bits that i selected and write them to a new textfile. Sort of like compiling a script. Does that make any more sense?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-10-2010, 2:16 PM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,316
Reputation: 1315
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

The logic could be something like this:
Code:
Dim includeLine As Boolean
Dim newLines As New List(Of String)
For Each line As String In lines
    If line.StartsWith("#") Then
        includeLine = CType(Me.Controls(line.Substring(1)), CheckBox).Checked
    ElseIf includeLine Then
        newLines.Add(line)
    End If
Next
You can for example read/write all lines with File.ReadAllLines Method (String) (System.IO) and the corresponding WriteAllLines.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 7:17 PM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.