Forum > General

Getting info that is very volatile.

<< < (3/3)

OC DelGuy:

--- Quote from: dseligo on January 30, 2023, 08:47:24 am ---Here you go, I think it's working for your example:

--- End quote ---
Yes, it works for the four lines I supplied.  Hopefully I picked a good sample size so it covers all the possibilities.  I've only seen the first 100 lines and studied the first 50 lines (maybe).  But now, with this, I'll be able to figure out (hopefully) any anomalies.  And if not, then I'll just change the raw file for the few lines that might not fit right.

At any rate, thank you for this.



I'll be turning this in to my professor later.  :o
Just kidding!  That was for jamie in the first comment.  :D ;D

All seriousness aside:
Procedure in a procedure!!  Never seen nested procedures!  I've seen nested loops and if statements (which is why I like the Case statement).

And some stuff like the Pos function and Delete.  There's no mention of them in the Sysutils reference.




OK, I just ran it a few times with the txt file (the one with the 900 lines).  I got an exception error.  So I knew it had to be in the txt file.  So I did a Try..Except..End in the main block.  And in the Convert procedure, the first line after "For x := 1 to Recds do Begin" I added "xxline:=x;"


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  Try    Convert;  Except    WriteLn('xxline :',xxline);  end;
xxline turned out to be 724.  Seems the only problem in the file was that line 723 was chopped off at the end.  One of the trades was actually in the line for the next village.  So, instead of starting off with the village name, it started with "copper. "  I opened the file with Notepad, looked for the offending village and simply put the copper back into the end of the previous line.  Now it runs beautifully for the full 900 lines.

So now I have a properly formatted Data file.

So, there you have it.  All I have to do now is write a WriteVillagedata (to file) procedure and run the file.  I'll also strip out all the WriteLn's and look for an exit code and terminate the program.

Clearly, I'm doing a bunch of extra stuff because in reality, all this is for a PDF I bought online that has, you guessed it, 900 village names.  I think I remember just highlighting the entire PDF and copying the text.  I then just opened Notepad and pasted.  That was the source for raw data.  Once I write the data file one time properly, I'm done.  I'll never have need for this program after the first successful run.

But I want to do all this extra work to learn.  Thanks to y'all, I learned quite a bit.

Yep, once I get the data file done, then I start writing an application that takes the information in the file and properly displays it on a form with the Lazarus controls and stuff.  And I'll have the information I need when I need it and searchable.  Need a village of about x number of population?  Here's a list of some.  Need a village that exports corn?  This list has those! 

OC DelGuy:

--- Quote from: alpine on January 30, 2023, 12:30:23 pm ---Although the dseligo program is working perfectly, I would like to propose another version for Convert procedure using a slightly different approach (with TStringHelper). That way It is a bit clearer and shorter, I believe.

--- End quote ---

WOW, when I ran this, I actually got several compile time errors.  I had just run the code above and it worked perfectly.  I got a runtime error, but solved that almost immediately.  So, I went with that code.  Thanks Alpine.

alpine:

--- Quote from: OC DelGuy on January 31, 2023, 01:50:41 am ---
--- Quote from: alpine on January 30, 2023, 12:30:23 pm ---Although the dseligo program is working perfectly, I would like to propose another version for Convert procedure using a slightly different approach (with TStringHelper). That way It is a bit clearer and shorter, I believe.

--- End quote ---

WOW, when I ran this, I actually got several compile time errors.  I had just run the code above and it worked perfectly.  I got a runtime error, but solved that almost immediately.  So, I went with that code.  Thanks Alpine.

--- End quote ---
You're welcome.
What I wanted to show is that it can first be split into sentences and then, depending on the position or prefix, split into individual tokens by specifying the delimiters. Thus processing should be easier than searching for specific positions.


--- Quote from: Thaddy on January 30, 2023, 06:42:29 pm ---I did. I would recommend to learn to count.

--- End quote ---
I see that total number of posts seems to be important and "real programmers" don't bother to explain their own offensive and otherwise false comments.

OC DelGuy:
Alright!!  I finished the program!  Thanks to all of y'all!!

This is done like Julie Bowen and Plastic Surgery!!

Navigation

[0] Message Index

[*] Previous page

Go to full version