English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System > Coders. Scripting

 
 
Thread Tools
Old 07 September 2012, 11:28   #1
alphagemini
Registered User
 
Join Date: Nov 2011
Location: Folkestone, Kent
Posts: 119
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?
alphagemini is offline  
Old 07 September 2012, 13:40   #2
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,194
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
t = 5
n = 10

list(n) = list(n-1)+t

' search through the whole list
s = 0
while s < n

 ' find the end of the current interval
 e = s
 while list(e+1)-list(e) < t
  e = e+1
 wend

 ' if there were more than 1 item we print them
 if e-s > 0
  for i = s to e
   print list(i)
  next
  print
 end if

' step to the next item and repeat
s = e+1

wend

Last edited by Leffmann; 07 September 2012 at 13:51.
Leffmann is offline  
Old 07 September 2012, 18:00   #3
alphagemini
Registered User
 
Join Date: Nov 2011
Location: Folkestone, Kent
Posts: 119
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
alphagemini is offline  
Old 07 September 2012, 21:18   #4
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,194
Sure, no problem. This code should work with HiSoft Basic v2.0 from 1994, I'm not sure how compatible the other versions are.
Leffmann is offline  
Old 11 September 2012, 11:11   #5
alphagemini
Registered User
 
Join Date: Nov 2011
Location: Folkestone, Kent
Posts: 119
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
alphagemini is offline  
Old 11 September 2012, 19:03   #6
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,194
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"
The # specifies where you want to fit digits and the \\ including the space in between specifies where you want strings. These are the only formatting specifiers I remember off the top of my head.

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.

Last edited by Leffmann; 11 September 2012 at 19:14.
Leffmann is offline  
Old 12 September 2012, 01:33   #7
prowler
Global Moderator

prowler's Avatar
 
Join Date: Aug 2008
Location: Sidcup, England
Posts: 10,300
Quote:
Originally Posted by Leffmann View Post
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.
HiSoft Basic 2.0 Manual-on-disk is in The Zone for you.
prowler is offline  
Old 12 September 2012, 08:02   #8
alphagemini
Registered User
 
Join Date: Nov 2011
Location: Folkestone, Kent
Posts: 119
Quote:
Originally Posted by Leffmann View Post
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"
The # specifies where you want to fit digits and the \\ including the space in between specifies where you want strings. These are the only formatting specifiers I remember off the top of my head.

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.

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
alphagemini is offline  
Old 12 September 2012, 08:04   #9
alphagemini
Registered User
 
Join Date: Nov 2011
Location: Folkestone, Kent
Posts: 119
Quote:
Originally Posted by prowler View Post
HiSoft Basic 2.0 Manual-on-disk is in The Zone for you.

I have the original in hard copy. Using it with all that jargon is a big task for a
a starter!
alphagemini is offline  
Old 12 September 2012, 15:45   #10
alphagemini
Registered User
 
Join Date: Nov 2011
Location: Folkestone, Kent
Posts: 119
Quote:
Originally Posted by Leffmann View Post
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"
The # specifies where you want to fit digits and the \\ including the space in between specifies where you want strings. These are the only formatting specifiers I remember off the top of my head.

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.


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.
alphagemini is offline  
Old 13 September 2012, 13:43   #11
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,194
Quote:
Originally Posted by prowler View Post
HiSoft Basic 2.0 Manual-on-disk is in The Zone for you.
Thanks a lot! Been looking for this everywhere.

Quote:
Originally Posted by alphagemini View Post
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
Yes I understand, the manual is more of a reference and not so much a guide to programming for someone just starting out. Glad you got the formatting sorted out.
Leffmann is offline  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic help wanted alphagemini Coders. General 6 07 March 2013 23:35
Manuals for GFA Basic and Hi-Soft Basic 2 ricky500 request.Apps 20 12 February 2013 22:06
Hi Soft Basic help wanted alphagemini Coders. General 4 11 January 2013 12:39
Alarm program in Hi Soft basic alphagemini Coders. General 6 05 August 2012 19:00
Basic Vector Code wanted redblade Coders. General 16 24 December 2005 06:41

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

Forum Jump


All times are GMT +2. The time now is 05:24.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.07206 seconds with 13 queries