<div dir="ltr"><div><div>i dont like tree structures at the moment<br></div>but here ya go<br>void Spider(xTreeItem CurrentItem)<br>{<br> int s;<br> CString spaces;<br> CString xStr;<br> //There Could Probably Be More Vars Here To Save Space<br> //Down There... There Also Needs To Be Some Space<br> //Generating Loop Code Put Into A Function <br><br> //CurrentItem Is Either A Branch Or A Leaf<br> //The Processing Of CurrentItem Will Be Different <br> //For Each State Of CurrentItem<br> if(CurrentItem.IsBranch())<br> {<br> CString currentpath;<br> CString currenturl;<br> <br> //Set Up All The Path Variables And File Names<br> //And Levels<br> CurrentLevel ++;<br> currentpath = BasePath;<br> currenturl = BaseURL; <br> CurrentItem.FileName = "index.txt";<br> CurrentItem.Level = CurrentLevel; <br> DirectoryL[CurrentLevel] = CurrentItem.Directory;<br> <br> for(int l = 1; l <= CurrentLevel; l ++)<br> {<br> currentpath += "\\" + DirectoryL[l];<br> currenturl += "/" + DirectoryL[l]; <br> }<br><br> CurrentItem.LocalHtmlPath=currentpath + "\\index.html";<br> CurrentItem.Url = currenturl + "/index.html";<br> currentpath += "\\index.txt";<br> <br> //Add This Branch Item To The Flat List<br> xTreeItems.Add(xTreeItem(CurrentItem));<br><br> spaces = MakeSpace(CurrentLevel);<br> TocFile.WriteString(spaces);//Toc File Was Opened For Append Each<br> //Write To Eat Bugs<br> <br> //Start A New Division<br> TocFile.WriteString("<UL>\n<LI>\n");<br> TocFile.WriteString(CurrentItem.MakeSiteMapObject());<br> <br> //This Is A New Branch So Keep Spidering<br> InputIndexFile[CurrentLevel].Open(currentpath, <br> CFile::modeRead | <br> CFile::typeText);<br> HtmlOutputFile[CurrentLevel].Open(CurrentItem.LocalHtmlPath,<br> CFile::modeCreate | <br> CFile::modeWrite | CFile::typeText );<br> //Start A Fresh Html Page<br> HtmlOutputFile[CurrentLevel].WriteString("<HTML>\n<Body>\n");<br> <br> //Create A Link From The Entry<br> HrefL[CurrentLevel] = CurrentItem.MakeHref();<br><br> //Make A Line Hrefs That Link To The Parent Level(s)<br> CString DirectoryBar;<br> DirectoryBar="";<br> for(int h = 1; h < CurrentLevel; h++)<br> {<br> DirectoryBar += HrefL[h] + " / ";<br> }<br><br> //Put The DirectoryBar On The Page<br> HtmlOutputFile[CurrentLevel].WriteString(DirectoryBar + <br> CurrentItem.Name + <br> "<BR><BR>\n");<br> <br> //If This Is Not The Root<br> if(CurrentLevel > 1)<br> {<br> //Then Put A Link To This Page <br> //On This Item's Parent's Page<br> HtmlOutputFile[CurrentLevel - 1].WriteString(<br> CurrentItem.MakeHref() +<br> "<BR>\n");<br> }<br> <br> <br> for(;;)<br> {<br> //If We Don't Hit EOF Spider Recursively <br> if(InputIndexFile[CurrentLevel].ReadString(xStr))<br> {<br> xTreeItem NewTreeItem;<br> NewTreeItem.InitFromTxtEntry(xStr);<br> Spider(NewTreeItem); <br> }<br> //If We Do Hit EOF <br> else<br> { <br> //Close This Division<br> TocFile.WriteString("</UL>\n");<br><br> //Close This Input File<br> InputIndexFile[CurrentLevel].Close();<br><br> //This Could Be A (Nifty Page Ground)<br> //HtmlOutputFile[CurrentLevel].WriteString(themeFooter);<br><br> //Close The Html And Body Tags And The File<br> HtmlOutputFile[CurrentLevel].WriteString(<br> "</Body>\n</Html>\n");<br> HtmlOutputFile[CurrentLevel].Close();<br><br> //Decrement The CurrentLevel And Break Out Of The Loop<br> //So We Can Return To Whence We Came Which Was <br> //Probably Up There Where It Says Spider(NewTreeItem);<br> CurrentLevel --;<br> break;<br> //Maybe This Is Where The Recursive Action Ends Hmmm...<br> //All Those pMFs Pushed On The Stack Get Popped Right<br> //Back On To IP... OH Wait The Class This Function Used <br> //To Belong To Has Probably Been Removed For The Sake<br> //Of Simpleness So pFs If So<br> }<br> } <br> }<br> //Here Is Where The Leaf Gets Processed<br> else<br> {<br> //First We Need To Make Sure CurrentItem Has A URL <br> if(CurrentItem.Url)<br> {<br> xTreeItem LeafTreeItem;<br> LeafTreeItem.copy(CurrentItem);<br> <br> //The Leaf Is As Far As The Spider Will Crawl<br> //So There's No Need To Increment The CurrentLevel <br> //Just Set The LeafTreeItem's Level To CurrentLevel + 1<br> LeafTreeItem.Level = CurrentLevel + 1;<br> <br> //Ah Add The Item To The Flat List<br> xTreeItems.Add(xTreeItem(LeafTreeItem)); <br> <br> //Nothing Done With Spaces Yet Here<br> //Need To Standardize And Functionize The TocFile Writes<br> spaces = MakeSpace(CurentLevel + 1);<br> <br> //Start A New Division I The Toc And Put This Item <br> //In As The Head Of The Division<br> TocFile.WriteString("<UL>\n<LI>\n");<br> TocFile.WriteString(LeafTreeItem.MakeSiteMapObject());<br><br> <br> //Throw It In It's Parent's List Of Links<br> HtmlOutputFile[CurrentLevel].WriteString(LeafTreeItem.MakeHref() +<br> "<BR>\n");<br> <br> //Loop Through The Rest Of The File<br> //Here Is Where It's Assumed That All<br> //Items That Follow Are Leaves<br> //This Is Fine For Our DirectoryTree Spider<br> //Where All The Links In The Deepest Folder<br> //Are Outside Of The Crawler's Space<br> //But Not For A Web Crawler<br> for(;;)<br> {<br> <br> if(InputIndexFile[CurrentLevel].ReadString(xStr))<br> {<br> //Again As Above<br> LeafTreeItem.InitFromTxtEntry(xStr);<br> LeafTreeItem.Level = CurrentLevel + 1;<br> <br> xTreeItems.Add(xTreeItem(LeafTreeItem)); <br><br> //Those Spaces Again<br> spaces = MakeSpace(CurrentLevel + 1);<br> <br> //We Are Allready In A Division So Just<br> //Make A New Entry<br> TocFile.WriteString("<LI>\n"); <br> TocFile.WriteString(LeafTreeItem.MakeSiteMapObject());<br> <br> //Throw It In It's Parent's List Of Links<br> HtmlOutputFile[CurrentLevel].WriteString(<br> LeafTreeItem.MakeHref() + "<BR>\n");<br> }<br> else<br> {<br> //Close The Division... We Ran Out Of File <br> TocFile.WriteString("</UL>\n");<br><br> //Get Out Of The Loop And Return To Next Line Of Caller<br> //Which Was Probably This Very Function <br> break;<br><br> //This Could Be Where The Recursive Action Ends<br> //Nah I Think It's Up There At The Branch Break<br> //Cause You Have To Start The Spider On A Branch<br> //Unless The Spider Drops From Another Tree And<br> //Lands On A Leaf<br> }<br> <br> }<br> } <br> }<br>}<br><br></div>more on the spider later<br><a href="http://geocities.ws/billy_stiltner/code/OSOS-3_25_am_06_06_02.zip">http://geocities.ws/billy_stiltner/code/OSOS-3_25_am_06_06_02.zip</a><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 30, 2017 at 9:28 AM, Christof Ressi <span dir="ltr"><<a href="mailto:christof.ressi@gmx.at" target="_blank">christof.ressi@gmx.at</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> If it was possible to have an array of pointers,<br>
<br>
</span>I get your idea. You can already have [list]s of pointers but this is rather cumbersome. Sometimes I've wished that pointers could be fields in structs (don't know why that's not possible...). Together with a mechanism to compare pointers (right now you can only route them by their type) these could indeed add some new possibilities.<br>
<br>
Gesendet: Mittwoch, 29. März 2017 um 15:37 Uhr<br>
Von: "José de Abreu" <<a href="mailto:abreubacelar@gmail.com">abreubacelar@gmail.com</a>><br>
An: "Derek Kwan" <<a href="mailto:derek.x.kwan@gmail.com">derek.x.kwan@gmail.com</a>>, "Christof Ressi" <<a href="mailto:christof.ressi@gmx.at">christof.ressi@gmx.at</a>>, <a href="mailto:pd-list@lists.iem.at">pd-list@lists.iem.at</a><br>
<span class="">Betreff: Re: [PD] [text define] functionality for text in structs?<br>
</span><span class="">Hello, this is my first e-mail on the list, and i don't understand the code of pd or anything like that, but I have an idea. Plus, sorry for bad english.<br>
If it was possible to have an array of pointers, maintained by the user, we could jump to some scalar in the list, say I have 1000 scalars, and an array with pointers to 100th, 200th, 300th, or any combination. This would improve the search.<br>
Maybe this would be a list/array of pointers inside another scalar? What do you think?<br>
Using this design, the user itself can create his own structures with pointers, creating trees, graphs with the scalars themself.<br>
It make sense?<br>
<br>
<br>
</span><div><div class="h5">Em Qua, 29 de mar de 2017 08:47, Derek Kwan <<a href="mailto:derek.x.kwan@gmail.com">derek.x.kwan@gmail.com</a>[<wbr>mailto:<a href="mailto:derek.x.kwan@gmail.com">derek.x.kwan@gmail.com</a>]<wbr>> escreveu:"Christof Ressi" <<a href="mailto:christof.ressi@gmx.at">christof.ressi@gmx.at</a>[mailto:<a href="mailto:christof.ressi@gmx.at"><wbr>christof.ressi@gmx.at</a>]> writes:<br>
<br>
<br>
> I have - and traversing large lists of scalars by pointer can be veeeery slow.<br>
><br>
yeahhhh, i figured that could be the case =P<br>
<br>
> you could hide the fact that it's a linked list from the user but I<br>
> don't know if that's a good thing to do. It doesn't seem transparent<br>
> to me ("why is accessing the 1000th elements slower than the 1st<br>
> element?").<br>
<br>
I suppose you could tell the user via documentation, but then you'd have<br>
go into what a linked list is and why linked list indexing is<br>
O(n) versus array O(1) to explain the speed difference and yeah,<br>
I see your point haha. And it's probably not good either to have a layer<br>
of abstraction that isn't totally necessary either.<br>
<br>
><br>
> if you don't use the graphical representation, you can just as well<br>
> work with data structure arrays and get fast random access. there is<br>
> one little but unfortunate drawback compared to using lists of<br>
> scalars: drawn instances of array elements don't respond to mouse<br>
> events, making them more or less useless as UI elements. if you<br>
> click/select an element, you only get a pointer to the array, not to<br>
> the element(s). if you click on the canvas, you get pointers to the<br>
> array + all array elements (for whatever reason).<br>
> The right behaviour IMHO would be that clicking/selecting array<br>
> elements gives you pointers to the array *and* the clicked/selected<br>
> element(s). clicking on the empty canvas shouldn't trigger any mouse<br>
> events!<br>
><br>
> Apart from that, data structure arrays are quite easy to handle and<br>
> much more efficient than linked lists of scalars<br>
<br>
ah, that's interesting. admittedly, i haven't used pd structs that much<br>
in my pd work as of yet but the stuff i want to do seems to be<br>
increasingly lending itself to that (or a similar) sort of paradigm so<br>
i'll keep that in mind!<br>
<br>
Derek<br>
<br>
--<br>
Derek Kwan<br>
</div></div><a href="http://www.derekxkwan.com" rel="noreferrer" target="_blank">www.derekxkwan.com</a>[<a href="http://www.derekxkwan.com" rel="noreferrer" target="_blank">http://www.<wbr>derekxkwan.com</a>]<br>
<br>
______________________________<wbr>_________________<br>
<a href="mailto:Pd-list@lists.iem.at">Pd-list@lists.iem.at</a>[mailto:<a href="mailto:Pd-list@lists.iem.at">Pd<wbr>-list@lists.iem.at</a>] mailing list<br>
UNSUBSCRIBE and account-management -> <a href="https://lists.puredata.info/listinfo/pd-list[https://lists.puredata.info/listinfo/pd-list]" rel="noreferrer" target="_blank">https://lists.puredata.info/<wbr>listinfo/pd-list[https://<wbr>lists.puredata.info/listinfo/<wbr>pd-list]</a><br>
<div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>_________________<br>
<a href="mailto:Pd-list@lists.iem.at">Pd-list@lists.iem.at</a> mailing list<br>
UNSUBSCRIBE and account-management -> <a href="https://lists.puredata.info/listinfo/pd-list" rel="noreferrer" target="_blank">https://lists.puredata.info/<wbr>listinfo/pd-list</a><br>
</div></div></blockquote></div><br></div>