473,787 Members | 2,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to read confusing execution code under IF condition

1 New Member
Hi - I'm completely new to C and trying to read some code that doesn't make sense to me. For proprietary reasons I can't display the code here but I'll describe it...and list part of it in a generic form below. I know the basics about IF conditions and have read plenty of them without difficulty but this one is really confusing me.

There is a long, complicated IF condition (1 AND and 2 ORS, with 2 parts to each OR and 2 NOTs!), then a list of code to execute if the IF condition is true, under it.

The execution code looks like this:

output = variable x
variable y = output
variable z [0] = output
variable z [1] = variable [0]

I am very confused. This is part of a continuous simulation block and variables x and y are different inputs to the block, which cannot possibly be the same and (when I tested it) are not forced to be equal to the same value, yet both are said to be equal to the output, which can be only one value. The block runs without glitches so I don't think it's an error in the code. Could someone please explain to me how to read this code? It doesn't make any sense to me but it must be just something I don't know about IF conditions or ignorance of some sort. I'm wondering if the first line is executed during the first time step in the simulation, then the next line during the next time step,or something...

Also, the last 2 lines above...what does this mean? I know about arrays and assume that this has to do with values at different time steps...value 0 is defined at one step, then value 1 is defined at the next step, etc. but I don't get what this code is saying.

Any help would be much appreciated. Thank you so much!
Nov 10 '08 #1
2 1438
JosAH
11,448 Recognized Expert MVP
Better show the actual expression because I don't understand anything from your
description. Feel free to change variable names at will as long as the semantics
of your posted expression are the same as the one you're looking at.

kind regards,

Jos
Nov 10 '08 #2
donbock
2,426 Recognized Expert Top Contributor
Please also provide the declarations for the variables. For example, perhaps "output" is a pointer to a memory-mapped input port. If so, then you might get a different value each time you read it.

Another issue is to understand what it means in your application domain to take this branch of the if-statement. Perhaps that complicated boolean expression amounts to a corner case where it is necessary to initialize the simulation variables.
Nov 10 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1470
by: Rajarshi Guha | last post by:
Hi, I'm writing some code using PyGTK2 that uses inpu_add_full() to watch a socket. I've included the code below. I have two questions: 1) What does a condition == 16 mean? It does match any of the gtk.gdk.INPUT_* values. What is the use of the condition variable in the callback? 2) The source variable in the call back is an fd. I have some trivial code that is able to read from a socket:
5
6306
by: Boris Nikolaevich | last post by:
This is backwards of what I usually want--normally if you have a long-running ASP script, it's a good idea to check to see whether the client is still connected so you can cancel execution. However, I have a script that absolutely MUST finish one it's been started--is there a way to cause the entire script to execute, even if the client disconnects in the middle of the process? It doesn't matter if the script returns anything to the...
2
9004
by: Gunnar | last post by:
Hello, I've just written a CPP program that reads integers from a binary file, and used this code while (my_ifstram.read( (char* ) &number, sizeof(int)) { // do something with number } My question is now, where can I find a manual that describes what the read method does with the ifstream object? I'm sitting here with my Linux/Debian machine, but I have not found any
2
2303
by: David McBride | last post by:
I'm getting the following message when I run my Perl script that uses the XML::Writer module: "Processing instruction target begins with 'xml' at .../makeconf/LW/LWTest.pm line 75" The pi() statement is almost identical to the example for the module at cpan.org. In fact, I tried replacing my use with the example and got the same result. Can anyone tell me why I'm getting this warning, even though I'm getting the correct output?
2
2065
by: smauldin | last post by:
Why does the execution plan have a nested loop join for a simple select with an UDF in the where clause? Here is the query: select * from test_plan where vCol = my_udf('test') Here is the table definition: create table test_plan(iCol integer, vCol varchar(20))
7
2265
by: Naren | last post by:
Hello All, Can any one help me in this file read problem. #include <stdio.h> int main() {
7
1791
by: kk | last post by:
Hi all, How to write a c/c++ program to execute limited number of times. if anybody know plz give reply. thanks
12
3400
by: Yash | last post by:
My SQL query is like: SELECT ..... FROM tblCLAIM C INNER join tblXXX .... INNER join tblYYY ....(5 more joins) WHERE C.created_date between @start_date and @end_date AND C.claimant_id=@claimant_id or @claimant_id=-1 AND (more conditions like the claimant condition) This query is in a stored proc which takes parameters @start_date,
4
27989
by: sphinney | last post by:
Hi everyone. I'm creating an application inside Access 2007. The application will retrieve data from various locations on my company's network servers. Depending on the time of day, alignment of the planets, other unfathomable mysteries sometimes my company's network is very, very slow. I would like to provide the user of my application with a "Cancel" button on a form that will cancel/stop execution of the code (at whatever point it may...
0
9655
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
10363
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...
0
10169
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...
1
10110
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
9964
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...
1
7517
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
6749
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
5398
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...
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.