Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

array declaration

Status
Not open for further replies.

bhas

Programmer
Mar 17, 2004
30
US
Is declaring an array like this correct?

Function Check_Val(ByRef arrArray)
Dim row As Integer, j As Integer
For row = LBound(arrArray) To UBound(arrArray) - 1
For j = row + 1 To UBound(arrArray)
If arrArrray(j) = arrArray(row) Then
Check_Val = arrArray(row)
Exit Function
End If
Next
Next
Check_Val = ""
End Function
 
If teststr="Accession numbers 1324-9, patient name roger smith, DOB 14/06/1992, procedure code 124567." then the following code:
If InStr(1,teststr,"Accession",1) > 0 Then
a=Split(teststr,",")

will populate the array a like this:
a(0)="Accession numbers 1324-9"
a(1)=" patient name roger smith"
a(2)=" DOB 14/06/1992"
a(3)=" procedure code 124567."
I have absolutely no knowledge about Biztalk mapper.
Which sort of value should the function returns ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Actually biztalk mapper reads the file and there is something called functoid where we can format the output to what i had in my example.
so can we do what you have done in your script in a function.so that we can just format the output to what we need.
thanks again for your time on this.
 
I have another question.
How can we hard code a value like this.

If teststr="Accession numbers 1324-9, patient name roger smith, DOB 14/06/1992, procedure code 124567." then the following code:

Because we will not know the values what we have.
The function has to read and pull out only the non duplicating values and pass it to the variable(because we are using a function)
 
If teststr="Accession numbers 1324-9, patient name roger smith, DOB 14/06/1992, procedure code 124567." then the following code:
This is not code to write !
This stand for:
If the teststr variable contains this value, then see what will be the result of the Split function.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Can we write the same script in a function.
Like i said the biztalk mapper reads the file for us but we can format the output based on the script whatb we write.
Do you know how to write the same in a function.
Thanks a lot!
 
A function MUST return a single value.
Which value should this function returns, and which parameters is it supposed to handle ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
It should return the accesion number which are not duplicates.
Actually when we map and run the file we should get all the accession numbers which do not repeat(duplicate).
Actually how do we do it to get all the accession numbers which do not repeat.
Thanks for your precious time on this.
Please respond.
 
Hello all,

After on-lineagain , you have made progress already so much beyond my recognition. Take some time to digest. Using PHV's input, I would summarize the thing for bhas's immediate testing.
Code:
sInputFile="E:\LabCorpNovBC10.txt"
sOutputFile="E:\LabCorpNovBC10_unique.txt"  'edit this
call summary(sInputFile, sOutputFile)

function summary(sInFile, sOutFile)

const ForReading=1, ForWriting=2
set d=createobject("scripting.dictionary")
set fso=createobject("scripting.filesystemobject")
set oF=fso.opentextfile(sInFile, ForReading)
do while not oIF.AtEndOfStream
	sLine=oF.readline
	if Instr(1, sLine, "accession", 1)<>0 then
		a=split(sLine,",")
		if d.exists(a(0)) then
			d.item(a(0))=d.item(a(0)) & a(ubound(a))
		else
			d.add a(0), sLine
		end if
	end if
loop
oF.close
set oF=fso.opentextfile(sOutFile,ForWriting,true)
a=d.Items
for i=0 to d.count-1
	oF.writeline a(i)
next
oF.close : set oF=nothing
set fso=nothing

end function
Inspect if the file (sOutputFile) is created all right and in the format desired.

regards - tsuji
 
Correction:

Have a typo in variable oIF (a trace of drafting up), should be oF. The line
Code:
   do while not [COLOR=red]oIF[/color].AtEndOfStream  '_wrong_
should be read
Code:
   do while not oF.AtEndOfStream
- tsuji
 
Tsuji,
Thanks for your reply.
But i would like to create the same logic in a function with array. Because I am working on biztalk mapper and the mapper reads the file for me and i have to look for only those records for which there are no duplicates and then map.
The data will look like 1234-8 ,roger smith, 04/05/1969, male etc...
Please respond.
 
Hello again,

