4GL code to trim text

I see two ways to do it Ted, using r-index to substring out the filename or entry(n, list, "\") to pull out the nth entry from a "\" delimited list. This code illustrates both ...

def var vcOpt as char no-undo inital "C:\documents\partlist\NewPart1234.pdf".
def var viTemp as int no-undo.
def var vcTemp as char no-undo.
def var vcFID as char no-undo.

assign
viTemp = num-entries(vcOpt, "~\")
vcFID = (if viTemp > 0 then entry(viTemp, vcOpt, "~\") else vcOpt)
vitemp = r-index(vcOpt, "~\").
if viTemp > 0 then do:
vcTemp = substring(vcOpt, viTemp + 1).
end.
return "Given: " + vcopt
+ '~n' + ' R-Index: ' + string(vitemp)
+ '~n' + ' Filename: ' + vctemp
+ '~n' + ' Entry(viTemp, vcOpt): ' + vcFID.

----------- output:

Given: C:\documents\partlist\NewPart1234.pdf
R-Index: 22
Filename: NewPart1234.pdf
Entry(viTemp, vcOpt): NewPart1234.pdf

Personally I like using NUM-ENTRIES( ) and ENTRY( ) when I don't have to deal with a portion of the resulting string. But either method would work.

Note the use of tilde ~\ to take the backslash literally as it is an escape cahracter in certain ABL contexts (just checked this in the ABL Ref and that might only be under Unix. Old habbits die hard!)

- Chris

--- In vantage@yahoogroups.com, "tkoch77" <tkoch77@...> wrote:
>
> In need of some 4GL code help. For example, I have a value that is C:\documents\stuff\Document1.docx and another time it could be C:\documents\partlist\NewPart1234.pdf. I want to return Document1.docx and NewPart1234.pdf from the strings. How can I tell it with 4GL code to always trim after the last "\"?
>
> Thanks for any help,
> Ted
>
In need of some 4GL code help. For example, I have a value that is C:\documents\stuff\Document1.docx and another time it could be C:\documents\partlist\NewPart1234.pdf. I want to return Document1.docx and NewPart1234.pdf from the strings. How can I tell it with 4GL code to always trim after the last "\"?

Thanks for any help,
Ted
Use the SUBSTRING() function coupled with R-INDEX().

R-INDEX ( source , target [ , starting ] )

R-INDEX() starts at the right and searches to the left of the string (as opposed to INDEX() which goes from left to right).

Something like this should work:

SUBSTRING(Your_Path_String, R-INDEX(Your_Path_String, “\”))



.



From: tkoch77
Sent: Monday, November 07, 2011 10:52 AM
To: vantage@yahoogroups.com
Subject: [Vantage] 4GL code to trim text


In need of some 4GL code help. For example, I have a value that is C:\documents\stuff\Document1.docx and another time it could be C:\documents\partlist\NewPart1234.pdf. I want to return Document1.docx and NewPart1234.pdf from the strings. How can I tell it with 4GL code to always trim after the last "\"?

Thanks for any help,
Ted




No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.1869 / Virus Database: 2092/4602 - Release Date: 11/07/11


[Non-text portions of this message have been removed]
Thanks Vic that worked.



________________________________
From: Vic Drecchio <vic.drecchio@...>
To: vantage@yahoogroups.com
Sent: Monday, November 7, 2011 11:13 AM
Subject: Re: [Vantage] 4GL code to trim text

Use the SUBSTRING() function coupled with R-INDEX().

R-INDEX ( source , target [ , starting ] )

R-INDEX() starts at the right and searches to the left of the string (as opposed to INDEX() which goes from left to right).

Something like this should work:Â

SUBSTRING(Your_Path_String, R-INDEX(Your_Path_String, “\”))



.



From: tkoch77
Sent: Monday, November 07, 2011 10:52 AM
To: vantage@yahoogroups.com
Subject: [Vantage] 4GL code to trim text

Â
In need of some 4GL code help. For example, I have a value that is C:\documents\stuff\Document1.docx and another time it could be C:\documents\partlist\NewPart1234.pdf. I want to return Document1.docx and NewPart1234.pdf from the strings. How can I tell it with 4GL code to always trim after the last "\"?

Thanks for any help,
Ted




No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.1869 / Virus Database: 2092/4602 - Release Date: 11/07/11


[Non-text portions of this message have been removed]



------------------------------------

Useful links for the Yahoo!Groups Vantage Board are: ( Note:Â You must have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and Crystal Reports and other 'goodies', please goto: http://groups.yahoo.com/group/vantage/files/.%c2%a0
(2) To search through old msg's goto: http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto: http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links



[Non-text portions of this message have been removed]
Vic,


I have another question related to 4GL code, how do you return a user name or ID and the current date/time?

Thanks,
Ted



________________________________
From: Vic Drecchio <vic.drecchio@...>
To: vantage@yahoogroups.com
Sent: Monday, November 7, 2011 11:13 AM
Subject: Re: [Vantage] 4GL code to trim text

Use the SUBSTRING() function coupled with R-INDEX().

R-INDEX ( source , target [ , starting ] )

R-INDEX() starts at the right and searches to the left of the string (as opposed to INDEX() which goes from left to right).

Something like this should work:Â

SUBSTRING(Your_Path_String, R-INDEX(Your_Path_String, “\”))



.



From: tkoch77
Sent: Monday, November 07, 2011 10:52 AM
To: vantage@yahoogroups.com
Subject: [Vantage] 4GL code to trim text

Â
In need of some 4GL code help. For example, I have a value that is C:\documents\stuff\Document1.docx and another time it could be C:\documents\partlist\NewPart1234.pdf. I want to return Document1.docx and NewPart1234.pdf from the strings. How can I tell it with 4GL code to always trim after the last "\"?

Thanks for any help,
Ted




No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.1869 / Virus Database: 2092/4602 - Release Date: 11/07/11


[Non-text portions of this message have been removed]



------------------------------------

Useful links for the Yahoo!Groups Vantage Board are: ( Note:Â You must have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and Crystal Reports and other 'goodies', please goto: http://groups.yahoo.com/group/vantage/files/.%c2%a0
(2) To search through old msg's goto: http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto: http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links



[Non-text portions of this message have been removed]
TODAY() will return the current system date.
TIME() returns seconds since midnight and then you need to parse together HH:MM:SS with formulas (not fun) (that’s why we have that useless “systime” column in PartTran and other tables)

Here’s a Crystal Formula to convert SysTime into something useful for most humans. 4GL also has a MOD command, so this could be done in Progress, too.

// Formula to convert SysTime field
//
Local Numbervar Minute := ({?SysTimeInput} mod 3600) / 60;
Local Numbervar Hour := Int ({?SysTimeInput} / 3600);
Local Numbervar Second := (Minute mod 60) / 60;
Local StringVar Hr := ToText(Hour,0);
Local StringVar Min := If Len(ToText (Minute,0)) = 1 then "0" + ToText (Minute,0) else ToText (Minute,0);
Local StringVar Sec := If Len(ToText (Second,0)) = 1 then "0" + ToText (Second,0) else ToText (Second,0);
Hr + ":" + Min + ":" + Sec


UserID in 4GL? Never tried this function but it may work: USERID [ ( logical-dbname ) ]

Perhaps something like USERID() should work fine. Good luck.

.


From: Ted Koch
Sent: Monday, November 07, 2011 11:28 AM
To: vantage@yahoogroups.com
Subject: Re: [Vantage] 4GL code to trim text


Vic,

I have another question related to 4GL code, how do you return a user name or ID and the current date/time?

Thanks,
Ted

________________________________
From: Vic Drecchio <mailto:vic.drecchio%40swepcotube.com>
To: mailto:vantage%40yahoogroups.com
Sent: Monday, November 7, 2011 11:13 AM
Subject: Re: [Vantage] 4GL code to trim text

Use the SUBSTRING() function coupled with R-INDEX().

R-INDEX ( source , target [ , starting ] )

R-INDEX() starts at the right and searches to the left of the string (as opposed to INDEX() which goes from left to right).

Something like this should work:

SUBSTRING(Your_Path_String, R-INDEX(Your_Path_String, “\”))

.

From: tkoch77
Sent: Monday, November 07, 2011 10:52 AM
To: mailto:vantage%40yahoogroups.com
Subject: [Vantage] 4GL code to trim text


In need of some 4GL code help. For example, I have a value that is C:\documents\stuff\Document1.docx and another time it could be C:\documents\partlist\NewPart1234.pdf. I want to return Document1.docx and NewPart1234.pdf from the strings. How can I tell it with 4GL code to always trim after the last "\"?

Thanks for any help,
Ted

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.1869 / Virus Database: 2092/4602 - Release Date: 11/07/11

[Non-text portions of this message have been removed]

------------------------------------

Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and Crystal Reports and other 'goodies', please goto: http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto: http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto: http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links

[Non-text portions of this message have been removed]




No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.1869 / Virus Database: 2092/4602 - Release Date: 11/07/11


[Non-text portions of this message have been removed]
DCD-USERID = Current User ID

Rob Bucek
Production Control Manager
PH: (715) 284-5376 ext 311
Mobile: (715)896-0590
FAX: (715)284-4084
[Description: cid:1.234354861@...]<http://www.dsmfg.com/>
(Click the logo to view our site)<http://www.dsmfg.com/>

From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of Vic Drecchio
Sent: Monday, November 07, 2011 10:51 AM
To: vantage@yahoogroups.com
Subject: Re: [Vantage] 4GL code to trim text



TODAY() will return the current system date.
TIME() returns seconds since midnight and then you need to parse together HH:MM:SS with formulas (not fun) (that’s why we have that useless “systime” column in PartTran and other tables)

Here’s a Crystal Formula to convert SysTime into something useful for most humans. 4GL also has a MOD command, so this could be done in Progress, too.

// Formula to convert SysTime field
//
Local Numbervar Minute := ({?SysTimeInput} mod 3600) / 60;
Local Numbervar Hour := Int ({?SysTimeInput} / 3600);
Local Numbervar Second := (Minute mod 60) / 60;
Local StringVar Hr := ToText(Hour,0);
Local StringVar Min := If Len(ToText (Minute,0)) = 1 then "0" + ToText (Minute,0) else ToText (Minute,0);
Local StringVar Sec := If Len(ToText (Second,0)) = 1 then "0" + ToText (Second,0) else ToText (Second,0);
Hr + ":" + Min + ":" + Sec

UserID in 4GL? Never tried this function but it may work: USERID [ ( logical-dbname ) ]

Perhaps something like USERID() should work fine. Good luck.

.

From: Ted Koch
Sent: Monday, November 07, 2011 11:28 AM
To: vantage@yahoogroups.com<mailto:vantage%40yahoogroups.com>
Subject: Re: [Vantage] 4GL code to trim text

Vic,

I have another question related to 4GL code, how do you return a user name or ID and the current date/time?

Thanks,
Ted

________________________________
From: Vic Drecchio <mailto:vic.drecchio%40swepcotube.com>
To: mailto:vantage%40yahoogroups.com
Sent: Monday, November 7, 2011 11:13 AM
Subject: Re: [Vantage] 4GL code to trim text

Use the SUBSTRING() function coupled with R-INDEX().

R-INDEX ( source , target [ , starting ] )

R-INDEX() starts at the right and searches to the left of the string (as opposed to INDEX() which goes from left to right).

Something like this should work:

SUBSTRING(Your_Path_String, R-INDEX(Your_Path_String, “\”))

.

From: tkoch77
Sent: Monday, November 07, 2011 10:52 AM
To: mailto:vantage%40yahoogroups.com
Subject: [Vantage] 4GL code to trim text

In need of some 4GL code help. For example, I have a value that is C:\documents\stuff\Document1.docx and another time it could be C:\documents\partlist\NewPart1234.pdf. I want to return Document1.docx and NewPart1234.pdf from the strings. How can I tell it with 4GL code to always trim after the last "\"?

Thanks for any help,
Ted

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.1869 / Virus Database: 2092/4602 - Release Date: 11/07/11

[Non-text portions of this message have been removed]




Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and Crystal Reports and other 'goodies', please goto: http://groups.yahoo.com/group/vantage/files/.<http://groups.yahoo.com/group/vantage/files/>
(2) To search through old msg's goto: http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto: http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links

[Non-text portions of this message have been removed]

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.1869 / Virus Database: 2092/4602 - Release Date: 11/07/11

[Non-text portions of this message have been removed]



[Non-text portions of this message have been removed]