The following function combines the use of the Left and Right methods to create a Mid function that returns X letters from a string starting at Y position. The prototype is string sDataOut=Mid(string sDataIn, integer iStartPos, integer iEndPos, string sDataOut) The function is [-] string Mid(string sDataIn, integer iStart, integer iEnd, string sDataOut) [ ] integer i=0 [ ] string sData="" [ ] [ ] //Check that iStart and iEnd are NOT out of range compared to sData [-] if((iStart len(sDataIn)) || (iEnd len(sDataIn)-(iStart-1))) [ ] sDataOut="NULL" [-] else [ ] sData=Right(sDataIn,len(sDataIn)-(iStart-1)) [ ] sData=Left(sData,iEnd) [ ] sDataOut=sData [ ] return sDataOut The following testcase will act as proof of function: [-] testcase GetMidString() appstate none [ ] string sData="Borland Software" [ ] sMidString="" [ ] sMidString=Mid(sData,4,4,sMidString) [ ] print(sMidString) sMidString will return "land". Old KB# 20730
↧