C-touch Reading text files from disk.

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by Dave Byron, Dec 8, 2008.

  1. Dave Byron

    Dave Byron

    Joined:
    Aug 3, 2004
    Messages:
    835
    Likes Received:
    0
    Location:
    Casurina
    Can the C-Touch read text files from disk ?
    And were do I find examples of the logic code to perform this ??


    From the help file;
    The syntax for reading file data is:
    Read(FileName, Variable_List);
    FileName is the name of a file variable (either file1 or file2)
    Variable_List is a series of variable identifiers separated by commas.


    The EOF function tests whether the file position is at the end of a file.
    The Reset procedure opens an existing file for reading.
    The CloseFile procedure closes a file.
    The AssignFile procedure assigns a file name to a file variable.

    These are not applicable for use with the Pascal Automation Controller or C-Touch.

    Dave
     
    Dave Byron, Dec 8, 2008
    #1
  2. Dave Byron

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Files can be used with colour C-Touch, but not black and white C-Touch. When you see "C-Touch", assume black and white C-Touch.
     
    Darren, Dec 8, 2008
    #2
  3. Dave Byron

    Dave Byron

    Joined:
    Aug 3, 2004
    Messages:
    835
    Likes Received:
    0
    Location:
    Casurina
    Thanks Darren,
    Now does the file have to be in a directory as specific by the project name in the Piced setup.
    ie If the file exists in the project directory, the result is true, otherwise it is false

    My file exists fails.
    logic as per image 1

    and the directory layout on hard disk

    one line you would think i could that right.

    dave
     

    Attached Files:

    Last edited by a moderator: Dec 8, 2008
    Dave Byron, Dec 8, 2008
    #3
  4. Dave Byron

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Dave,

    I am not sure what is going wrong for you. As long as the file is in the folder where the project is stored, it should find it. I just tried this:

    Code:
    if FileExists('MyFile.txt') then
    begin
      WriteLn('File Found');
      AssignFile(file1, 'MyFile.txt');
      Reset(file1);
      CloseFile(file1);
    end
    else
      WriteLn('File not Found');
    And it correctly reported whether the file was found or not.

    Are you 100% sure that the file is in the right folder :confused:
     
    Darren, Dec 8, 2008
    #4
  5. Dave Byron

    Dave Byron

    Joined:
    Aug 3, 2004
    Messages:
    835
    Likes Received:
    0
    Location:
    Casurina
    Darren
    is what I showed the correct directory ???

    see image

    with "basic" selected as project

    dave
     

    Attached Files:

    Dave Byron, Dec 8, 2008
    #5
  6. Dave Byron

    Dave Byron

    Joined:
    Aug 3, 2004
    Messages:
    835
    Likes Received:
    0
    Location:
    Casurina
    Darren
    Got it - Piced's "project directory" is the directory that Piced source file (calender3.ctp) resides in and is nothing to do with the "project" selected within Piced.

    Think the Help file should be make clearer on this.

    See image

    Tks
    dave
     

    Attached Files:

    Dave Byron, Dec 8, 2008
    #6
  7. Dave Byron

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    I am still not 100% clear on what you have done. Are you editing a template called "calendar3.ctp" which is stored in C:\Clipsal\PICED\Templates\Logic ?

    Or did you create a project using the above as a template?
     
    Darren, Dec 10, 2008
    #7
  8. Dave Byron

    Dave Byron

    Joined:
    Aug 3, 2004
    Messages:
    835
    Likes Received:
    0
    Location:
    Casurina
    Darren
    What I am doing is reading a text file that contains data to add to the calendar template - names and dates.
    What confused me was Piced was looking for the data file - the help file says the project directory which is a bit confusing, it should say the directory were the Piced opens the the project or template source.

    Now I now were it looking I can read the file.

    tks


    dave
     
    Dave Byron, Dec 15, 2008
    #8
  9. Dave Byron

    ColbyJarrett

    Joined:
    Mar 13, 2011
    Messages:
    1
    Likes Received:
    0
    Location:
    Tennessee
    readln

    I am try to do the same thing and can not get Piced to find the file. I assume it is in the wrong directory, but I have tried almost every one I can think of. from the discussion above, I thought the file should be in the Clipsal\piced\templates\logic, but this does not work. any help?
     
    ColbyJarrett, Mar 14, 2011
    #9
  10. Dave Byron

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    The text file should be in the folder where you have saved your project file.
     
    Darren, Mar 14, 2011
    #10
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.