[Date Prev][Date Next][Subject Prev][Subject Next][
Date Index][
Subject Index]
A programming issue
- Subject: A programming issue
- From: Harry Binswanger hb@xxxxxxxx
- Date: Mon, 01 Sep 2008 18:36:59 -0400
I don't know why Carl didn't get my file--I got it myself--but at any rate,
it had a section of code that was my heavy-handed approach to solving a
programming problem that I'd like to get anyone's feedback on.
Here's the issue: I want to test a string to see if it has any of four
possible substrings. If it does, I change the string to something, if it
doesn't, I want to preserve that string.
So imagine one input string is: "This payment was by a personal check."
The next time it might be: "Paid by PayPal."
And another time it might be blank. It can have any text notation whatever,
free form.
I want to standardize its content for database use, where I can, so what I
have done, putting it in XyBasic language is this, where "payment.method$"
is the input string (periods in variable names are only separators, nothing
object-oriented):
string.has.good.content = 0
if paypal$ in payment.method$ >= 0 then payment.method$ = "paypal"
string.has.good.content = 1
endif
if credit$ in payment.method$ >= 0 then payment.method$ = "creditcard"
string.has.good.content = 1
endif
if cash$ in payment.method$ >= 0 then payment.method$ = "cash"
string.has.good.content = 1
endif
if check$ in payment.method$ >= 0 then payment.method$ = "check"
string.has.good.content = 1
endif
if string.has.good.content = 0 then freeform.notes$ = payment.method$
Seems like there has to be a more economical way.
Harry Binswanger
hb@xxxxxxxx