473,856 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loading file into an array

I would like to know if anyone can help me with this. I would like to
load a file into a switch/case function but dont know how. Here is an
example file.
;File Example
;Created 03/04/99
[Command]
name = "2QCF_y"
command = ~D, DF, F, D, DF, F, y

[Command]
name = "5b"
command = b, b, b, b, b
time = 30
etc....

My question is if someone can help me to load any file (I know how to
open it) but then input it into a switch/case function where each case
is

command = ......

Also, I would like to know if there was any way to impose a time
limit, the times shown with the command, with the default time being
15 if no time is specified. And then with each case, the name of that
command is shown?

I also have one further problem. I would like to know if there was any
way to increase the amount of commands depending on the amount in the
files and stop once I get into a certain section.

If anyone can help point me in the right direction? An example maybe?
I just need the switch/case function that would work with a file that
I open. Thanks in advance for any help that can be provided.
Jul 22 '05 #1
3 3170

"Jose" <da*********@vf email.net> wrote in message
news:f4******** *************** *@posting.googl e.com...
I would like to know if anyone can help me with this. I would like to
load a file into a switch/case function but dont know how. Here is an
example file.
;File Example
;Created 03/04/99
[Command]
name = "2QCF_y"
command = ~D, DF, F, D, DF, F, y

[Command]
name = "5b"
command = b, b, b, b, b
time = 30
etc....

My question is if someone can help me to load any file (I know how to
open it) but then input it into a switch/case function where each case
is

command = ......


Do you know how to read a line from a file into a string? Do you know how to
examine the content of string to see what is there? Do you know how to write
loops and if statements? Do you know how to define a data structure for your
command objects? That is all that you have to do, but its going to be an
awful lot of tedious code. And forget about switch case, it seems completely
inappropriate for what you are trying to do. Switch case works on integers,
and I don't see many integers in that file format.

john
Jul 22 '05 #2
"John Harrison" <jo************ *@hotmail.com> wrote in message news:<2v******* ******@uni-berlin.de>...

Do you know how to read a line from a file into a string? Do you know how to
examine the content of string to see what is there? Do you know how to write
loops and if statements? Do you know how to define a data structure for your
command objects? That is all that you have to do, but its going to be an
awful lot of tedious code. And forget about switch case, it seems completely
inappropriate for what you are trying to do. Switch case works on integers,
and I don't see many integers in that file format.

john


Good point. Umm, do you have any idea as to how I would make the
structure so that it can increase or decrease according to the amount
of command objects?
Jul 22 '05 #3

"Jose" <da*********@vf email.net> wrote in message
news:f4******** *************** ***@posting.goo gle.com...
"John Harrison" <jo************ *@hotmail.com> wrote in message
news:<2v******* ******@uni-berlin.de>...

Do you know how to read a line from a file into a string? Do you know how
to
examine the content of string to see what is there? Do you know how to
write
loops and if statements? Do you know how to define a data structure for
your
command objects? That is all that you have to do, but its going to be an
awful lot of tedious code. And forget about switch case, it seems
completely
inappropriate for what you are trying to do. Switch case works on
integers,
and I don't see many integers in that file format.

john


Good point. Umm, do you have any idea as to how I would make the
structure so that it can increase or decrease according to the amount
of command objects?


Use a vector, or maybe a map. See my other post.

john
Jul 22 '05 #4

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

Similar topics

17
4819
by: Aguilar, James | last post by:
My previous example used the concept of a Shape class heirarchy, so I will continue with that. Suppose I have something like fifty different shapes, and I am trying to instantiate one of them. The trick is, the instatiation will be based on a string with the exact same name as the type that I am trying to instantiate. Obviously, writing a fifty element long switch statement is an inferior solution. So, how can I instantiate based on...
4
2120
by: Baris | last post by:
What is the best and speedy way of loading files into an array? i have an int MyArray = new int; and a file (size is 4000000 byte)
3
1946
by: Bala | last post by:
Hi, In my page there is 4 dropdown list boxes.when page loading that time i am loading the nearly 3000 items array. so its taking too much time to load. is it other way fill up the dropdown list array items? can i make the array itesm into xml file and bind the dropdown list? is it possible?
0
255
by: Terry Olsen | last post by:
I wrote the following code to load a DataTable with a CSV file. My problem is: If I include the line "MyTable.Clear()" before I start loading the Table, I'm presented with the 2nd line of my CSV file presented twice (rows 0 and 1 of the table) and the 1st line of the CSV file is missing. If I remove the "Clear" statement, then all my data is there, but there's a blank row at Row 0. Help!?!?!? Thanks!
1
1814
by: Bala | last post by:
Hi, Currently i am loading the file names into datagrid (unbound) from a folder(sub folders too). so for this i am using this below code. but its too slow to loading all the file names. is it any other method to make it fast loading bala code:
1
1505
by: bobmct | last post by:
Fellow PHP'ers; I'm digging myself a hole on this one so I thought it has come to the time when I must ask those who know. I have what should be a simple question for loading, accessing and retrieving values stored in a simple one-dimensional array. I am simply trying to determine the occurrence of numbers as they appear in a file. For example lets assume the lowest allowed value is
2
2997
by: Jean Pierre Daviau | last post by:
When I have something like this in a js file. listeImg = new Array(); listeImg = new Image(w,h); listeImg.src = "centre1.jpg"; etc Are the images loaded after the page is loaded? In the same time? Before the page is loaded? The browser decision? If the visitors goes, before the procedure is over, to another page having a link to the same js file, will the other page allows for the rest of the
8
3299
by: jhoff | last post by:
So, I'm in a pickle... Lets say I have a page: http://www.gen2host.com/discgolf/index.html and on this page, there are a list of links. These links will be generated by 5 pieces of data pulled from each .xml file in a subdirectory on the webserver. Ex <A Href=" " </a as text.
6
3555
by: Apollo1376 | last post by:
I am very new to C++. I need some help with loading/reading data from text file and write in an array. I have the following data. 12/31/2004 1213.55 1217.33 1211.65 1211.92 786900000 1211.92 12/30/2004 1213.45 1216.47 1213.41 1213.55 829800000 1213.55 12/29/2004 1213.54 1213.85 1210.95 1213.45 925900000 1213.45 12/28/2004 1204.92 1213.54 1204.92 1213.54 983000000 1213.54 12/27/2004 1210.13 1214.13 1204.92 1204.92 922000000 1204.92...
0
2036
by: ne0lithic | last post by:
Hey everyone, I'm working on a program based on steganography. For this, i need to access the individual pixels and perform my manipulations. FYI, I do not have the JAI library available with me and I have to make do with awt, imageIO and image. I'm having no issues in loading an image but when i thought I would test things and just save the same image without manipulation I was surprised. After copying the pixels from the image into an int...
0
9904
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
11049
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
10772
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
10378
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
9527
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...
0
5754
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
5956
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3195
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.