Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replace !empty(alias.field) with len(alias.field)>0
Message
From
14/02/2016 15:38:58
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01631431
Message ID:
01631437
Views:
47
>>>Hi,
>>>
>>>I need to create a function to replace the expression "!empty(mytable.myfield)" with "len(mytable.myfield)>0" (to make it work for SQL server).
>>>I played with SUBSTR and STRTRAN functions but can't seem to find a way to get around the fact that the "mytable.myfield" changes from one expression to another. So it has to be "generic."
>>>I would appreciate any suggestions
>>
>>
>>m.lcInput = "!empty(mytable.myfield)"
>>m.lcOutput = "LEN" + STREXTRACT(m.lcInput,"(",")",1,4) + ">0"
>>
>
>First, thank you very much for you suggestion. But, again, I probably didn't say the initial question correctly. The m.lcInput can have more than just this '!empty(.. " but other expressions. Let me give you a good example:
>
>
>m.lcInput = "Mytable.FieldXyx = '233' and (MyTable.Field233 > 344) and !empty(mytable.myfield) and someothertable.field3 = '333'"
>
>
>As you can see that the expression "!empty(mytable.myfield)" could be somewhere in the middle, beginning, or end of the entire string.

Perhaps this will do, then:
m.lcInput = "Mytable.FieldXyx = '233' and (MyTable.Field233 > 344) and !empty(mytable.myfield) and someothertable.field3 = '333'"
m.lcHold = STREXTRACT(m.lcInput,"!empty(",")",1,5)
m.lcOutput = STRTRAN(m.lcInput, m.lcHold, "LEN" + STREXTRACT(m.lcHold,"(",")",1,4) + ">0")
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform