I'm getting some data to view from public service
"www.ams.usda.gov/.../lm_pk601.txt" by using
oWebClient = NEW System.Net.WebClient().
oWebClient:DownloadFile("www.ams.usda.gov/.../lm_pk601.txt" , cFileName).
DELETE OBJECT oWebClient.
editor1:INSERT-FILE(cFileName)
but wonder if I would need to digest it and get some values from it, what would be the best way to do so?
[quote user="OctavioOlguin"]
I've been reading this, but can't imagine how would apply in 4GL
msdn.microsoft.com/.../system.string.split(v=vs.110).aspx
[/quote]
You can BOX an ABL Character value and CAST that to System.String to invoke the methods of the .NET System.String to that value.
DEFINE VARIABLE cDelimiters AS CHARACTER NO-UNDO EXTENT 1 . DEFINE VARIABLE cString AS CHARACTER NO-UNDO INIT "123,456,789". DEFINE VARIABLE cParts AS CHARACTER NO-UNDO EXTENT . cDelimiters [1] = "," . cParts = CAST (BOX (cString), System.String):Split (cDelimiters) . MESSAGE cParts [1] SKIP cParts [2] SKIP cParts [3] SKIP VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
However, when there is an ABL alterantive, like LOOKUP, ENTRY, SUBSTRING, etc.., I'd rather go with that.
so far:
DEFINE TEMP-TABLE tt1 FIELD renglon AS CHAR INDEX renglon IS WORD-INDEX renglon. DEFINE VARIABLE dayofReport AS INTEGER NO-UNDO. DEFINE VARIABLE dailyValue AS DECIMAL NO-UNDO. INPUT FROM d:\temp\lk601.txt. REPEAT: CREATE tt1. IMPORT UNFORMATTED renglon. END. FOR EACH tt1: IF index(renglon, "Des Moines, IA ") <> 0 THEN dayofReport = INTEGER (ENTRY (2, TRIM(ENTRY(3, renglon, ",")), " ")). IF index(renglon, "20-23# Trmd Selected Ham") <> 0 THEN dailyValue = DECIMAL(ENTRY (2, REPLACE(TRIM(ENTRY(3, renglon, "-")), " ", " "), " ")). END. MESSAGE "Day of report" dayofReport SKIP "Daily VALUE:" dailyValue VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
// the parts of dense substring manipulation is the area I would like to strengthen with less prone to error constructs (as file migth change someday)
I've been reading this, but can't imagine how would apply in 4GL
Also, there could be that some day, the price won't "open" (published) as in:
17-20# Trmd Selected Ham -
20-23# Trmd Selected Ham 14,512 55.77 - 62.22 56.62
23-27# Trmd Selected Ham -
Here, 17-20# and 23-27# did not open for that particular day
Also, there could be one day that price won't "open" (published), as in
17-20# Trmd Selected Ham -
20-23# Trmd Selected Ham 14,512 55.77 - 62.22 56.62
23-27# Trmd Selected Ham -
Here 17-20 and 23.27 won't opened for that particular day.
I've just found that there is same question here, of the same day I guess
[quote user="OctavioOlguin"]
I've been reading this, but can't imagine how would apply in 4GL
msdn.microsoft.com/.../system.string.split(v=vs.110).aspx
[/quote]
You can BOX an ABL Character value and CAST that to System.String to invoke the methods of the .NET System.String to that value.
DEFINE VARIABLE cDelimiters AS CHARACTER NO-UNDO EXTENT 1 . DEFINE VARIABLE cString AS CHARACTER NO-UNDO INIT "123,456,789". DEFINE VARIABLE cParts AS CHARACTER NO-UNDO EXTENT . cDelimiters [1] = "," . cParts = CAST (BOX (cString), System.String):Split (cDelimiters) . MESSAGE cParts [1] SKIP cParts [2] SKIP cParts [3] SKIP VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
However, when there is an ABL alterantive, like LOOKUP, ENTRY, SUBSTRING, etc.., I'd rather go with that.