GUI Urgent

I am creating a GUI which reads a txt file and outputs a txt file with column heading and the information from the input text file. Everything seems to be compiling and running correctly but my information from my input file is not transfering over to my output file. I see my headers and everything else but no information in the text output file. any help would be appreciated


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#include "stdafx.h"
//#include "Retail.h"


Retail * FirstRecordPointer;
// * Constructor *

Retail::Retail()
{
	ProductNumber = 0;
	Description[35] = '\0';
	ManufacturerID = 0;
	Price = 0;
	Markup = 0;
	Quantity= 0;
    NextRecordPointer = NULL;
}


void Retail::ListRecords( char * ReportName )
{
ofstream OutputFile;
Retail * CurrentRecordPointer;
char Separator[200] = "_______________________________________________________________________________________________";

	OutputFile.open((char*)(void*)Marshal::StringToHGlobalAnsi(String::Concat(Directory::GetCurrentDirectory(),
					 "\\RetailFileForOutput.txt")));

	if (!OutputFile)
	{
		Application::Exit( );
		return;
	}

	
	// * Display header for Retail information *
	
	OutputFile << endl << Separator << endl << endl;
	OutputFile << setw(38) << setfill(' ') << ReportName << endl;
	OutputFile << Separator;
	OutputFile << endl << endl << setw(15) << setfill(' ') << "Product"
				<< setw(16) << setfill(' ') << "Product"
				<< setw(21) << setfill(' ') << "Manufacturer's"
                << setw(19) << setfill(' ') << "Retail"
				<< setw(18) << setfill(' ') << "Quantity"<< endl
                << setw(11) << setfill(' ') << "Number"
                << setw(21) << setfill(' ') << "Description"
				<< setw(19) << setfill(' ') << "Id Number"
				<< setw(21) << setfill(' ') << "Price"
                << endl << Separator << endl << Separator << endl;


	// * Records are listed until the NULL value is encountered *
	
	CurrentRecordPointer = FirstRecordPointer;
	while( CurrentRecordPointer != NULL )
	{
		OutputFile << endl;
		OutputFile << right;
		OutputFile << endl << setw(9) << setfill(' ')
					<< CurrentRecordPointer->GetProductNumber( );

		OutputFile << setw(28) << setfill(' ')
					<< CurrentRecordPointer->GetDescription( );
		OutputFile << endl << setw(9) << setfill(' ')
					<< CurrentRecordPointer->GetManufacturerID( );

		OutputFile << fixed << showpoint << setprecision(2)
					<< setw(8) << setfill(' ')
					<< " $ " << CurrentRecordPointer->GetPrice( );

		OutputFile << endl << setw(9) << setfill(' ')
					<< CurrentRecordPointer->GetQuantity( );
		CurrentRecordPointer = CurrentRecordPointer->GetLink( );
	}

	OutputFile << endl << Separator << endl;

	OutputFile.close( );
	return;
}

// * Add an item to the head of the linked list  *

void Retail::InsertItem( int InitProductNumber, char InitDescription[], int InitManufacturerID,
        double InitPrice, double InitMarkup, int InitQuantity, Retail* CurrentRecordPointer )
{
Retail* CurrentPointer;  // Pointer to traverse the list
Retail* TrailPointer;    // Pointer to previous record
bool Found;

	ProductNumber = InitProductNumber;
	strcpy_s( Description, InitDescription );
	ManufacturerID = InitManufacturerID;
	Price = InitPrice;
	Markup = InitMarkup;
	Quantity = InitQuantity; 

	
	// * First Case:  The list is empty.  The node containing  *
	// * the new item is the only node and thus the first node *
	// * in the list.                                          *
	
	if( FirstRecordPointer == NULL )
	{
		FirstRecordPointer = CurrentRecordPointer;
	}
	else
	{
		CurrentPointer = FirstRecordPointer;
		Found = false;

        
        // * Search the linked list *
       
        while( CurrentPointer != NULL && !Found )
        {
			if( CurrentPointer->ProductNumber >= InitProductNumber )
            {
                    Found = true;
            }
            else
            {
                    TrailPointer = CurrentPointer;
                    CurrentPointer =
                            CurrentPointer->GetLink( );
            }
        }
        // 
        // * Second Case:  The new item is smaller than the    *
        // * smallest item in the list.  The new item goes at  *
        // * the beginning of the list and the head pointer is *
        // * adjusted.                                         *
        // 
        if( CurrentPointer == FirstRecordPointer )
        {
			NextRecordPointer = FirstRecordPointer;
			FirstRecordPointer = CurrentRecordPointer;
        }
        // 
        // * Third Case:  The new item is to be inserted       *
        // * within the list.  If the item is larger than all  *
        // * items in the list, it is inserted at the end of   *
        // * the list.  Thus, the value of                     *
        // * "CurrentPointer" is NULL and the new item         *
        // * is inserted after "TrailCurrent."  If the item is *
        // * to be inserted somewhere in the middle of the     *
        // * list, the new item is inserted between            *
        // * "TrailCurrent" and "CurrentPointer."              *
        // 
        else
        {
			TrailPointer->NextRecordPointer = CurrentRecordPointer;
		NextRecordPointer = CurrentPointer;
        }
	}
}

// ************************************************************
// * Count and display the number of items in the linked list *
// ************************************************************
int Retail::CountItems( )
{
Retail* CurrentRecordPointer;
int ItemCounter = 0;

	for( CurrentRecordPointer = FirstRecordPointer;
		CurrentRecordPointer != NULL;
		CurrentRecordPointer = CurrentRecordPointer->GetLink( ) )
	{
		ItemCounter++;
	}
        
	return( ItemCounter) ;
}

// *************************************************
// * Return the value of the private class members *
// *************************************************
int Retail::GetProductNumber( ) const
{
	return( ProductNumber );
}

char* Retail::GetDescription( ) const
{
	return( Description );
}

int Retail::GetManufacturerID( ) const
{
	return( ManufacturerID );
}

double Retail::GetPrice( ) const
{
	double Total = 0;
	double Total2 = 0;
	Total = Price * Markup;
	Total2 = Total + Price;
	return (Total2);
}

int Retail::GetQuantity( ) const
{
	return (Quantity);
}

Retail* Retail::GetLink( ) const
{
	return NextRecordPointer;
}

// **********************************************
// * Set the value of the private class members *
// **********************************************
void Retail::SetProductNumber( int InitProductNumber )
{
	ProductNumber = InitProductNumber;
}

void Retail::SetDescription( char InitDescription[] )
{
	strcpy_s( Description, InitDescription );
}

void Retail::SetManufacturerID( int InitManufacturerID )
{
	ManufacturerID = InitManufacturerID;
}

void Retail::SetPrice( double InitPrice)
{
	Price = InitPrice;
}

void Retail::SetMarkup( double InitMarkup)
{
	Markup = InitMarkup;
}

void Retail::SetQuantity( int InitQuantity)
{
	Quantity = InitQuantity;
}

void Retail::SetLink( Retail* InitLink )
{
	NextRecordPointer = InitLink;
}
My guess would be that 'FirstRecordPointer' isn't correctly set. That decides whether you have an output or not.

It's global variable which is certainly not good since it could be change by whoever
Topic archived. No new replies allowed.