Solved

ColdFusion How to pass a variable by reference

Posted on 2009-07-13
1
441 Views
Last Modified: 2012-05-07
I am using a com object that takes in a string of addresses and then presorts it for mailing purposes.  

What is supposed to happen is that you call the retrieve function with the string you submit to the send function and it is supposed to give back a resorted list.  The list never gets reordered and outputs the same list I input.  I think this is because I am not passing a variable that can be passed by reference.  What can I do to get back the reordered list?  I have tried to set a variable to the function call but it says the variable is not defined after I do that.
<cfquery datasource="MHL_DB" name="addresses">

	SELECT     TOP (200) ADDRESS_LINE1, ADDRESS_LINE2, CITY, STATE, ZIP_CODE, FIRST_NAME, LAST_NAME, PATIENT_ID

	FROM       PATIENT

    WHERE      CITY <> ''

    ORDER BY   LAST_NAME

</cfquery>

<cfdump var="#addresses#">

<cfset lstAddress = "">

<cfset test = "">
 

<cfset iterations = addresses.recordcount / 25>
 
 

<cfparam name="ps" default="">
 

<cfscript>

        _FieldDelimiter = chr(9);

		_RecordDelimiter = chr(10);

		_RecordCount = addresses.recordcount;

		_RecordBlockCount = 1;

		_TemmplateToUse = "Test";

		addressSort = "";

	    szInput = "FLD_RECORD_ID" & _FieldDelimiter & "FLD_FIRST_NAME" & _FieldDelimiter 

                & "FLD_LAST_NAME" & _FieldDelimiter & "FLD_ADDRESSLINE1" & _FieldDelimiter 

                & "FLD_ADDRESSLINE2" & _FieldDelimiter & "FLD_CITY" & _FieldDelimiter 

                & "FLD_STATE" & _FieldDelimiter & "FLD_ZIPCODE" & _FieldDelimiter & "FLD_DPC";

        szOutput = "FLD_RECORD_ID" & _FieldDelimiter & "FLD_PRESORT_ID" & _FieldDelimiter 

                & "FLD_PACKAGE_NUMBER" & _FieldDelimiter & "FLD_TRAY_NUMBER" & _FieldDelimiter 

                & "FLD_ENDORSEMENT_LINE" & _FieldDelimiter & "FLD_DP_BARCODE" & _FieldDelimiter 

                & "FLD_ADDRESSLINE1" & _FieldDelimiter & "FLD_ADDRESSLINE2" & _FieldDelimiter 

                & "FLD_CITY" & _FieldDelimiter & "FLD_STATE" & _FieldDelimiter & "FLD_ZIPCODE";

				
 

        ps = createObject("COM","MRTKTask.PresortTask.1");

		ps.SetProperty(203,"localhost:5150"); //mrtkMAILROOM_SERVER_LIST
 

		ps.PrepareTask();

		ps.SetProperty(151, _TemmplateToUse); //mrktTemplate_NAME_TO_USE

		ps.SetProperty(303, 0); //ptSHOW_SORT_PROPERTY

		ps.SetProperty(312, 0);  //ptCASS_CERTIFY_FIRST

		ps.SetProperty(307, 0); //ptENABLE_CASS_PROCESSING

		ps.SetProperty(325, 0); // ptSHOW_PAGE_SETUP

		ps.SetProperty(304, 0); // ptHIDE_SORT_PROGRESS

		ps.SetProperty(300, "Presort List Test"); // ptFORM_NAME

		ps.SetProperty(301,_RecordCount); //ptRECORD_COUNT

		ps.SetProperty(302,2); //ptSORT_RESULTS_FLAG

		ps.SetProperty(310,_RecordBlockCount); //ptRECORD_COUNT_PER_RECEIVE

		ps.SetProperty(202,_RecordBlockCount); //mrtkINPUT_BLOCK_RECORD_COUNT

		ps.SetProperty(175,_FieldDelimiter); //mrtkDELIMITER_FIELD

		ps.SetProperty(176,_RecordDelimiter); //mrtkDELIMITER_RECORD

		ps.SetProperty(200,szInput); //mrtkFIELD_LIST_IN

		ps.SetProperty(201,szOutput); //mrtkFIELD_LIST_OUT
 

		

		ps.ValidateProperties(); 

		

		totalRecords = addresses.recordcount;

		rounds = totalRecords;

		startRow = 1;

		endRow = 25;
 

		

		for (i = 1; i LTE _RecordBlockCount; i++){

			addressLine = "";

			for ( intRow = startRow; intRow LTE _RecordCount; intRow++ ){

							tempString = "";

							tempString = addresses["PATIENT_ID"][intRow] & _FieldDelimiter & addresses["FIRST_NAME"][intRow] & _FieldDelimiter 

							& addresses["LAST_NAME"][intRow] & _FieldDelimiter & addresses["ADDRESS_LINE1"][intRow] & _FieldDelimiter 

							& addresses["ADDRESS_LINE2"][intRow] & _FieldDelimiter & addresses["CITY"][intRow] & _FieldDelimiter 

							& addresses["STATE"][intRow] & _FieldDelimiter & addresses["ZIP_CODE"][intRow] & _RecordDelimiter;

			addressLine = listAppend(addressLine,tempString,_RecordDelimiter);	

	//		addressLine = tempString;

		//WriteOutput("<pre>" & addressLine & "</pre>");

			//

			}
 

			startRow = startRow + _RecordBlockCount;

			//endRow = endRow + 25;

			//WriteOutput("<pre>" & addressLine  & "</pre>");

			ps.SendV(addressLine);

		}

		//

		

		

	ps.DoSort();

	

ps.Retrieve(addressLine);

		
 

WriteOutput("<pre>" & addressline & "</pre>");
 

        ps.EndTask();
 

		

		

</cfscript>

Open in new window

0
Comment
Question by:monica73174
1 Comment
 

Accepted Solution

by:
monica73174 earned 0 total points
ID: 24854519
I figured it out.  You need to pass in the variable with quotes when passing by reference instead of by value.  

ps.Retrieve("addressLine");
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Mixing cold fusion headers and footers with PHP body 6 56
cfgrid format issue and columns missing 4 90
Can I run Access database.exe file thru Coldfusion 2 109
CSS HELP 6 84
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now