|
>> I wouldn't say to *never* use strtok, but you had better know what it does before using it. While Jim is correct in absolute terms, and it _is_ important to know how the function works, I wouldn't worry about it too much. Why? Because the best way to use strtok with RPG IV is to code the proto to pass a pointer by value and use options(*String) as I demonstrated in the Redbook example of using strtok. The proto looks like this: D StrTok Pr * ExtProc('strtok') D String@ * Value Options(*String) D Delimiters@ * Value Options(*String) This has a number of benefits - one of which is that if you pass the name of the field (or an expression or a constant) to the function, it will always generate a null terminated _copy_ of the data and pass that to strtok. Since the function is handling a copy there is no problem. As noted this also allows the use of constants (for the delimiters for example) and there is no need to mess about with adding hex zero to the end of the string! Jon Paris Partner400
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.