INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Using a variable name to create/open files

Using a variable name to create/open files

(OP)
I'm using VFX Forth and i am only a beginner to Forth programming. Is it possible to use a variable name to open or/and create a file in Forth? I have only be able to create a file name when I hard code a file name and path – such as s" c:\1 Wire Data.csv" open-output

Any pointers would greatly appreciated! (see my code below)

Create Datafname 256 allot
0 Value fd-out
\ File I/O words ****************************
: open-output ( addr u -- ) w/o create-file throw to fd-out ;
: close-output ( -- ) fd-out close-file throw ;
\ *******************************************
\ Enter data file name word***************************
: datafilename-Create
cr ." Enter datafile name and path (i.e. C:\foldername\filename.csv) : " pad 40 accept
pad swap Datafname place
cr ." Data file to be saved to : " Datafname count type
;
\ ********************************************
\ Create data file word***************************
: createdatafile
Datafname count open-output
close-output
Datafname count r/w open-file throw to fd-out
s" Time, Temp1, Temp2, Day, Date, Read Count" fd-out write-line
;
\ ********************************************
Createdatafile
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close