Input troubles

whwar9739

Member
I am trying to import a record to a table. I would like to hard code it using something other than one long assign statement. I was thinking of using an input statment similar to the following:
Code:
INPUT THROUGH ECHO '"CHAR1" LOG1 INT1 DEC2 "CHAR2" "CHAR3"'.
CREATE temp-record.
IMPORT temp-record.
INPUT CLOSE.

And the result is not what I am expecting. I tried testing it using the following code example:
Code:
INPUT THROUGH echo '"CHAR1" LOG1 INT1 DEC2 "CHAR2" "CHAR3"'.
IMPORT UNFORMATTED text-string.
DISPLAY text-string WITH DOWN FRAME x.
DOWN WITH FRAME x.

When I run this simple test I get the following displayed:
echo: No match.

Can anyone help?

Thanks,
 

whwar9739

Member
I think I may have narrowed down my problem somewhat.

I have changed the code, for testing purposes, to something similar to the following:

Code:
OUTPUT TO mgf.test.
DEF TEMP-TABLE xpasswd LIKE passwd.
DEF VAR text-string AS CHAR FORMAT "x(76)".
DEF VAR text-string2 AS CHAR FORMAT "x(76)".
FIND FIRST runprm.
INPUT THROUGH echo """CHAR1"" ""CHAR2"" ""CHAR3"" ""CHAR4""  INT1 INT2 LOG1 DATE1 DATE2 INT3 INT4 INT5 INT6 ""CHAR5"" INT7 INT8 ""CHAR6"" ""CHAR7""".
IMPORT UNFORMATTED text-string.
PUT UNFORMATTED text-string.

And i get the expected results except for one thing, the extra quotes. I am wanting/needing to have it include a quote whenever there is a set of two or more double quotes.

Thanks,
 

MrMoo

Member
Wouldn't you have to escape the " so that it knows to place it in you input otherwise two adjacent "'s would be interpreted as an empty string? I am not sure what the escape is, maybe someone else would be able to help you on that, but you could try \".
 

whwar9739

Member
Exactly what I am looking for since my prior experience tells me that a double quote(") followed by another is the escape sequence for a double quote.

For example:
Code:
def var l-string char no-undo.
l-string = """".
display l-string.

Would result in a single double quote(") being displayed.
 

TomBascom

Curmudgeon
This works fine for me:

Code:
define variable text-string as character no-undo format "x(60)".

INPUT THROUGH echo '"CHAR1" LOG1 INT1 DEC2 "CHAR2" "CHAR3"'.
IMPORT UNFORMATTED text-string.
DISPLAY text-string WITH DOWN FRAME x.
DOWN WITH FRAME x.

I think that you must have tested something different to get "no match" as an error.
 

whwar9739

Member
I think in my test code I had something missing in terms of a quote or something.

However, I still need to get the quotes to show up around the character strings.

I would like to eventually move to being able to import that string into a table record.

Thanks,
 

whwar9739

Member
I think I may have finally found a solution.

I needed to, obviously, use an escape character. That character was the '\', however i needed to use it twice so that through out the process it was not lost completely. Example below:

Code:
INPUT THROUGH '\\"CHAR1\\"'.
[\code]
 
I also ran into another issue that was solved by the same problem. I wanted to print a '?' for a blank date and needed to use the escape character for that as well.
 
Thanks everyone for your help.
 
Top