I'm having a really confusing problem with BlitzMax. I'm basically writing a simple crawler for individual sites, and I've got a Type, TPage, where every newly detected page is placed. Here's the code for adding a new page object:
As you can see, it first checks existing pages to see if the new one has actually already been detected and added to the list. If so, it just returns the existing one.
At least, that's what supposed to happen. The problem is, after much debug checking, this line:
I feel like I'm missing something really obvious, but I just don't see it. What seems to be happening is this:
1) The program adds the first page. This works fine.
2) The program detects several links in this page and proceeds to add more.
3) At this stage, as the Create function is called for each new page.
4) Each time the create function is called for these new pages, the above line evaluates to true. Each = operator is treated like an assignment operator, and checkPage is given the values, rather than being compared to them.
5) End result: every time the Create function is called after the initial call, the one page in the list is assigned the new values, instead of a new page being created, so I can never have more than one, constantly changing page in the list.
BMax doesn't seem to support the == operator for checking equality, so...
What am I doing wrong?
Function Create:TPage(nsite$,nport%,naddress$,nawaitingCrawl%=1) AddTextAreaText(output_TextArea:TGadget,Chr$(10)+"Checking: "+naddress$+" ") ;CHECK IF PAGE ALREADY EXISTS For checkPage:TPage=EachIn PageList If checkPage.address$=naddress$ And checkPage.site$=nsite$ And checkPage.port%=nport% AddTextAreaText(output_TextArea:TGadget,Chr$(10)+"Exists: "+naddress$+" "+checkPage.awaitingCrawl%) Return checkPage EndIf Next ;OTHERWISE, CREATE IT AddTextAreaText(output_TextArea:TGadget,Chr$(10)+"New: "+naddress$) Local p:TPage=New TPage p.address$=naddress$ p.content$="" p.awaitingCrawl%=nawaitingCrawl% p.site$=nsite$ p.port%=nport% ListAddLast(PageList,p) Return p End Function
As you can see, it first checks existing pages to see if the new one has actually already been detected and added to the list. If so, it just returns the existing one.
At least, that's what supposed to happen. The problem is, after much debug checking, this line:
If checkPage.address$=naddress$ And checkPage.site$=nsite$ And checkPage.port%=nport%
I feel like I'm missing something really obvious, but I just don't see it. What seems to be happening is this:
1) The program adds the first page. This works fine.
2) The program detects several links in this page and proceeds to add more.
3) At this stage, as the Create function is called for each new page.
4) Each time the create function is called for these new pages, the above line evaluates to true. Each = operator is treated like an assignment operator, and checkPage is given the values, rather than being compared to them.
5) End result: every time the Create function is called after the initial call, the one page in the list is assigned the new values, instead of a new page being created, so I can never have more than one, constantly changing page in the list.
BMax doesn't seem to support the == operator for checking equality, so...
What am I doing wrong?