Greetings.
Can some one help to transalate this:
DEFINE INPUT PARAMETER RUTA AS CHAR NO-UNDO.
DEFINE OUTPUT PARAMETER NOMARCH AS CHAR NO-UNDO.
DEFINE OUTPUT PARAMETER EXTARCH AS CHAR NO-UNDO.
DEFINE VAR I AS INTEGER NO-UNDO.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
/* ******************** Preprocessor Definitions ******************** */
&Scoped-define PROCEDURE-TYPE Procedure
&Scoped-define DB-AWARE no
/* _UIB-PREPROCESSOR-BLOCK-END */
&ANALYZE-RESUME
/* *********************** Procedure Settings ************************ */
&ANALYZE-SUSPEND _PROCEDURE-SETTINGS
/* Settings for THIS-PROCEDURE
Type: Procedure
Allow:
Frames: 0
Add Fields to: Neither
Other Settings: CODE-ONLY COMPILE
*/
&ANALYZE-RESUME _END-PROCEDURE-SETTINGS
/* ************************* Create Window ************************** */
&ANALYZE-SUSPEND _CREATE-WINDOW
/* DESIGN Window definition (used by the UIB)
CREATE WINDOW Procedure ASSIGN
HEIGHT = 3.67
WIDTH = 63.4.
/* END WINDOW DEFINITION */
*/
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
/* *************************** Main Block *************************** */
/* First: strip disc if present */
I = INDEX(RUTA, ":").
IF I > 0 THEN RUTA = SUBSTRING(RUTA, I + 1).
/* get filename, if there is extension...*/
I = INDEX(RUTA, ".").
IF I > 0 THEN DO:
EXTARCH = SUBSTRING(RUTA, I + 1).
RUTA = SUBSTRING(RUTA, 1, I - 1).
END.
ASSIGN I = R-INDEX(RUTA, "\").
IF I = 0 THEN DO:
ASSIGN I = R-INDEX(RUTA, "/").
END.
IF I > 0
THEN NOMARCH = SUBSTRING(RUTA, I + 1).
ELSE NOMARCH = RUTA.
RETURN.
into some method of system.IO, if available?
the object of procedure is to get just filename of a FQFN. On other procedure I have same kind of logic to get just the extensión..
TIA
Jorge Octavio
Are you looking for System.IO.Path:GetFileName()?
USING System.IO.*.
DEFINE VARIABLE vFile AS CHARACTER.
DEFINE VARIABLE fi AS FileInfo.
vFile = ".\testload.xml".
MESSAGE
"GetFileName: " Path:GetFileName(vFile) SKIP
"GetExtension: "Path:GetExtension(vFile) SKIP
"GetFileNameWithoutExtension: " Path:GetFileNameWithoutExtension(vFile) SKIP
"GetFullPath: " Path:GetFullPath(vFile) SKIP
"ChangeExtension: " Path:ChangeExtension(vFile,"foo") SKIP
"GetRandomFileName: " Path:GetRandomFileName() SKIP
"GetTempFileName: " Path:GetTempFileName() SKIP
"GetTempPath: " Path:GetTempPath()
VIEW-AS ALERT-BOX.
Indeed!!!!
Thanks a lot!!!!
(one side question: where is to get this info? MSDN?)
|
In general, when I need to figure something out using .Net, I use google and search for what I want to do along with .Net and sometimes C# as keywords. The C# examples are usually pretty easy to translate. Of course MSDN is good reference material but I usually go there only after getting a clue on what I need elsewhere.
I did a presentation on using .Net for things like this at the PugChallenge event in June. The slides and code examples are available here http://pugchallenge.org/downloads2015.html
Just wonder,... (And i guess it just slipped in)
the line about:
DEFINE VARIABLE fi AS FileInfo.
is doing something in the simple code? as I took it out and it worked the same...
This line was inadvertently left in when I copied what I posted from some code that used it. You don't need it but you might be interested in the .Net fileinfo class as an alternative to Progress's.