I am using a function in my program to pass a filename variable to a field, but i need to pass it to several fields. I know I could repeat the function for each variable but I also know that I can change where the variable is placed.
Here is the code ;
STATIC FUNCTION FileName
LOCAL cDir := ALLTRIM(CURDIR())
LOCAL cApp := ""
cApp := cGetFile( "*.rpt","Report Files",1,cDir)
IF cApp == "*.rpt"
cApp := "default"
ELSE
IF "\"$cApp
cApp := ALLTRIM(subst(cApp , rat("\",cApp)+1,12))
cApp := LEFT(cApp, LEN(cApp) - 4)
ENDIF
ENDIF
IF !Empty(cApp)
mReportID := Alltrim(cApp)+".rpt"
oReportID:Refresh()
ENDIF
RETURN NIL
What I need to know is, how can I tell my program to change where the outcome is stored without rewriting it for each variable?
passing a function several times?
-
- Posts: 22
- Joined: Wed Nov 09, 2005 9:43 am
- Contact:
-
- Posts: 54
- Joined: Fri Oct 21, 2005 10:45 am
- Location: Russia, Moscow
- Contact:
Sorry I have not understood exactly what do you want.What I need to know is, how can I tell my program to change where the outcome is stored without rewriting it for each variable?
Maybe the code below can give you some ideas?
STATIC cApp := ""
STATIC FUNCTION SetRptName()
/*
the body of the function almost the same as the body of your function FileName()
*/
...
RETURN ( NIL )
STATIC FUNCTION GetRptName()
RETURN ( cApp )
-
- Posts: 22
- Joined: Wed Nov 09, 2005 9:43 am
- Contact:
maybe this will explain my question better?
CODE ;
STATIC FUNCTION FileName
LOCAL cDir := ALLTRIM(CURDIR())
LOCAL cApp := ""
cApp := cGetFile( "*.rpt","Report Files",1,cDir)
IF cApp == "*.rpt"
cApp := "default"
ELSE
IF "\"$cApp
cApp := ALLTRIM(subst(cApp , rat("\",cApp)+1,12))
cApp := LEFT(cApp, LEN(cApp) - 4)
ENDIF
ENDIF
IF !Empty(cApp)
mReportID := Alltrim(cApp)+".rpt"
oReportID:Refresh()
ENDIF
IF !Empty(cApp)
mFileProof := Alltrim(cApp)+".rpt"
oFileProof:Refresh()
ENDIF
IF !Empty(cApp)
mFinalFile := Alltrim(cApp)+".rpt"
oFinalFile:Refresh()
ENDIF
IF !Empty(cApp)
mReprint := Alltrim(cApp)+".rpt"
oReprint:Refresh()
ENDIF
RETURN NIL
the problem is, they all refresh with the same value, and I want each o:refresh to be able to hold a seperate value?
thanks for any help!
CODE ;
STATIC FUNCTION FileName
LOCAL cDir := ALLTRIM(CURDIR())
LOCAL cApp := ""
cApp := cGetFile( "*.rpt","Report Files",1,cDir)
IF cApp == "*.rpt"
cApp := "default"
ELSE
IF "\"$cApp
cApp := ALLTRIM(subst(cApp , rat("\",cApp)+1,12))
cApp := LEFT(cApp, LEN(cApp) - 4)
ENDIF
ENDIF
IF !Empty(cApp)
mReportID := Alltrim(cApp)+".rpt"
oReportID:Refresh()
ENDIF
IF !Empty(cApp)
mFileProof := Alltrim(cApp)+".rpt"
oFileProof:Refresh()
ENDIF
IF !Empty(cApp)
mFinalFile := Alltrim(cApp)+".rpt"
oFinalFile:Refresh()
ENDIF
IF !Empty(cApp)
mReprint := Alltrim(cApp)+".rpt"
oReprint:Refresh()
ENDIF
RETURN NIL
the problem is, they all refresh with the same value, and I want each o:refresh to be able to hold a seperate value?
thanks for any help!
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
-
- Posts: 22
- Joined: Wed Nov 09, 2005 9:43 am
- Contact:
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
-
- Posts: 22
- Joined: Wed Nov 09, 2005 9:43 am
- Contact:
-
- Posts: 54
- Joined: Fri Oct 21, 2005 10:45 am
- Location: Russia, Moscow
- Contact:
I think you should rewrite your function such a way that it returns not NIL but cApp. In your main code you will have the following
LOCAL cApp
.....
IF ( !EMPTY( cApp := FileName() ) )
mReportID := Alltrim(cApp)+".rpt"
oReportID:Refresh()
ENDIF
.....
Or you can write general function as for example AssignVal()
FUNCTION AssignVal( &cVarName, oObject )
and call it for various arguments as below
AssignVal( &mReportID, oReportID )
AssignVal( &mFileProof, oFileProof )
and so on.
LOCAL cApp
.....
IF ( !EMPTY( cApp := FileName() ) )
mReportID := Alltrim(cApp)+".rpt"
oReportID:Refresh()
ENDIF
.....
Or you can write general function as for example AssignVal()
FUNCTION AssignVal( &cVarName, oObject )
and call it for various arguments as below
AssignVal( &mReportID, oReportID )
AssignVal( &mFileProof, oFileProof )
and so on.