469,270 Members | 1,731 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

expression built sting / Parsing text field

I am needing to Parse some text fields, where a 3rd party application i
use stores data from a user created expression.

the user creates and expression such as this:

ActualSizeYN =Y? SubassyL : BackDadoYN = Y ?(BaseRailYN =Y ? SubassyL
+DadoBack+ RailM : SubassyL + 2* DadoBack) : SubassyL - 2*
BackClearance- TbH
The data is stored in a text field like this.

;389 =Y? ;10 : ;160 = Y ?(;105 =Y ? ;10 +;111+ ;100 : ;10 + 2* ;111) :
;10 - 2* ;161- ;72
where each number precceded by a ; is the ID number of the parameter in
the paramater table ex:

ID |ParamaterName
-----------------------
389 |ActualSizeYN
10 |SubassyL
160 |BackDadoYN
Each Parameter may contain another expression, a Quantity, or a
Dimension as its value. The application prevents

I need to be able to answer the question, and output to a table or
query, What are all the parameters which are used in an expression
(including the ones nested bellow in other parameters)

I would appreciate any suggestions
Andre
Nov 13 '05 #1
1 1577
rkc

"Andre" <An***@cuteww.com> wrote in message
news:AZ6zc.750579$oR5.317643@pd7tw3no...
I am needing to Parse some text fields, where a 3rd party application i
use stores data from a user created expression.

the user creates and expression such as this:

ActualSizeYN =Y? SubassyL : BackDadoYN = Y ?(BaseRailYN =Y ? SubassyL
+DadoBack+ RailM : SubassyL + 2* DadoBack) : SubassyL - 2*
BackClearance- TbH
The data is stored in a text field like this.

;389 =Y? ;10 : ;160 = Y ?(;105 =Y ? ;10 +;111+ ;100 : ;10 + 2* ;111) :
;10 - 2* ;161- ;72
where each number precceded by a ; is the ID number of the parameter in
the paramater table ex:

ID |ParamaterName
-----------------------
389 |ActualSizeYN
10 |SubassyL
160 |BackDadoYN
Each Parameter may contain another expression, a Quantity, or a
Dimension as its value. The application prevents

I need to be able to answer the question, and output to a table or
query, What are all the parameters which are used in an expression
(including the ones nested bellow in other parameters)


So your base problem is parsing the parameter codes out of the
expression?

Here's an idea for the start of a solution. This function takes an
string argument in the form of the type of expression you posted
and returns a comma delimited string of the parameters names
associated with them.

<input>
;389 =Y? ;10 : ;160 = Y ?(;105 =Y ? ;10 +;111+ ;100 :
;10 + 2* ;111) :;10 - 2* ;161- ;72
</input>

<output>
ActualSizeYN,SubassyL,BackDadoYN,BaseRailYN,Subass yL,
DadoBack,RailM,SubassyL,DadoBack,SubassyL,BackClea rance,TbH
</output>

<code>
Function ParseParameters(exp As String) As String
Dim i As Integer
Dim s As String
Dim nip As String
Dim temp As String

Dim hit As Boolean

For i = 1 To Len(exp)
s = Mid$(exp, i, 1)
Select Case s
Case ";"
hit = True
Case "0" To "9"
If hit Then
nip = nip & s
End If
Case Else
If hit Then
temp = temp & DLookup("[ParameterName]", _
"tblParameters", _
"[Id] =" & nip) & ","
nip = ""
hit = False
End If
End Select
Next

If Len(nip) Then
temp = temp & DLookup("[ParameterName]", "tblParameters", "[Id] =" &
nip)
Else
temp = Left$(temp, Len(temp) - 1)
End If

ParseParameters = temp

End Function

</code>



Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Tina Li | last post: by
8 posts views Thread by Michael McGarry | last post: by
4 posts views Thread by Neri | last post: by
7 posts views Thread by John Øllgård Jensen | last post: by
25 posts views Thread by Mike | last post: by
28 posts views Thread by Marc Gravell | last post: by
13 posts views Thread by Chris Carlen | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.