473,803 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

string manipulation, file input problem....

ok, im gonna try and explain this as best i can...
i have an AS/400 program that generates big, ugly, messy reports. i need to
read these ASCII reports in and output meaningful data. the good news is
that the raw reports are sequential files with fixed length fields. im
having only a few problems but its driving me nuts. here is a small sample
of what the file might look like: (im simplifying of course, and adding line
numbers)

1 ghfljkgsdfjklgs garbage gsdfgsdfg gfdsg fdsgdsgds
2 ITEM 0009
3 PRICE 7889
4 QUANTITY 3214
5 ITEM 0010
6 PRICE 2214
7 QUANTITY 0008

ok so... the structure of the file is like this: there will be an item# and
a corresponding price and quantity to THAT item number. then there will be
another item# with its own price and quantity. so what i could do is read
until i find "ITEM", get the item number, then read until i find the price
and quantity. while doing this if i again find "ITEM" i know im done with
the previous item and have a new item. but the problem is that sometimes the
item# will be the same because the report thinks that it has output too much
data and it needs to remind you of what item you are on. ok so when i find
"ITEM" i can compare it to the current item and if its the same then i know
its the same item. my only problem is that this seems to be one big,
confusing and complicated routine with nested if's and do while's. anyone
wanna save my sanity and help me out?
Jul 17 '05 #1
1 3897
cipher <de*@null.com > schreef in berichtnieuws
oP************* **********@news 4.srv.hcvlny.cv .net...

Hello cipher,
ok, im gonna try and explain this as best i can...
i have an AS/400 program that generates big, ugly, messy reports. i need to read these ASCII reports in and output meaningful data. the good news is
that the raw reports are sequential files with fixed length fields. im
having only a few problems but its driving me nuts. here is a small sample
of what the file might look like: (im simplifying of course, and adding line numbers)

1 ghfljkgsdfjklgs garbage gsdfgsdfg gfdsg fdsgdsgds
2 ITEM 0009
3 PRICE 7889
4 QUANTITY 3214
5 ITEM 0010
6 PRICE 2214
7 QUANTITY 0008

ok so... the structure of the file is like this: there will be an item# and a corresponding price and quantity to THAT item number. then there will be
another item# with its own price and quantity. so what i could do is read
until i find "ITEM", get the item number, then read until i find the price
and quantity. while doing this if i again find "ITEM" i know im done with
the previous item and have a new item. but the problem is that sometimes the item# will be the same because the report thinks that it has output too much data and it needs to remind you of what item you are on. ok so when i find
"ITEM" i can compare it to the current item and if its the same then i know its the same item. my only problem is that this seems to be one big,
confusing and complicated routine with nested if's and do while's. anyone
wanna save my sanity and help me out?


while not eof(hFile)
line input #hFile,Line$
{split Line$ into parts. Store(d) in sWords() . Easily done in VB6 :-) }
select case sWords(0)
case "ITEM"
if sWords(1)<>CurI tem then
{Print gathered data. See closing remark}
CurItem=sWords( 1)
debug.Print "-------------" ;Signal a new item
{Clear previously gathered data}
endif
case "PRICE"
{do something with the price}
case "QUANTITY"
{do something with the quantity}
case else
Debug.Print "Unrecognis ed : ";sWords(0)
end select
wend

Ofcourse, my suggestion would be to gather all data (price, quantity,etc),
and only print when the current item's number changes (in the IF) ...

Regards,
Rudy Wieser

Jul 17 '05 #2

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

Similar topics

12
1848
by: Hp | last post by:
Hi All, Thanks a lot for all your replies. My requirement is as follows: I need to read a text file, eliminate certain special characters(like ! , - = + ), and then convert it to lower case and then remove certain stopwords(like and, a, an, by, the etc) which is there in another txt file. Then, i need to run it thru a stemmer(a program which converts words like running to run, ie, converts them to roots words).
16
382
by: zohaibbaloch | last post by:
how to manipulate string without using arrays.manipulation example i have to print dog or any string i want to cut d from dog and paste it a end and add a at the last dog becoms ogda. please help
32
14915
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if ((someString.IndexOf("something1",0) >= 0) || ((someString.IndexOf("something2",0) >= 0) ||
1
1855
by: amitbadgi | last post by:
Welcome back amitbadgi | Logout | Faq Knowledge Discovery Keys COMPUTER PROGRAMMING, DATA MINING, STATISTICS, ARTIFICIAL INTELLIGENCE * Settings * Photos * Lists * MVPs * Forums * Blogs
4
3496
by: WaterWalk | last post by:
Hello, I'm currently learning string manipulation. I'm curious about what is the favored way for string manipulation in C, expecially when strings contain non-ASCII characters. For example, if substrings need be replaced, or one character needs be changed, what shall I do? Is it better to convert strings to UCS-32 before manipulation? But on Windows, wchar_t is 16 bits which isn't enough for characters which can't be simply encoded...
5
3539
by: ThatVBGuy | last post by:
Hello All, I could really use some help with this problem its driving me nuts. I have a small vb app, the goal of the app is to read an html doc into a variable then go through that variable and find and replace some tags. I have 3 functions. 1 to open the doc, the 2nd to find and replace the tags the 3rd to save the info. the code is pasted below : Public Function ReadFileContents(FileFullPath As String) As _ String On Error GoTo...
7
2108
Frinavale
by: Frinavale | last post by:
I currently have a .NET application that has an object which passes a string (a connection string) as a parameter to another object that does database manipulation. This string isn't stored anywhere else and is only used by this behind-the-scenes object to provide the database manipulation object with a connection string. Does my connection string pose a security problem when it is inside the code like this? Or are connection strings...
3
2300
by: ommail | last post by:
Hi I wonder if regular expressions are in general sower than using classes like String and Char when used for validating/parsing text data? I've done some simple test (using IsMatch()) method and the result was that Regex is either as fast or two times slower than method which used methods from classes
13
1993
by: Logan Lee | last post by:
Hi. I've written a small program to learn to write in C. But unfortunately the output is all jumbled up and not nice. /* read_file.c The whole point of this code is to read the entire content from a file then arrange the data as a single string. */ #include <stdio.h> char* returnArrayFromFile(char* file_name) { // Try opening a file
0
9703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9565
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10550
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10295
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9125
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5501
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5633
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.