View previous topic :: View next topic
|
Author |
Message |
EternalQuest
New User
Joined: 24 Dec 2009 Posts: 4 Location: Chennai
|
|
|
|
Hi,
I am trying to update (concatenate a string and a compound variable) a record in a file. I used the following statements
Rexx Code:---------
"EXECIO 1 DISKRU MEMSTAT 1(STEM LINE."
SAY LINE.1 /* Output: Test
TEST.1 = LINE.1||" Successful "
SAY TEST.1 /* Output: Test
"EXECIO 1 DISKW MEMSTAT (STEM TEST. FINIS"
-----------------------
MEMSTAT has a single record with value "Test". I want to add string "Successful" to the existing record and update the same file, so the result should be "Test Successful". But the above code is not giving the expected result. It only prints "Test".
However, the below test is working fine, i.e., adding a string to the front of LINE.1
but my requirement need the above result.
REXX Code:------------
"EXECIO 1 DISKRU MEMSTAT 1(STEM LINE."
SAY LINE.1 /* Output: Test
TEST.1 = " Successful "||LINE.1
SAY TEST.1 /* Output: Successful Test
"EXECIO 1 DISKW MEMSTAT (STEM TEST. FINIS"
--------------------------
Could you please help me with that? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
I am trying to update (concatenate a string and a compound variable) a row in a file. |
Terminology note: files do not have rows. Databases have rows. Files have records. Hence, by definition, what you are wanting to do cannot be done since there are no rows in files.
There are many terms in IT that are very precisely defined, mistaking rows for records as you have done indicates at best a degree of carelessness in your approach, at worst that you have no idea what you are doing. |
|
Back to top |
|
|
EternalQuest
New User
Joined: 24 Dec 2009 Posts: 4 Location: Chennai
|
|
|
|
Sorry Robert,
The input file is a flat file. I mistakenly mentioned as row instead of record. Now I have corrected it. |
|
Back to top |
|
|
fayazbashask
New User
Joined: 28 Jun 2007 Posts: 9 Location: Hyderabad
|
|
|
|
Hi, when you read the data from dataset, for example 80 bytes record, it will be stored in the stem variable. After that you are concatenating the value with Successful so the value becomes 80 chars and successful, lets say totally 90 characters. again you are updating the dataset record of 80 bytes, so it will take the first 80 bytes.
solution1:
read the record from the dataset in updatable mode.
STRIP the value in the stem variable and then append what you want to, then write it.
(just add value = strip(value,"b") before you append)
solution2:
read the record from the dataset in updatable mode.
Parse the value from the stem variable and then position the value what you want to, then write it. |
|
Back to top |
|
|
EternalQuest
New User
Joined: 24 Dec 2009 Posts: 4 Location: Chennai
|
|
|
|
@ fayazbashask
Awesome dude. I got it!!!
I used the 1st option, thanks for your timely help. |
|
Back to top |
|
|
|