none
ATTACH A SELECTED .PRG/.SCX FILE TO A SELECTED FOLDER PROGRAMATICALLY RRS feed

  • Question

  • I have a table with .prg & .scx files. I want to attach the files to selected folder in a Directory. How to do it thru a program

    S.Alagappan

    Sunday, June 23, 2019 10:31 AM

Answers

  • Not sure what level of help you really need, i.e. someone to write the code for you or just a general approach. Here's a general approach for now:

    1. Create a menu of file names in the main folder (see CREATE MENU). You can limit the menu list to prg & scx files using the ADIR() function.

    2. Assign the file name selected by user to a memory variable, e.g cFileName. See PROMPT() function.

    3. You can copy & delete the file with the COPY FILE and DELETE commands, but RENAME can do both in a single step:

    RENAME ('Accounts\'+m.cFileName) TO ('Accounts\Bank Routines\'+m.cFileName)

    Is this what you need? (I hope)

    Steve

    Friday, June 28, 2019 11:49 PM

All replies

  • It's simple if your files are outside the table - just use the COPY FILE command (see Help).

    If they are embedded in your table, copy (or move?)  them to a folder then use above method. You may need the STRTOFILE function (see Help).

    HTH

    Steve


    Monday, June 24, 2019 2:16 PM
  • Both answers do no work. I have the name of the file in a Table i.e., BANK_PB_NEW.PRG" . I want to attach this name to a folder 'BANK ROUTINES'. NEITHER COPY FILE OR COPY OR STRTOFILE WORKS

    S.Alagappan

    Thursday, June 27, 2019 5:57 AM
  • Hello,

    not sure what you want to achive. Why store .prg and.scx/.sct in a table You could generate an exe ??

    You can use filetostr() to read the .scx/.sct.prg into a variable, then store the content of the var into a memobin field of a table, maybe together with another field containing the name.

    To restore it seek the record(s), scatter the content, then strtofile() it into a .scx,.. file

    regards

    tom

    Thursday, June 27, 2019 6:53 AM
  • To get a precise understanding of your situation:

    When you say you have the NAME of the file in a table, is it the name ONLY or is the file itself also in the table?

    If the file is not in the table, where is it?. If it's in another folder, the COPY FILE command should work. You may need the MKDIR command to create the folder if it doesn't exist.

    If the file is inside the table, Tom's solution should work.

    Steve

    Thursday, June 27, 2019 1:27 PM
  • I have a folder containing all my PRG/SCX files which I use to execute the routines. Over time, I create PRG/SCX files for testing new routines. When these files are not required, I want to remove them from the main folder "ACCOUNTS" and transferred the files to a Table (thru ADIR and append from array) stored as samples & retrieval if needed. Since my ACCOUNTS Project has many menus, I want to transfer the files in the table to relevant sub directories inside the main ACCOUNTS Directory. I have created the sub directories e.g., BANK ROUTINES with MKDIR. THE TABLE CONTAINS prg/scx FILE NAMES. These can be opened and modified if needed. 

    I WANT TO TRANSFER THESE TO THE SUB DIRECTORY CREATED AND DELETE THEM FROM THE TABLE

    Alagappan S


    S.Alagappan

    Thursday, June 27, 2019 2:05 PM
  • Show us the exact code you're using. There may just be a mistake we can help you fix.

    Tamar

    Friday, June 28, 2019 8:30 PM
    Moderator
  • Not sure what level of help you really need, i.e. someone to write the code for you or just a general approach. Here's a general approach for now:

    1. Create a menu of file names in the main folder (see CREATE MENU). You can limit the menu list to prg & scx files using the ADIR() function.

    2. Assign the file name selected by user to a memory variable, e.g cFileName. See PROMPT() function.

    3. You can copy & delete the file with the COPY FILE and DELETE commands, but RENAME can do both in a single step:

    RENAME ('Accounts\'+m.cFileName) TO ('Accounts\Bank Routines\'+m.cFileName)

    Is this what you need? (I hope)

    Steve

    Friday, June 28, 2019 11:49 PM
  • p.s. Don't forget to include the .sct file when moving its .scx file.
    Friday, June 28, 2019 11:56 PM
  • I made a stupid mistake in coding. Instead of the contents of the variable I transferred the variable. I have corrected and the job is done.Thank you

    S.Alagappan

    Saturday, June 29, 2019 4:09 AM