Loop through a string in PowerBuilder

2k views Asked by At

First of all, I'm a noob at PowerBuilder and can't seem to find how to do this anywhere.

I have been give the task of rewriting an application at work. My boss wants the new application to mimic the old one as much as possible, so that leads to my question. There is a date field that will allow a date input separated by a tilde (01/01/15~01/31/15) and it uses this to get a beginning date and end date for a between SQL statement.

With all that being said, I am trying to do the same thing in PowerBuilder 12.6 classic. I know that I can accomplish the same thing by using two date pickers (begin date and end date), but my boss wants this transition to be as seamless as possible to the end users.

I have a sle_date_shipped on my form that currently takes in a date format of mm/dd/yy and will process it, but I want to allow mm/dd/yy~mm/dd/yy and parse out a begin and end date. My pseudo code would look something like this:

int i
String s
String start_date
String end_date

if this.textsize > 8 then
   s = this.text(value of this position in the string)
   start_date = s + s
   if this.text = "~" then
      s = s + 1
      s = this.text(value of this position in the string)
      end_date = s + s
   end if 
   this.textsize + 1
else
   start_date = this.text
end if

I do realize that my pseudo code probably needs some work, I'm just trying to get the point across.

Thanks

1

There are 1 answers

2
NoazDad On BEST ANSWER

Don't loop...

string ls_start, ls_end
ls_start = left( this.text, pos( this.text, '~' ) - 1)
ls_end   = right( this.text, Len( this.text) - pos( this.text, '~'))

-Paul Horan-