Page 1 of 1

[01 Jun 2009] manually adding extension to a file

Posted: Sat Jun 13, 2020 5:32 pm
by GMKai
Note: This is an archived post that was originally sent to the Hollywood mailing list on 01 Jun 2009 16:50:26 +0100

Hello, currently I am trying to maintain some fileextensions. When a requester returns I want to save a table to the given file. The file itself should be named in a special way, ending with ".hsmdb", but with the given code below I get an error in the OpenFile-line. To me it looks like the path derived from the requester gets changed in an illegal way in the subfunction "p_CheckAppendSuffix", but what am I doing wrong?

Regards GMKai

Code: Select all

Function p_SaveTab(f$)
    f$=p_CheckAppendSuffix(f$)
    OpenFile(1,f$,#MODE_WRITE)
    Seek(1,0)
    /*save tables To file*/
    WriteTable(1,t_masterdata)
    CloseFile(1)
EndFunction

Function p_CheckAppendSuffix(f$)
    path=PathPart(f$)
    file=FilePart(f$)
    suffix=".hsmdb"
    right=RightStr(file,6)
    DebugPrint(right)
    DebugPrint(suffix)
    If (right<>suffix)
        file=file..suffix
        f$=FullPath(path,file)
    EndIf()
    Return f$
EndFunction  

[13 Jun 2009] Re: manually adding extension to a file

Posted: Sat Jun 13, 2020 5:32 pm
by airsoftsoftwair
Note: This is an archived post that was originally sent to the Hollywood mailing list on Sat, 13 Jun 2009 17:12:15 +0200
Hello, currently I am trying to maintain some fileextensions. When a requester returns I want to save a table to the given file. The file itself should be named in a special way, ending with ".hsmdb", but with the given code below I get an error in the OpenFile-line. To me it looks like the path derived from the requester gets changed in an illegal way in the subfunction "p_CheckAppendSuffix", but what am I doing wrong?
I didn't run your code but from a first glance I can see that you're doing a

Return f$

at the end of your function. This won't work because return values must be enclosed in parentheses. If there are no parentheses, Hollywood will assume Nil as the return value. Correct version would be:

Return(f$)