473,385 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Replacing code based on static variables to variable variables.

Can anyone give me some help or tips in converting this code to take 2 variables that will specify the number of Pack
type lines and the number of Single type lines. We use it to create a web page that allows us to split a garment
delivery over multiple dates and and to specify the number and size of garments in a pack and the number and size of
individual garments in the delivery. 3 of each has been enough until now. However we are finding new customers that want
it spread over as many as 5 to 8 of each type pack and single.

Everything is stored in an array $RPack.
Easy to do as i new there were only ever goung to be 6 lines.

$maxC is the number of colours available (usually 3)
$maxR is the number of lengths each colour is available (usually 3)
$maxH is the number of sizes each length is available in. (Between 8 & 14)

Input() is a function for drawing HTML input boxes of the format

Input (Size,Value,Class,Name,Maxlength,Readonly)

I think what I need is to use variable variables but I am having a hard time getting my head around it so any tips and
advice would be very gratefully received.

// Create Data Entry, Boxes for Amt,Qty Total and Date
for ($z=0; $z<$maxC; $z++){
for ($y=0; $y<$maxR; $y++){
//Set Temp variables to 0 or ""
$ThisColour = "";
$ThisRange = "";
$ColourSize="";
$P_In0="";
$P_In1="";
$P_In2="";
$S_In0="";
$S_In1="";
$S_In2="";
$Total_In="";
$RatioTotal_In="";
$LineAmt0 = 0;
$LineAmt1 = 0;
$LineAmt2 = 0;
$LineAmtS0 = 0;
$LineAmtS1 = 0;
$LineAmtS2 = 0;
$ColourSize = Input(8,$RatioColours{$z}.' '.$RatioRange{$y};,formstyle,Colour_Size,10);

for ($i=0; $i<$maxH; $i++){
// Check already an entry if so use it, if not add default order line to singles1 and set rest to 0
if($fldfldMDA==1){

$Pack0 = Input(3,$RPack[0]{$i}{$z}{$y},formstyle,Pack0.$i.$z.$y,10);
$LineAmt0 = $LineAmt0 + $RPack[0]{$i}{$z}{$y};
$ColSumP0{$i}{$z}{$y} = ($RPack[0]{$i}{$z}{$y}*$RPack[0]{$Qty}{$z}{$y});

$Pack1 = Input(3,$RPack[1]{$i}{$z}{$y},formstyle,Pack1.$i.$z.$y,10);
$LineAmt1 = $LineAmt1 + $RPack[1]{$i}{$z}{$y};
$ColSumP1{$i}{$z}{$y} = ($RPack[1]{$i}{$z}{$y}*$RPack[1]{$Qty}{$z}{$y});

$Pack2 = Input(3,$RPack[2]{$i}{$z}{$y},formstyle,Pack2.$i.$z.$y,10);
$LineAmt2 = $LineAmt2 + $RPack[2]{$i}{$z}{$y};
$ColSumP2{$i}{$z}{$y} = ($RPack[2]{$i}{$z}{$y}*$RPack[2]{$Qty}{$z}{$y});

$Singles0 = Input(3,$RPack[3]{$i}{$z}{$y},formstyle,Singles0.$i.$z.$y,10);
$LineAmtS0 = $LineAmtS0 + $RPack[3]{$i}{$z}{$y};
$ColSumS0{$i}{$z}{$y} = ($RPack[3]{$i}{$z}{$y}*$RPack[3]{$Qty}{$z}{$y});

$Singles1 = Input(3,$RPack[4]{$i}{$z}{$y},formstyle,Singles1.$i.$z.$y,10);
$LineAmtS1 = $LineAmtS1 + $RPack[4]{$i}{$z}{$y};
$ColSumS1{$i}{$z}{$y} = ($RPack[4]{$i}{$z}{$y}*$RPack[4]{$Qty}{$z}{$y});

$Singles2 = Input(3,$RPack[5]{$i}{$z}{$y},formstyle,Singles2.$i.$z.$y,10);
$LineAmtS2 = $LineAmtS2 + $RPack[5]{$i}{$z}{$y};
$ColSumS2{$i}{$z}{$y} = ($RPack[5]{$i}{$z}{$y}*$RPack[5]{$Qty}{$z}{$y});

$ColTotal =
$ColSumP0{$i}{$z}{$y}+$ColSumP1{$i}{$z}{$y}+$ColSu mP2{$i}{$z}{$y}+$ColSumS0{$i}{$z}{$y}+$ColSumS1{$i }{$z}{$y}+$ColSumS2{
$i}{$z}{$y};

$RatioTotal = Input(3,$ColTotal,formstyle,ColTotal.$i.$z.$y,10);

$Total = Input(3,$RatioAmt{$i}{$z}{$y},formstyle,Total.$i.$ z.$y,10);

}
else{
$Pack0 = Input(3,0,formstyle,Pack0.$i.$z.$y,10);
$Pack1 = Input(3,0,formstyle,Pack1.$i.$z.$y,10);
$Pack2 = Input(3,0,formstyle,Pack2.$i.$z.$y,10);
$Singles0 = Input(3,$RatioAmt{$i}{$z}{$y},formstyle,Singles0.$ i.$z.$y,10);
$Singles1 = Input(3,0,formstyle,Singles1.$i.$z.$y,10);
$Singles2 = Input(3,0,formstyle,Singles2.$i.$z.$y,10);
$Total = Input(3,$RatioAmt{$i}{$z}{$y},formstyle,Total.$i.$ z.$y,10);
$RatioTotal = Input(3,0,formstyle,ColTotal.$i.$z.$y,10);
}
//Save Input Boxes for later
$P_In0 = $P_In0.$Pack0;
$P_In1 = $P_In1.$Pack1;
$P_In2 = $P_In2.$Pack2;
$S_In0 = $S_In0.$Singles0;
$S_In1 = $S_In1.$Singles1;
$S_In2 = $S_In2.$Singles2;
$Total_In = $Total_In.$Total;
$RatioTotal_In = $RatioTotal_In.$RatioTotal;
}
$RatioPacksOrdered =
$ColourSize.'<br>'.$fldHeaderR.'<br>'.$P_In0.'<br> '.$P_In1.'<br>'.$P_In2.'<br>'.$S_In0.'<br>'.$S_In1 .'<br>'.$S_In2.'<br>
'.$RatioTotal_In.'<br>'.$Total_In.'<br>';
//Pass to display variable
$fldfldRatioPacksOrdered = $fldfldRatioPacksOrdered.$RatioPacksOrdered.'<br>' ;
}
}
Jul 16 '05 #1
0 2012

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: David | last post by:
Can anyone give me some help or tips in converting this code to take 2 variables that will specify the number of Pack type lines and the number of Single type lines. We use it to create a web page...
3
by: IHateSuperman | last post by:
public class StaticField2{ public static void main(String args){ private int x, y; // <<== error 1 for ( y = 0 ; y < 100 ; y++){ x = StaticMethod(); System.out.println(" x = "+x); } } public...
2
by: katekukku | last post by:
HI, Could anyone please tell me what are static variables and what exactly are there features. I am a little bit confused. Thank You
6
by: Michael B Allen | last post by:
I want to initialize a static variable to a "random" value like: static void * get_key(struct dnsreq *req) { static uint16_t next_txnid = (uint32_t)req & 0xFFFF; But gcc gives me an error: ...
4
by: abCSharp | last post by:
I understand that static variables have app-domain scope. Till the app-domain is in memory, the static variable will be in memory. When are the app-domains unloaded is the question. I have read...
1
by: Larry Neylon | last post by:
Hi, I'm working on a VBScript application on IIS6 and I'm looking for some advice about the best way of replacing or improving session variable usage. The application is in a secure extranet...
9
by: CDMAPoster | last post by:
About a year ago there was a thread about the use of global variables in A97: http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/fedc837a5aeb6157 Best Practices by Kang...
10
by: Pramod | last post by:
Hello to all of you, I want to know that what's the use to create static object. Thanks You Pramod Sahgal
29
by: Nick | last post by:
I've seen a few frameworks use the following: function $(id) { return document.getElementById(id); } Then to use: $('something').innerHTML = 'blah'; I'm just trying to roll this out to my...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.