|
There's always the dilemma of defining and enforcing contracts. If you can't trust the people who call your procedures to do it correctly, then either you aren't communicating those requirements correctly, or they're not very good programmers. Neither option bodes well for long term software quality. However, there is a sort of halfway position. Just check the last position of the passed string. If it's blank, trim it. I think something like this will work: If (%len(var) > 0) and ((%subst(var): %len(var): 1) = ' '); %len(var) = %len(%trim(var)); Endif; Joe
From: albartellCatPath += ('cat=' + %char(CatArr(i)) + '&');I like using this syntax along with VARYING fields (for all of the obvious reasons), but the thing I struggle with is when I need to be ensured that something does not have trailing blanks (e.g. concatenating a IFS stream file path). This seems to be the case more often than not. A lot (nearly all) of my development is done with RPG ILE service program sub procs. So I am constantly providing interfaces to other programmers. I am not so worried about them implementing the interface correct (i.e. using VARYING in their programs), but more so that they aren't ensuring the absence of blanks in strings before they pass them on to sub procs I create. Sure I could just insert a few more %TRIM's here and there to bullet proof my programs, but then I just lost some of the benefit I was trying to gain.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.