Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Create a new file...diff path

UnrealDangerUnrealDanger Member Posts: 9
New question...my program will run from a cd-rom with external data files read from the cd. My problem is I want to create or move a file to the users hard drive to keep a log file. Can qbasic move files to a new location and write to them? Thanks.


Comments

  • PrzemekG_PrzemekG_ Member Posts: 595
    In Visual Basic there is a function called "FileCopy", if you don't have if, write your own.

    [code]
    source = "d:main.log"
    dest = "c:MyProgmain.log"
    open source for binary as inf
    open dest for binaty as outf

    do while not eof(inf)

    loop
    close inf, outf
    [/code]

    after "do while ..." you have to write yourself, read from the source and write to dest (using put and get commands)

  • billywm664billywm664 Member Posts: 176
    While Qbasic only has limited file functions of its own, it does have the SHELL command which executes any DOS command. Through SHELL you could use DOS's COPY command, like so:

    Shell "Copy D:frompathfromfile.ext C: opath"

    I don't know if you know anything about DOS, but i'll explain it in case not:

    DOS, unlike windows, does everything via typed commands. To talk about file access in dos, you refer to them by 'paths', similar to an internet address: Htpp://....whatever.
    The copy command passed to DOS here by the shell command is saying "Look in D (ususally the DOS letter assigned to the CD, but it may not be, so make sure first) then look in the folder called 'frompath' (or any other folder name you want) and find the file named fromfile.ext (again.. any file will do, just an example). Then copy it to C (ususally the letter assigned to the harddrive) and put it in the folder (path) called 'topath'."

    Then once the file is copied to the new location, you can refer to it in your OPEN command instead of the one on the CD.


    : New question...my program will run from a cd-rom with external data files read from the cd. My problem is I want to create or move a file to the users hard drive to keep a log file. Can qbasic move files to a new location and write to them? Thanks.
    :
  • alan_pollockalan_pollock Member Posts: 110
    In addition to this, you may also want to examine DOS's IF and ERRORLEVEL statements as well. DOS sets an error condition in ERRORLEVEL if the copy / move fails... this condition can be mirrored to an environment variable, which can then be looked at by your program and acted upon accordingly.


    : While Qbasic only has limited file functions of its own, it does have the SHELL command which executes any DOS command. Through SHELL you could use DOS's COPY command, like so:
    :
    : Shell "Copy D:frompathfromfile.ext C: opath"
    :
    : I don't know if you know anything about DOS, but i'll explain it in case not:
    :
    : DOS, unlike windows, does everything via typed commands. To talk about file access in dos, you refer to them by 'paths', similar to an internet address: Htpp://....whatever.
    : The copy command passed to DOS here by the shell command is saying "Look in D (ususally the DOS letter assigned to the CD, but it may not be, so make sure first) then look in the folder called 'frompath' (or any other folder name you want) and find the file named fromfile.ext (again.. any file will do, just an example). Then copy it to C (ususally the letter assigned to the harddrive) and put it in the folder (path) called 'topath'."
    :
    : Then once the file is copied to the new location, you can refer to it in your OPEN command instead of the one on the CD.
    :
    :
    : : New question...my program will run from a cd-rom with external data files read from the cd. My problem is I want to create or move a file to the users hard drive to keep a log file. Can qbasic move files to a new location and write to them? Thanks.
    : :
    :

  • Chris BrownChris Brown USAMember Posts: 4,624 ✭✭

    _________ // http://forcoder.org // free ebooks and video tutorials about \ R C Objective-C Perl Python Visual Basic .NET C++ PHP Ruby Delphi JavaScript PL/SQL MATLAB Scratch Assembly Swift Java Go Visual Basic C# Prolog Clojure Lisp LabVIEW Alice Bash SAS Ada Crystal VBScript Scheme F# Erlang ABAP Julia COBOL Apex Fortran Transact-SQL Rust D ML Scala Dart Logo Hack Kotlin FoxPro Awk Lua \ ________

Sign In or Register to comment.