Board Logo
« Dates to an array »

Welcome Guest. Please Login or Register.
Nov 22nd, 2017, 7:59pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Dates to an array  (Read 44 times)
FoxTrot
Full Member
ImageImageImageImage


member is offline

Avatar

Just your average, hard working, father, husband, computer technician, and college student.

YIM YIM
PM

Gender: Male
Posts: 453
xx Dates to an array
« Thread started on: May 1st, 2017, 9:37pm »

So, say I want to build an array of dates, but only specifics. Like, I want to build an array of only the next 12 Fridays, from the date the application was run. So, if I run it today (5/1/17), the array would build 5/5/17, 5/12/17, 5/19/17 and so on and so forth. I'd have to have it fluid, however, for any month, of any year.
On top of this, I think there are limitations toward arrays, such as only a specific number can be loaded (?). The issue here is in the application I am intending to produce, this number would have to be fluid as well.
I'm not asking for Arrays For Dummies, but a little tidbit would help. Thanks!

P.S. I've been out of the game for several years, but am in college, and my wife is now pushing me to code again. She helped me get past my block, and it feels good to be back, even if I am really rusty.
User IP Logged

We all want to be great; some just get there faster than others. Turn around and help the person behind you. They may need it more than you think, and they will remember your actions, if ever you should fall.
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1213
xx Re: Dates to an array
« Reply #1 on: May 2nd, 2017, 12:44am »

Hi Foxtrot,

Code:
'The date$ function is multi-purpose,
'if it gets a date format, it gives days since Jan 01, 1901
'if it gets an integer amount of day,s it gives a date in this format mm/dd/yyyy


Friday$ = "5/5/2017"  'get a date we know is Friday

thisFriday = date$(Friday$) ' days since Jan 01, 1901

weeks = 20  'say we want an array of 20 weeks (plus this Friday)

Dim Fridays$(weeks) 'get array ready, fits 21 Friday's thisFriday and 20 following

'processing loop
for i = 0 to weeks
    Fridays$(i) = date$(i*7 + thisFriday)  'i*7 days + thisFriday is day count, so Date$ returns date
    print "Fridays$(";i;") = ";Fridays$(i) 'check our array loading
next
print "Fridays$ array is ready!"

 


I think you should share the fun of coding with your wife. Perhaps on Fridays, make a date!
User IP Logged

B+
FoxTrot
Full Member
ImageImageImageImage


member is offline

Avatar

Just your average, hard working, father, husband, computer technician, and college student.

YIM YIM
PM

Gender: Male
Posts: 453
xx Re: Dates to an array
« Reply #2 on: May 2nd, 2017, 7:05pm »

That loop is beautiful, and I love the comments to understand the code! Thank you!

And actually, she has taken a liking to coding and has begun looking into BASIC commands, but she's the type that learns at her own pace.
User IP Logged

We all want to be great; some just get there faster than others. Turn around and help the person behind you. They may need it more than you think, and they will remember your actions, if ever you should fall.
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls