Beginner question:
Assume that I have a string: 'PO - BOX 12345 - 999'. I want to start from the right, moving left, acquire the first hyphen. Once I do this, I want to set the portions to the right and left of the hyphen to different variables. How exactly do I do this. As I said I am beginner and not well versed in SQR. I am using the code below, which does look for a hyphen however it assumes that only one hyphen can exist in the string. Please help.
begin-procedure Check_Vendor_Information !!!Looking for the hyphen right here.
let #start_remit_char = 0
let $chk_vendor_setid = 'KMCTL'
get $chk_vendor_id from APSEND_HDR_REC_ARRAY(0) vendorcode
get $chk_vendor_loc from APSEND_HDR_REC_ARRAY(0) vendorloccode
let $chk_vendor_loc = rtrim($chk_vendor_loc,' ')
find '-' in $chk_vendor_loc 0 #hyphenloc
!display $chk_vendor_loc
if #hyphenloc = -1
!*******System Test Fix ... Fix format E. Pasha 11/28/01 ***************************************************
!let $eError_Message = ' No hyphen found in VendorLocCode on APSEND file'
let $eError_Message = ' No hyphen found in Vendor Loc Code on APSEND file'
let $eError_Message = $eValidation_Error||$eError_Message
!*************************************************************************************************************
do WRITE_ERROR_REPORT
let $Is_reject_flg = 'Y'
else
!*******System Test Fix ... get correct position for starting remit location extraction E. Pasha 11/27/01 ****
let #start_remit_char = #hyphenloc + 2 !get position after hyphen
let $chk_remit_addr_seq_num = substr($chk_vendor_loc,#start_remit_char,3)
let $chk_vendor_loc = substr($chk_vendor_loc,1,#hyphenloc)
!**************************************************************************************************************
end-if