Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 20th, 2005, 02:07 PM
Authorized User
 
Join Date: Oct 2003
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to iloveoatmeal
Default Output loop data to a string

I have an application which connnects to FexEx freight and gets a quote based on the products in the shopping cart. In order to get a quote from Fedex you need to pass a string to their application. I am looking to dynamically generate the weight and shipping class for each product (as_class & as_weight).

Sample from FedEx:

"http://www.fedexfreight.fedex.com/XMLRating.jsp?as_shipterms=prepaid&as_shzip=85748& as_shcntry=US&as_cnzip=80112&as_cncntry=US& ***** as_class1=070&as_weight1=480&as_class2=050&as_weig ht2=100 ***** &as_acctnbr=XXXXXXXX&as_iamthe=shipper", False

***** This is the string I need to build based on the products in the shopping cart. *****

The code below outputs the correct string but I don't know how to capture it.

shippingArray = objRS.GetRows()

Const totalWeight = 0
Const shippingClass = 1

For lnLoopCounter = 0 To Ubound(shippingArray,2)

Response.Write "as_class" & lnLoopCounter + 1 & "=" & shippingArray(shippingClass, lnLoopCounter) _
      & "&as_weight" & lnLoopCounter + 1 & "=" & shippingArray(totalWeight, lnLoopCounter) _
      & "&"
Next

Output:
 as_class1=50&as_weight1=100&as_class2=50&as_weight 2=400&as_class3=50&as_weight3=900&

The above string is exactly what I need to capture. There are three products in the my shopping cart (1 - class 50/100lbs., 2 - class 50/400lbs., 3 - class 50,900lbs.)

However, this is what I tried but it only captures the last (Ubound) record.

shippingArray = objRS.GetRows()

Const totalWeight = 0
Const shippingClass = 1

For lnLoopCounter = 0 To Ubound(shippingArray,2)

shippingString = "as_class" & lnLoopCounter + 1 & "=" & shippingArray(shippingClass, lnLoopCounter) _
      & "&as_weight" & lnLoopCounter + 1 & "=" & shippingArray(totalWeight, lnLoopCounter) _
      & "&"

Next

Response.Write shippingString
%>

Output:

as_class3=50&as_weight3=900&


How do I capture the shippingString which is generated by looping thru the recordset?
 
Old December 21st, 2005, 01:25 PM
Authorized User
 
Join Date: Oct 2003
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to iloveoatmeal
Default

Foolish! Just add the string so it will rewrite itself.

shippingArray = objRS.GetRows()

Const totalWeight = 0
Const shippingClass = 1

For lnLoopCounter = 0 To Ubound(shippingArray,2)

shippingString = shippingString & "as_class" & lnLoopCounter + 1 & "=" & shippingArray(shippingClass, lnLoopCounter) _
      & "&as_weight" & lnLoopCounter + 1 & "=" & shippingArray(totalWeight, lnLoopCounter) _
      & "&"

Next

Response.Write shippingString

%>
 
Old December 22nd, 2005, 08:28 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Do they insist on queryStrings (QS)? If so, so be it - if not I would change my process.

IMO QS's should be used as a last resort. There may be no need to URLEncode chars now and the length of the QS may be acceptable at this point. Scalability is reason enough to re think the process.

Wind is your friend
Matt




Similar Threads
Thread Thread Starter Forum Replies Last Post
How to output the entire content to a string sunnyman XML 6 November 29th, 2007 10:48 PM
data output kciwzehc Access 5 November 28th, 2007 01:10 PM
How to loop a command for a string length? LordJaffa Excel VBA 5 June 5th, 2007 10:20 PM
create string from For Each loop dhborchardt Classic ASP Databases 3 March 17th, 2004 01:18 PM
how to output non-well formed string harag XSLT 5 November 10th, 2003 11:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.