Hi Soft Basic help wanted
I am trying to write a routine to sort listed data into time difference groups such that any group of data with a fixed time difference will have a line of space before the next group as follows:-
Basic data list a b c d e f g h etc If a-b < 5 then print a and b, if b-c < 5 print a,b and c etc If c-d > 5 then print a line of space and start again at d this will then look like this:- a b c d e f g h etc Any item without a close neighbour is to be unlisted Can anyone help? |
You can do this by starting at the first value and search forward while the difference is lower than your threshold. If the interval you searched in covers more than one value then you print these and a blank line after. If the next value after the interval is still inside your list then you repeat the whole procedure.
EDIT: assuming you have a list sorted in ascending order: Code:
' set the threshold and number of items in our list |
Thanks. I will ponder on your answer and see if I can make it applicable. If not, may I
ask for more help? regards Dan |
Sure, no problem. This code should work with HiSoft Basic v2.0 from 1994, I'm not sure how compatible the other versions are.
|
Hi Leffmann, my HiSoft basic program is V2.0, so it should work. My data generated from another program is filed in the following format:-
Day 11 9 Time 0 0 4 Har 12 22 35 Day 11 9 Time 10 10 40 Har 16 52 48 This makes the line lengths different. If we need the length of the file to use in the formula you gave me, we need the number of lines and not just the file length. Typically my files have between 3500 and 4000 lines. I tried using the following code to find the file length:- Open for input as #1 : length&=LOF(1) FileBuf$=INPUT$(length&,#1) PRINT LOF(1) I use the print statement to check LOF. The result is a large number 155378 is an example. To find the number of lines we need to divide this by the number of data bits in a line (I think). Therefore the line lengths must be equal. How can I file data so that all of the items are tabbed in columns? This would be useful also for visual inspection of the data. I use the following code in my data generation program. OPEN ans2$ for APPEND AS #1 thanks for your help |
You can achieve both tabulation and fixed-width lines if you write your data with the print using-statement, f.ex:
Code:
print #1, using "### ### ### \ \", x, y, 10, "test" Do you have the v2.0 manual btw? I'd like to add it to my own files but can't find a download anywhere. EDIT: if the lines in your file are already sorted, and you're not doing anything else with the file but reading it in to group the lines and print them, then you can probably do this in one go and print as you read. |
Quote:
|
Quote:
Yes I have the original manual in hard copy. I find it hard to use because I'm not really a programmer. I'm just starting to learn but have a research project to complete. I shall try your advice. Thanks for your help |
Quote:
I have the original in hard copy. Using it with all that jargon is a big task for a a starter! |
Quote:
Thanks. I have now managed to get the files right and can calculate the number of lines of text. Next is to get the search routine right. |
Quote:
Quote:
|
All times are GMT +2. The time now is 23:51. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.