Results 1 to 6 of 6

Thread: Putfile() error

  1. #1
    Senior Member
    Join Date
    Jan 2016
    Posts
    160

    Putfile() error

    I followed the example in the documentation for Putfile() function, but am getting an error if I add expc1 and expc3. without these it appears to work. Any ideas?

    example:
    cProgramSaveAs = putfile("Save the program","default.prg","prg")

    My code:
    copy to putfile("Save file As:","payrollexport.csv","csv") fields id, classify, category, amount, blank1, blank2, blank3 delimited

    Helps if I give the error:

    **** Lianja error ****
    to putfile("Save file As:","payrollexport.csv","csv") fields id, classify, category, amount, blank1, blank2, blank3 delimited

    ^
    Syntax error in command
    Called from procedure - pto_menu_export_click at line 108

    I have since tried to save the file path to a variable and that that point the dialog box comes up, but still gives the following error:

    **** Lianja error ****
    to test2 fields id, classify, category, amount, blank1, blank2, blank3 delimited

    ^
    Field variable was expected
    Called from procedure - pto_menu_export_click at line 108

    If I use putfile() by itself, it works properly.
    Last edited by rdd1963; 2019-02-24 at 23:52.

  2. #2
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Hi,

    Saving path is way to go.
    COPY TO is problematic. You can simulate this error in Southwind database:

    Code:
    open database southwind
    use customers
    copy to aaa fields customerid,companyname
    *  OK
    copy to aaa fields customer id, companyname
    * error if typo in table column name "customerid" vs. "customer id"
    **** Lianja error ****
    copy to aaa fields customer id, companyname
    ^
    Field variable was expected
    Check your table column names.

    Isn't "Field variable" misleading in the error?
    Imagine this:
    Code:
    id="customerid"
    copy to aaa fields &id, companyname
    * OK

    Josip
    Last edited by josipradnik; 2019-02-25 at 04:09.

  3. #3
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,848
    Hi RD,

    Enclose the putfile() in brackets so it is evaluated:

    Code:
    copy to (putfile("Save file As:","payrollexport.csv","csv")) fields id, classify, category, amount, blank1, blank2, blank3 delimited
    Regards,

    Yvonne

  4. #4
    Senior Member
    Join Date
    Jan 2016
    Posts
    160
    Thanks Yvonne,

    Here a a couple things I noticed. The pre-populated filename of payrollexport.csv did not appear. I had to type it in manually and noticed that if I don't put the file extension on it, it will not include it even though .cvs is noted as he save as type.

    Also if I hit cancel from the save as dialog box, I get the following error:

    **** Lianja error ****
    to (putfile("Save CBiz Export File","payrollexport.csv","csv")) fields id, classify, category, amount, blank1, blank2, blank3 delimited

    ^
    Filename was expected
    Called from procedure - pto_menu_export_click at line 108

  5. #5
    Senior Member
    Join Date
    Jan 2016
    Posts
    160
    Thanks Yvonne,

    Here a a couple things I noticed. The pre-populated filename of payrollexport.csv did not appear. I had to type it in manually and noticed that if I don't put the file extension on it, it will not include it even though .cvs is noted as he save as type.

    Also if I hit cancel from the save as dialog box, I get the following error:

    **** Lianja error ****
    to (putfile("Save CBiz Export File","payrollexport.csv","csv")) fields id, classify, category, amount, blank1, blank2, blank3 delimited

    ^
    Filename was expected
    Called from procedure - pto_menu_export_click at line 108

    This was after I put the statement in brackets.
    Last edited by rdd1963; 2019-02-25 at 11:24.

  6. #6
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,848
    Hi RD,

    Can you submit a ticket for the pre-populated filename not appearing and file extension required. https://www.lianja.com/support/newticket

    If you cancel, then putfile() will return an empty string, so depending on whether you want to force the copy and a filename or cancel the operation completely you need to handle that.

    Regards,

    Yvonne

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us