answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

What is the difference between an array shift and unsetting a variable in PHP?

By shifting the values in an array, you are moving a key's value to the previous key. The very first key's value is obliterated. By shifting all values in the array, all keys will have a value of NULL. Unsetting a variable is entirely different -- performing a variable unsetting causes the variable to have a value of NULL, as if it was never set.

How do you program a button in WinCC script to open a specified file in adobe reader when clicked?

Did you find an answer yet?

I must say, WinCC could be a vastly more powerful package if the various scripting languages and macros had access to the same framework.

Since their help file is a badly translated version of a German document, and their use of the same word to describe several technologies, finding information is a very painful task. To make matters worse, once found, it's usually just a fragment of the information you need!

It's almost like buying a manual to build a ship. The instructions are "Gather steel" then..... nothing. Another laborious and painful search starts.

I can rant for hours about the various inconsistencies, but, instead, I'll give you a link to an OCX I wrote in VB6, which took about 10 minutes (at most.. took longer to write the usage instructions than it did to write the OCX) that will enable you to open any file in its associated application... send it a pdf, it'll open the reader. Send it an HTML file, it'll open internet explorer (or firefox or whatever the associated app is)... a doc file? It opens word. (if installed, of course).

http://www.vbsight.com/Zips/LaunchFile.zip

You'll need to contact me for a password to that zip file. There is no licensing but I'd like to keep track the number of people that find it useful. You can contact me by visiting the site above and using the menu to get to the contact page (trying to avoid endless spam from posting this answer... I hope you understand)

Ken Halter (MS-MVP-VB)

How do you get FBide basic to pause for 5 seconds before doing the next command?

You can't. If you want to pause between each command you have to step through the commands one at a time, or set a breakpoint at the point you wish to start stepping through.

What are curvillinear coordinates?

Curvilinear coordinate systems are a means of describing an object/point's position based on angle and distance from the origin. For example, polar coordinates are Curvilinear coordinates for R2 (2D space). Spherical coordinates are Curvilinear coordinates for R3 (3D space) If you need to know more:

http://en.wikipedia.org/wiki/Curvilinear_coordinates

A full node is a node with two children Prove that the number of full nodes plus one is equal to the number of leaves in a binary tree?

Let N = the number of nodes, F = number of full nodes, L = the

number of leaves, and H = the number of nodes with one child (or half nodes).

The total number of nodes in a binary tree equals N = F + H + L.

Because each full node is incident on two outgoing edges, each half node is

incident on one outgoing edge, and each leaf is incident on no outgoing edge it

follows that the total number of edges in a binary tree equals 2F + H. It is also

true that the total number of edges in a tree equals N 1. Thus,

2F + H = N 1

H = N 1 2F

Subbing this value of H into N = F + H + L gives,

N = F + N 1 2F + L

N N + 1 = F + L

F + 1 = L

What is abstraction in oops?

Abstraction means to describe with a term or a brief sentence that the audience can understand the entirety.

In OOPS context, the program unit is an abstraction by itself. When we use the term "program", we sort of know what it is, yet don't know anything of the detail what it can and will do.

Hence, any software element may be thought of as an abstraction in OOPS if you do not know the detail implementation!! The element may be small as a method, a property, a class, an interface, and up to the entire application/program itself.

What is a virtual table in C?

A virtual table, or "vtable", is a mechanism used in Programming languages to support dynamic polymorphism, i.e., run-time method binding. Hope ive helped. Each function has an address in memory somewhere. Function names are just pretty ways of referring to a position in memory. When a program is linked (after the compiler is finished compiling) all those names are replaced with hardcoded memory addresses.

class Foobar

{

public:

int i;

void Something() {i = 0;}

};

int main()

{

Foobar f;

f.Something();

return 0;

}

You can tell even before execution that f.Something() is referring to the Something in Foobar. The linker will be able to replace that with an address pointing directly at Something.Draw().

