SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 9 of 9
  1. #1
    Super Member
    Join Date
    Jul 2002
    Posts
    1,769
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    How to find variable filenames in TSL? ...

    I have a need to open up a text file each day (via WR) and do some work with it. But I don't know everything about the filename ahead of time. The filename is prepended with the date, and has a timestamp from the file creation in the middle of the name.

    For example, today I may see this file:
    "20060323_1-31-9_awqqltr.txt"

    I will always now that the date at the beginning is the current date, and I know that the filename always ends in "awqqltr.txt".

    The "1-31-9" in the middle refers to 01:31:09 AM, I don't particularly care what the actual value is, other than I won't know it ahead of time, it could be anything.


    What is an elegant way for me to determine the filename at runtime so that I can open it?

    Thanks very much in advance,

    Chris

  2. #2
    Super Member
    Join Date
    Jul 2002
    Posts
    1,769
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to find variable filenames in TSL? ...

    I don't think file_open() will accept a regex as a an argument, will it?

  3. #3
    Moderator
    Join Date
    Mar 2000
    Location
    Orange County, CA
    Posts
    3,187
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to find variable filenames in TSL? ...

    I can see a couple of ways to do it, but the easiest would be to once you pull the file names available in the directory you expect them to be in, loop through each one and just perform a split on the "_" character.

    Once you do that, you then have an array of the sections of the file. The first element would be the data format you expect, the last element would be the file extension.

    You'd just then have to check the contents of the array to see if it fits what you need.


    Another way is just a simple substr command to look at the first portion of the file and the last part of the file you expect, then if it matches you are set.
    Insanity: doing the same thing over and over again and expecting different results

  4. #4
    Moderator
    Join Date
    Mar 2000
    Location
    Orange County, CA
    Posts
    3,187
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to find variable filenames in TSL? ...

    Originally posted by cmeisenzahl:
    I don't think file_open() will accept a regex as a an argument, will it?
    <font size="2" face="Verdana, Arial, Helvetica">No it won't unfortunately.

    You'd have to work out in code to loop through all available files and then step through each one and work in how to look at each one
    Insanity: doing the same thing over and over again and expecting different results

  5. #5
    Senior Member
    Join Date
    May 2003
    Location
    Austria
    Posts
    1,480
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to find variable filenames in TSL? ...

    I guess
    dos_system("DIR /B C:\\yourdirectory\\" & currentdate & "_*_awqqltr.txt > C:\\tempfile.txt");
    and then reading tempfile.txt will be the easiest way to find the file you need to open...

    Regards,
    Juergen

  6. #6
    Moderator
    Join Date
    Mar 2000
    Location
    Orange County, CA
    Posts
    3,187
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to find variable filenames in TSL? ...

    well, that spoils the fun of it all bru [img]images/icons/wink.gif[/img]

    And you know the killer of it all? I use that no less than 10 times in various compiled modules and it didn't click in answering this question!

    I think I need more caffeine!

    [ 03-23-2006, 08:26 AM: Message edited by: Tony Davis ]
    Insanity: doing the same thing over and over again and expecting different results

  7. #7
    Super Member
    Join Date
    Jul 2002
    Posts
    1,769
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to find variable filenames in TSL? ...

    Thanks very much to both of you guys. ;-)

    Chris

  8. #8
    Senior Member
    Join Date
    May 2003
    Location
    Austria
    Posts
    1,480
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to find variable filenames in TSL? ...

    Originally posted by cmeisenzahl:
    Thanks very much to both of you guys. ;-)
    <font size="2" face="Verdana, Arial, Helvetica">I'll take the thanks - send a coffee to Tony... [img]images/icons/wink.gif[/img]

  9. #9
    Moderator
    Join Date
    Mar 2000
    Location
    Orange County, CA
    Posts
    3,187
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to find variable filenames in TSL? ...

    Packages thanks to bru to send off this afternoon


    oh glorious coffee! yummmm
    Insanity: doing the same thing over and over again and expecting different results

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 05:43 AM.

Copyright BetaSoft Inc.