programming tools for Windows applications development
  Home  |   SwiftForth Archive  |   SwiftX Archive  |

Re: creating folders

From: Mike Ghan <mikeghan_at_logix-controls.com>
Date: Sat, 4 Oct 2003 08:39:18 -0700

Virgil,

It appears your data directories are subdirectories of where your
SwiftForth application executable resides. The following snip returns
your app's pathname without a trailing \.

THIS-EXE-NAME -NAME \ Returns app pathname

If you specify the entire pathname both when creating a directory and
when opening/creating a file there is no ambiguity. The current
directory would be irrelevant.

To create a directory:

THIS-EXE-NAME -NAME
PAD ZPLACE S" \" PAD ZAPPEND \ "base" directory
BuildFN ZCOUNT -NAME PAD ZAPPEND \ add subpath
PAD 0 CreateDirectory

To open a file:

THIS-EXE-NAME -NAME
PAD ZPLACE S" \" PAD ZAPPEND \ "base" directory
BuildFN ZCOUNT PAD ZAPPEND \ add subpath\filename
PAD R/W CREATE-FILE

You could, of course, use any directory arrangement in place of
THIS-EXE-NAME -NAME, for example S" C:\MyData\2003".

Mike

-----Original Message-----
From: sftalk-bounce_at_forth.com [mailto:sftalk-bounce_at_forth.com]On
Behalf
Of Virgil Stamps
Sent: Friday, October 03, 2003 4:24 PM
To: sftalk_at_forth.com
Subject: [sftalk] Re: creating folders

Roger,
I needed something that would create a directory each day and
periodically
store chromatogram log files there.
Directories defined yymmdd and files were hhmmss.crm
Here is what I came up with... The ususal warnings apply. I have a
problem
with it because if I change directories for some other file operation
within
my program, ?TodayDirectory will happily create a directory in the
new
path. That issue not solved yet.
Virgil

---
CREATE nameholder  256 ALLOT  nameholder 256 ERASE
: BuildFN ( --a )
    (@date) 2000 - 10000 * swap 100 * + + 0
    <# # # # # # # #> NameHolder Zplace
    S" \" NameHolder Zappend
    (@time) 10000 * swap 100 * + + 0
    <# # # # # # # #> NameHolder Zappend
    S" .CRM" NameHolder Zappend
    NameHolder ;
: $>Z ( caddr n buf -- buf )
   2DUP 2>R  SWAP MOVE  2R> TUCK + 0 SWAP C! ;
: ?TodayDirectory  ( -- f)   \ true if same
    BuildFN ZCount -NAME
    PAD 256 OVER GetCurrentDirectory -PATH
    COMPARE 0= ;
: INVALID-FILE-OP ( addr  -- )   hmenuMAIN SWAP  Z" File Operation"
MB_OK
    MessageBox    IDRETRY <> ;
: AutoFileSave  ( -- )
    ?TodayDirectory NOT
    IF  BuildFN ZCount  -NAME PAD $>Z SetCurrentDirectory 0=
        IF  PAD 0 CreateDirectory 0=
            IF  Z" Can't Create Directory" INVALID-FILE-OP  EXIT  THEN
            PAD SetCurrentDirectory 0=
            IF  Z" Invalid Directory" INVALID-FILE-OP  EXIT  THEN
        THEN
    THEN
    NameHolder ZCOUNT -PATH W/O CREATE-FILE
    IF  Z" Can't Create File" INVALID-FILE-OP  EXIT THEN
    DUP  >R   ['] SEND-CHROMO CATCH  IF DROP THEN
    R> CLOSE-FILE DROP ;
---
----- Original Message -----
From: "Roger Dube" <rdube_at_entropylock.com>
To: <sftalk_at_forth.com>
Sent: Friday, October 03, 2003 6:46 AM
Subject: [sftalk] creating folders
> I need a suggestion:
> I can create, rename and delete files with no problem, but I can't
find a
way to create a folder... in fact, the same functions for a folder
would be
nice... can someone suggest where I might look to be able to create
such
words?
>
> Thanks.
>
> - Roger
> --------------------------------------------------------------------
--
> Dr. Roger Dube
>
> RogerDube_at_datHQ.com
> President/CEO
> Digital Authentication Technologies, Inc.
> http://www.datHQ.com/
> TEL +1.561.392.7404
> FAX +1.561.892.2474
>
> PO Box 811564
> Boca Raton, FL 33481-1564
>
----------------------------------------------------------------------
sftalk_at_forth.com      The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users.  For product support and
bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
----------------------------------------------------------------------
sftalk_at_forth.com      The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users.  For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Sat Oct 04 2003 - 08:43:02 PDT

This archive was generated by hypermail 2.2.0 : Wed Jan 07 2009 - 03:04:10 PST