This works pretty well until you bring in polymorphism because the linker is unable to tell which function to call. For example in C++:

class Foobar

{

public:

int i;

Foobar() {i = -1;}

virtual void FuncA() {i = 0;}

void FuncB() {i = 10;}

};

class Foo: public Foobar

{

public:

virtual void FuncA() {i = 1;}

void FuncB() {i = 11;}

};

class Bar: public Foobar

{

public:

virtual void FuncA() {i = 2;}

void FuncB() {i = 12;}

};

void FoobarFunc(Foobar* fb)

{

cout << fb->i << endl;

fb->FuncA();

cout << fb->i << endl;

fb->FuncB();

cout << fb->i << endl << endl;

}

void FooFunc(Foo* f)

{

cout << f->i << endl;

f->FuncA();

cout << f->i << endl;

f->FuncB();

cout << f->i << endl << endl;

}

int main()

{

Foobar fb;

Foo f;

Bar b;

Foo OtherFoo;

FoobarFunc(&fb);

FoobarFunc(&f);

FoobarFunc(&b);

FooFunc(&OtherFoo);

return 0;

}

In this excerpt, both Foo and Bar inherit from Foobar. FuncA is a virtual function while FuncB is not. The integer i is being set to see the results of our actions.

Notice how in FoobarFunc, you are unable to tell beforehand what address to replace FuncA and FuncB with! In order to solve this, virtual tables are created.

Normally, functions are not stored with the data of the class at all. So in our very first Foobar example with no inheritance, the class would only be 4 bytes long (excluding any compiler magic). However, when you declare something virtual, you're actually declaring a pointer to a function so each virtual function you have will increase the class size by the size of a pointer. The pointers will be populated by the constructors under the hood which is one reason why you cannot have virtual constructors. If you have many virtual functions, you end up with many pointers, which are organized into a table... the v-table. Each class will have its own unique v-table.

When a child class is constructed, the parent class's constructor is called before the child class's constructor is called. Each classes constructor will put the addresses of all the virtual functions it has into the v-table. In our example, when Foo is instantiated, Foobar's constructor is called first. Foobar's constructor will place the memory location of Foobar.FuncA into the v-table. Once Foobar's constructor is done, Foo's constructor will execute, placing Foo.FuncA into the table.

In FoobarFunc the line fb->FuncA(), actually replaced by an address to the v-table. When that line is executed, the computer will go to that location in the v-table, fetch the address of the function, and then jump to that location in memory. Because of how the constructors setup the v-table, you end up calling the correct function.

If you look at the example, you'll notice I have included FuncB which is not declared virtual to highlight the difference between virtual and nonvirtual functions. In FoobarFunc, the parameter is Foobar. Because FuncB is not virtual, there is no entry for FuncB in the v-table. The compiler/linker will hardcode the address in the binary and cause the program to always execute Foobar.FuncB no matter what gets passed in as the parameter. No polymorphism. In FooFunc, the parameter is Foo. Foo.FuncB will always execute in that function. Again, no polymorphism.

What is a word for performing at high level?

class-leading performance / top-tier performance / advanced performance

What is SAS 70-2 certification?

The SAS 70 audit process includes an in-depth audit examination of the effectiveness of a service organization's internal controls. A SAS 70 audit is very important to public companies in the US that are required to comply with the terms of the Sarbanes-Oxley Act (SOX) of 2002. Online Tech's audit process, along with our HIPAA compliance, offers all clients at each data center the following competitive benefits: # Assurance that the internal controls within the data center are in place, are suitably designed, and are operating effectively. # Assurance that physical access, IT infrastructure, data and network are secured against certain threats.

# Assurance that the data center's control policies and procedures have been evaluated and reviewed by an independent third party. # Confidence that colocating with a data center operator that has undergone a SAS 70 audit provides clients the ability to assure their own customers that their data and information is secure, helping them keep, attract, and build their business.

