By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,688 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

expression built sting / Parsing text field

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.