If you want feed into the function with accession number and that the function return the summary information you need, this is how you can do.
Code:
sInputFile="E:\LabCorpNovBC10.txt"
sAccNum="1324-9"  'edit this or dynamic input
wscript.echo summary_talk(sInputFile, sAccNum)

function summary(sInFile, sAccession)

const ForReading=1
msg=""
set fso=createobject("scripting.filesystemobject")
set oF=fso.opentextfile(sInFile, ForReading)
do while not oF.AtEndOfStream
    sLine=oF.readline
    if Instr(1, sLine, cstr(sAccession), 1)<>0 then
        a=split(sLine,",")
        if msg<>"" then
            msg=msg & a(ubound(a))
        else
            msg=sLine
        end if
    end if
loop
oF.close : set oF=nothing
set fso=nothing
summary_talk=msg

end function
regards - tsuji
 
bhas,

My above posting is done without seeing your last posting. We post nearly the same time. Will try to understand what you desire. (No gurrantee. I sure will be occupied for other things in the coming hours and will return later.)

- tsuji
 
Tsuji,
Thanks again for quick response,but i dont want to open the file and read the file since the biztalk mapper does that for me.
All i wanted to do is that before mapping the fields i want to write a function in the accession field which will give me only those records for which there are no duplicates.
Can we use an array in the function to do this.
Can you help please
 
bhas,

Just a quick note before breakoff.

If you rely on biztalk to open the plain-text file (actually a data base), then the file is loaded into the memory block controlled by the biztalk or mapper whatever. In that case, you won't enjoy the flexibility of the scripting. You are overpowered and have to subject to what biztalk offer. I may be wrong. Does biztalk/its mapper offer a scripting interface with it?

- tsuji
 
hello gents, sorry to jump in on this thread.

bhas,
i think what tsuji and phv are trying to get at is that you havent stated what you are trying to return to Biztalk. Infact you didnt mention you needed to return something to Biztalk in the first place.

API
Make it clear what you are being given from Biztalk
Make it clear what you want to return to Biztalk

I know you have said the 'non duplicates' but this isnt enough information.

Does biztalk want the function to return an Array? If so what format should the array take?
If biztalk is expecting the function to return a string then in what format should the string take?
phv has posted an example on how to get a unique patient entry listing all the treatments they have had, surely this is what you are after?

Regards,
Richard
 
bhas,

How's it going?

I take this opportunity to call attention that in my second code posting using function summary_talk, the function declaring line itself should be read as function summary_talk(...), rather than function summary(...) which is a trace of my cut & paste & edit of my previous posting. (This should be obvious when try to run the script.)

- tsuji
 
Tsuji,richard
Thanks for your reply.
Bascially Biztalk does provide functoid where we can create scripts(function only).
What we are doing is mapping in source field to a destination field,when we do that we have to make sure that accession numbers (which is unique for each patient)does not repeat in the output even though they are in the input.
Since biztalk process the file by itself and gets all the data including duplicates.i just want to write vbscript(biztalk allows vbscript) which will get me
non duplicate values in thr output.
I am only thinking whether we can use array but i want answers from gurus like you on this.
 
So, again the same questions:
How are the data read by biztalk accessible to the function ?
How is the function called, with which parameters ?
Which sort of value is supposed to return this function ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
PHV,
After mapping source field to destination field in biztalk,
we pick flat file fir testing the data which is being provided by the customer. I could also do this by connecting to the database. In the mapping filed there is a provision called functoid where i can write a vbscript to do get non dup values.

How are the data read by biztalk accessible to the function ?
when we test the data file on the mapping it basically gets the data where ever we have mapped(field by field).
Accession is one of the field where the numbers are displayed in output.

How is the function called, with which parameters ?
Which sort of value is supposed to return this function ?

When we write the script and runthe test file against map the data now in accession field(output) will be what we write in the script.
Bascially i am looking at non duplicate values to be returned by the fuction to the accession field.
Please respond
 
As mrmovie noticed, I think you have all the necessary stuff to do what you want. Checking that an accession number is already in the dictionary object is sufficient to avoid duplicate.
The main goal is to use a dictionary object as an associative array.
Good luck.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top