473,657 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Advice: Buffer to Different Variables Quick & Easy?

I did a google web & group search and didn't find an answer to my
question so... here we go. Will try to keep it short. (I am not a
complete beginner but am still pretty low on the food chain).

Two programs on two different machines. Program 1 is given values for
multiple variables. Program 1 then sends everything to Program 2 in an
ascii character format. Program 2 then needs to parse the input
buffer, extract the type of data and value, and set its own variables.

I need to keep speed in mind at all times because there will be large
amounts of data to process. I will also be dealing with the same
variables each cycle and I know all of them in advance. They could
change from time to time so I do not want to base the data on specific
locations in the buffer. Also, some may not be present on each cycle.

I could bring in a certain number of characters, say the first three
will specify what the data is, and use an if statement to see what it
is and then assign the numbers after it to a variable. However, this
seems really long and slow and they has got to be a better way.

Using either #define or an enum, I could specify in program 2 all the
data types that it may find in the string and when I send everything
from program 1, I can have it put a : between then so it will be
easier to parse.

Example: Sending VEL=500:TEL=400 :SEL=300: into program 2.

Q1: I could setup something (enum, typedef, ??) to bind VEL to a
variable named Vello, TEL to tello, and SEL to sello. What is the best
way to do that for readability and speed?

Q2: Now that I have the specifiers in the buffer linked to a variable
in the program, what would be the fastest way to get the values into
the variables (match them up)? With the knowledge I have now I could
make a for loop with an if loop to check each part of the buffer as it
is read and compare the parts coming in with the pre-defined variables
and then store the variable (via pointer as it will not be local to
the function). But again, there has got to be a faster / better
method.

Thanks for any advice.
Jul 23 '05 #1
1 1397
Hi

Q1:
If you use teh enum, what would happen is instead of sending a 3 letter
code per item you would send a number = essentially an array of chars.

If you have under 100 categories, then using numbers instead of the 3
letter code will help you.

Q2:
How about not sending teh category with each single item but rather
sort the items by category and then send something of the form:

vel,5,500, 44,234,1,3:tel, 2,213,2:sel,1,3 00

code1, num_items, item1, item2, item3...:code2. ..

Good luck,
Nadina

Jul 23 '05 #2

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

Similar topics

24
1903
by: sundew | last post by:
Hi all, I am developing an open source DHTML project named Wednus Window. http://wednus.com Wednus Window is a DHTML Web-Application Windowing System. It shell websites/web-applications with fully customizable DHTML window objects and users also can change its skin, so it can goes well with an website layouts.
4
2300
by: Marquisha | last post by:
If this is off-topic, please forgive me. But I thought this might be the perfect spot to get some advice about how to proceed with a project. Working on a Web site design for a nonprofit organization, and I'm donating the work. Haven't done Web work in a while, and things have changed since I last did anything of this magnitude. I'm looking for a solution that will enable me to edit pages easily and in totally WYSIWYG fashion, while...
32
2557
by: Alan Silver | last post by:
Hello, I shamefully admit to be an old web designer, from before the days of CSS. In those heady days, tables were king and were used for every possible kind of alignment. When CSS came along, it was useful for specifying colours and fonts for a site in one central location, but useless for any real kind of design work due to the poor browser support. I got well in to using CSS for colours and fonts, but carried on using tables for...
11
28874
by: Ben Collingsworth | last post by:
Anyone have some efficient source code for implementing a ring buffer?
1
1986
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 environment. Currently the application has a search customers page with 10 search fields which list the results below the search fields. The requirement for this screen was that the user could return to this result page at any point from any page...
1
1411
by: C4rtm4N | last post by:
I'm about to embark on re-writing a database & bespoke web reporting application for our call centre & would like a little advice please. Currently the database has 10 tables containing summaried (<=1 record per staff member per day) data from different legacy systems, populated by DTS. There is an 11th table that has staff data in which is used to link the others together as many have different primary keys. After the data has been...
232
13242
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first set of examples, after decoding the HTML FORM contents, merely verifies the text within a field to make sure it is a valid representation of an integer, without any junk thrown in, i.e. it must satisfy the regular expression: ^ *?+ *$ If the...
7
2225
by: Gladen Blackshield | last post by:
Hello All! Still very new to PHP and I was wondering about the easiest and simplest way to go about doing something for a project I am working on. I would simply like advice on what I'm asking so I can go and learn it myself through doing (best way for me). I am building a card game as a learning-project as it involves many (to most of the) things that I would like to learn to do with PHP.
64
9709
by: Philip Potter | last post by:
Hello clc, I have a buffer in a program which I write to. The buffer has write-only, unsigned-char-at-a-time access, and the amount of space required isn't known a priori. Therefore I want the buffer to dynamically grow using realloc(). A comment by Richard Heathfield in a thread here suggested that a good algorithm for this is to use realloc() to double the size of the buffer, but if realloc() fails request smaller size increments...
0
8421
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
8325
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
8742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8621
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
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
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
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
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.