Online Tech has learned a lot in completing the SAS 70 audit process and has plans to share the hard-earned knowledge gained with other Michigan businesses. Many of our clients are able to spare themselves the auditing process and expense by outsourcing their data centers to Online Tech's SAS 70 audited data centers.

Feel free to email us at sales@onlinetech.com or call us at 734-213-2020 to get more information.

Online Tech is a Managed Data Center Operator and we recently completed our SAS 70 audit for all three of our data centers here in Michigan. We made the move because a number of our MSPs and hosting partners needed SAS 70 compliance to serve their customers which are public companies. With our SAS 70 audit in place, our clients can now position themselves as running from a SAS 70 data center - in fact we even created a SAS70 logo for our partners to leverage in their marketing. We also just wrote an article on our experience - "5 Tips for Surviving a SAS-70 Audit" - see - http://www.onlinetech.com/resources/enews/marchenews/

How can I use vesa without bios interrupts?

That is not possible. Only the vesa set bank function can be used with a "far call" instead of using the software interrupt for to set the banknumber of a banked vesamode. The pointer(offset,segment) for this "far call" can be found in the mode-info-buffer+0Ch. On my older et4000 isa-bus card(1 MB) and et4000-w32 vlb-bus card(2 MB) i found the portnumbers(3CDh and 3CBh) for to change the banknumber in the code of that cards when i was unassemble this function in there bios. Trying the same on a geforce4 ti4200 agp card(64 MB) i never found those portnumbers, because i have many problems to follow all of the many branches in the code.

Dirk

Traversing in Doubly Linked List is faster then Singly Linked List?

Traversing a doubly linked list is generally faster than traversing a singly linked list, but the speedup depends on how you do the traversal:

  • Traversing from first to last node: No difference.
  • Random access: Doubly linked list is faster, the difference is a fixed factor. (Like twice as fast. Which makes it still very slow for random access compared to arrays.)
  • Reverse order: Doubly linked list is just as fast traversing "backwards" as "forwards", while a singly linked list traversing in reverse order needs to traverse the entire list once for every element in the list - it is a LOT slower. (Time complexity O(n) for doubly linked list, O(n*n) for singly linked, if you are familiar with the notation.)
If you are talking about the computer science "big O notation", doubly linked and singly liked lists are the same. This is because the Big O notation ignores fixed factors and only looks at how time increases with the length of the list, and in this respect the two are the same. (Except for the special case of traversing the list in reverse order. Even here a singly linked list could do it in O(n) time - same as a doubly linked list - by reversing the list (O(n)) before traversing it (O(n)) for a total time of 2*O(n), which by the rules of Big O is the same as O(n).)

How do you allocate memory dynamically for a string of unknown size in c?

With function strdup (here is an implementation, if you don't have one already)

char *strdup (const char *f)

{

size_t len;

char *to;

len= strlen (f);

to = malloc (len+1);

if (to) memcpy (to, f, len+1);

return to;

}

What is an example of a logical procedure?

A logical procedure is any procedure that identifies the unknown from the known.

For example, a procedure that returns the maximum of any two given values has two known variables (the given values) and one unknown variable (the result). By logically examining the known, the unknown can be determined.

Given the values x and y, the logical process can be reduced to the following pseudocode:

If x is greater than y then return x otherwise return y.

In C++, we'd encode this logical procedure as follows:

template

T& Max( T &x, T &y ) { return( x>y?x:y ); }

What is difference between interface and abstract class?

All the methods declared inside an Interface are abstract. Where as abstract class must have at least one abstract method and others may be concrete or abstract. In Interface we need not use the keyword abstract for the methods.

How do you save a file that says read only?

although the details varies depending on the application used, the general thing to do is to go to File then choose "Save As", and save the files as a new name. note: you may need to expand the menu (by clicking on the arrows pointing down at the bottom of the File menu to see the Save As choice. once its saved then you can right click the file within Explorer and choose properties and uncheck the read only box then it won't be read only anymore.