I was going to say that sleep() isn't in section 5 of the manual...
heh heh heh :)
I was going to say that sleep() isn't in section 5 of the manual...
heh heh heh :)
He's still not clear which is which.
bis student
At this point, you should copy Narue's code into a file, compile it, and run it. Do it for both programs. That's how you will see what does what.
A university is a type of school, so it is schoolwork.
While your code works, I think you are trying to do too many things at once. For example, the procedure searchTitle should not create the file also, even just for testing. Create a procedure that creates/writes the file from the book array (say, ArchivarLibros), and another that reads it into the book array (say, LeerLibrosDeArchivo). Then, if you want to just make a file for testing, create a procedure that is called first which fills the array and saves it to file with the ArchivarLibros procedure.
You will also want to use a dynamic array instead of a fixed array. Dynamic arrays in Delphi always begin at zero, not one.
Whenever you find that you are doing something over and over, that is a good hint that a small function or procedure might be handy. For example:
[[I][/I]code=Delphi[I][/I]]
function PedirConfirmarONegar( msg: string ): boolean;
var
respuesta: string;
begin
{ La falla es fracasar, para un compiler feliz }
result := false;
{ Pida el mensaje }
writeln;
writeln( msg );
write( ': ' );
{ Repita hasta una respuesta correcta }
repeat
readln( respuesta );
case upCase( respuesta[ 1 ] ) of
'Y': begin
result := true;
break
end;
'N': break
else begin
writeln( 'Please answer YES or NO' );
write( ': ' )
end
end;
until false
end;
[[I][/I]/code[I][/I]]
OK, now for your actual question. You want to search titles for substrings. In Delphi, …
I haven't looked through your last posting too closely yet...
2 and related stuff
It appears that your teacher expects ApplyFilter() to be a member function of either TheData or TheFilter. You must choose one, and be able to justify your choice to the professor.
The ApplyFilter() function, however should never access private members of any foreign class. In other words, if it is TheData::ApplyFilter() then it should not access the private members of TheFilter. Likewise, if it is TheFilter::ApplyFilter() then it should not access the private members of TheData. Hopefully, thinking about this will help you choose which class should have the ApplyFilter() method.
The foreign class should only be accessed by accessor methods. In other words, to access any data element of TheData, write member functions double TheData::getValue( int index )
and void TheData::setValue( int index, double value )
This allows controlled access to TheData's data, and as part of the public interface, is OK to use anywhere. The same holds true for TheFilter.
inheritance
It appears from hint #5 that your teacher will not permit you to derive TheFilter and TheData from the same ancestor class. Just because they look similar is not sufficient to say that they are the same kind of thing.
Unless you can reasonably argue that they are, in fact, variations of the same thing.
1 and thoughts
Lerner suggests that you overcome the obstacle by creating a third class, which encapsulates the program and …
Python GUI programming is no more or less platform independent than C++ GUI programming. The only difference is the libraries used.
If you want to link between Python and C++, you might want to use the same GUI library in both bodies. You can use Tk (Tkinter in python), or wxWidgets, or FLTK, or GTK.
My personal observations are that people tend to like wxWidgets best, followed closely by FLTK.
See here for python GUI links.
You will generally find it no more difficult to program these in C++ than Python. Whatever you choose will require a bit of a learning curve.
Hope this helps.
Why such bitumen?
I've no problem with your web based application suggestions, and I said no ill of it. You did, however, suggest (now twice) he spend time learning VB.
Why do you believe that it is more difficult to develop a program in C++ or Pascal than VB? That is nothing more than bias on your part.
If you have only a month to develop a program, why spend time learning something you don't need and cut into time needed for development? This is business 101 here. Use the tools you know how to use, and don't waste time on ancillary problems.
Ah, this is an interesting problem. I have to go somewhere right now, but I'll give you some attention later today.
Is this schoolwork? Or is it business? (I'll make you work harder if its for business, since commercial programs must be much more robust than school programs...)
Hasta luego.
Very nice! Good job!
1. Line 11: You forgot to initialize BX with the address of "string".
2. Line 13: You forgot to give a size: cmp [B]byte ptr[/B] [BX], '$'
Personally, I would remove lines 36..38 since it serves no purpose. If you are going to ask the user to press a key, first print a message telling him to do it.
Also, I'd add just a few more comments: what are lines 13..15 doing? what is line 23 doing? and 32..34? and 40..42? Just a one-line synopsis (like in my example under "three" above) will do.
I'd give this an A (once 1 and 2 are fixed, that is).
I've just got to wonder why people keep posting to use VB and others when the OP did not indicate that he knows it:
I know a few, like C++, Pascal, SQL and some web based application
As he has but four weeks to do it:
If you need to finish in four weeks, a suitable language would be the highest-level language that you already know.
Emphasis added.
When it is time to work, use tools with which you are familiar. Don't waste time learning some new tool when you already have tools that can do the same job.
Doh! :$
Nice catch!
What about 1e7
?
Good start. I'm using MASM, so I don't know if some of my remarks are accounted for or not.
one
You need to load DS with the proper value. Generally data and code are separated into different segments, but they need not be. You'll need to start with some directives about the memory model also...
.model small
.stack 64
.data
string db '123 test TEsting$'
.code
start:
mov ax, @data
mov ds, ax
...
end start
two
The loop opcode relies on CX. You have used loop but you have not initialized CX. Therefore, your loop will execute some random number of times.
To test your code, I just added lea bx, string
mov cx, 16
uppercase:
since your string is 16 characters long (not counting the '$').
However, this is not a good solution. Instead of using loop, why not test to see if byte ptr [bx]
is the '$' character, and jump to the beginning of the loop if it is not? That way your string can be any length...
three
Always halt your program with:
; terminate with return code 0
mov ax, 4C00h
int 21h
You can of course change the return code as required. Zero indicates normal termination.
Hope this helps.
Read the Manual.
Show us what you can do and we'll help you where you get stuck.
You will need a loop and two conditional checks to see if the letter needs to be converted to uppercase.
I assume ASCII?
My best guess is that the argument is a "type-cast expression" (according to MSDN), which always takes the form: [B]([/B][I]typename[/I][B])[/B]
This makes a semantic difference when lexing/parsing types like struct foo
and int *
.
I'm not too sure though... I've never cared enough to get that deep into it, as it is always legitimate to surround any sizeable expression with parentheses...
Line 19 should read newp = (nameval_t *) malloc( sizeof( nameval_t ) );
This is why I recommend just always using parentheses with sizeof. It always works with parens, but makes a difference without...
Be careful suggesting something that he doesn't know.
Sarehu's response is correct: choice of language won't matter so much as long as you are familiar enough with it to do the job. The more high-level the better. (Hence, given your list, C++ and Pascal are both good choices.
There is no need to restrict yourself to one language. If you feel that you will use some SQL, then use it too. Delphi is specifically designed with database development in mind, but I'm sure that C++ products (Borland's, at least) can handle database components just as easily.
In the real world, choice of language is driven by business concerns. In academia, that concern vanishes. If you can't see any clear advantage for one or another given your requirements, then just choose the one(s) you think will be easiest for you to use.
Eh, why not?
[[I][/I]code=C++[I][/I]]
switch (pnlCards.Tag) {
case 0:
result = prediction;
break;
case 1: case 2: case 3: case 4: case 5:
TPanel p = (TPanel)(pnlCards.Controls[ pnlCards.Tag ]);
TPanel p0 = (TPanel)(pnlCards.Controls[ pnlCards.Tag-1 ]);
if (p.Tag > p0.Tag)
result = higher;
if (p.Tag < p0.Tag)
result := lower;
if (p.Tag == p0.Tag)
result := pair;
break;
}
[[I][/I]/code[I][/I]]
I took a single liberty to make typing easier. This code could be much better written in both Pascal and in C++.
Lerner, you are assuming too much and hijacking this thread from the OP's question in an attempt to battle me. You have presented a solution. I have presented a similar train of thought. Now the OP needs to look at his homework assignment and make a decision as to how he will proceed, based on his knowledge of the problem set. Since neither you nor I know anything about the problem set other than what the OP has told us (which isn't much!), we are hardly in a position to give authoritative advice on how to interpret it.
Just because the OP, or his professor, did not prohibit x, y, and z, does not mean that we here should encourage the use of x, y, or z in his program. That is the professor's perogative. Not ours. It is too often the case that, in an effort to help, people lead beginners into things that are not part of the assignment, which is always an intentionally limited subset of programming, and thereby distract the beginner from the thing the professor expects him to be working on and learning about.
You are misunderstanding me, as you have taken pains to disagree with me about things for which we had both suggested, and you are misrepresenting my concerns. Please stop. If you really feel slighted, take it to PM and stop toasting here. I'll warn you though, I have a very comprehensive knowledge about program transformation.
Lastly, from what …
I think you missed my point.
First off, I expressed no disapproval of deriving TheData and TheFilter from a common ancestor. What I said was that they shouldn't be intimately familiar.
Secondly, I don't think you should be introducing new structures into the assignment. Particularly as the FilterProgram is, as you have suggested it, simply a stand-in for main(). The assignment could be just as easily, and more simply, written without it:
struct TheData
{...};
struct TheFilter
{...};
int main()
{
TheData data;
TheFilter filter;
TheData filteredData;
...
}
Your solution sidesteps the problem of instantiating a single object in a way the teacher will not accept! Remember, keep it simple, and don't shuffle creation of things off into another function just to avoid doing it in main(). Avoiding main() is not a good enough reason to do that.
My question remains valid: how are you to initialize both the data and filter objects before filtering? And how are you to display the filtered data when done?
If your program is to behave like the original:
then there must be some consideration given to the following:
I'm not sure I understand one part of your assignment. You stated that you are only allowed to directly instantiate one object. This makes little sense to me, as the program requires two objects to combine to produce a third. FilteredData = OriginalData + Filter
(where '+' means 'apply the filter', of course).
This train of thought is validated by the fact that both the OrignalData and the Filter require user input.
While Lerner's suggestion about shared inheritance is good, given the actual structure of the classes, this is actually just a happy convenience. In reality, the filter and the data are only related because the filter modifies the data in some way. That is to say, the filter and the data are separate things, both conceptually and implementationally. (That one operates upon the other is not causal, just as their similarity in structure is not causal.)
In summation: how exactly does your professor expect you to create only one object at the start?
Thought 1:
Make FilterProgram a function, which takes as argument a TheData object (the one you create in main()), creates a TheFilter object, applies the filter, and returns to main() a filtered TheData object.
This of course will spread user I/O out between main() and FilterProgram()... (Indirectly, of course, as actual I/O should occur as you have it: in your member functions).
Thought 2:
(Is a really bad idea, so I won't share it.)
:-/ …
No, but I think there should be a comma at the end of line 22.
I've never directly made dialogues in an RC file though... If I'm wrong about line 22 I'll have to look it up.
Yes, your code is littered with errors, which is why I advised you to toss it and start anew. The fact that it works is a trick on you.
If you wrote any of the stuff above then you should know how to compare a number in a register to see if it is larger or smaller than another number.
What?
I think that the compiler is complaining that it doesn't know what NumOfPlayers
is, or believes it to be something other than a variable. Likewise in your argument list, one of them is not the type of thing it ought to be?
This can occur due to a syntax error (such as forgetting a semi-colon, or mis-matched braces, etc.) in some line above line 265.
It can also occur, amazingly, if you have whitespace other than spaces, tabs, and CR and LF in the lines, and sometimes if you don't put spaces between the "switch" and "(" ---I think, but I am not sure. GCC shouldn't have these problems...
Glad to be of help. I check in fairly regularly, but if I'm not here someone else will surely help. There are a fair number of knowledgeable people here who are always willing to help.
Have fun! :)
Just check to see that the number is not less than one or greater than 99.
The difference is how data is represented in memory.
str1 db 52, 50
str2 db '42'
The strings str1 and str2 are identical. Both contain the two-character ASCII string "42".
However, the number 42 is stored as just that:
num db 42
Notice how the only difference is how we think about it. We could say that str2 is really just an array of two numbers: 52 and 50. Or a single WORD-sized number: 12852. Or a string. Once we decide what it is we must use it correctly.
Since the user input is an ASCII string, we must change it into its proper numeric representation.
The ASCII digits and their numerical values are:
ASCII
char '0' '1' '2' '3' '4' '5' '6' '7' '8' '9'
value 48 49 50 51 52 53 54 55 56 57
To convert the representation (in ASCII) to its numerical value, we must do a little math:
(as numbers)
52, 50 - 48, 48 = 4, 2
(as characters)
'4', '2' - '0', '0' = 4, 2
Now we just need to change the sequence 4, 2 into a single number:
4 * 10 = 40
40 + 2 = 42
This should be enough to get you started. I recommend that you do it in a procedure:
str_to_int PROC NEAR
; this proc converts the $-terminated string at DX into a number
; the number is put in AX
; (you must write code here)
; (at …
I'm sorry, but like I said, I will not give you code. I will help you with the code you have. There is a distinct difference.
What you have above is likely to hurt you more than help, so I would start over if I were you. First, write what you want to do in a very simple C program or pseudo code. Something like the following is a good start:
char number1string[20], number2string[20];
int number1, number2;
printf( "Please enter the first number: " );
fgets( number1, 20, stdin );
number1 = convert_to_int( number1string );
/* and so on */
Once you have a good high-level idea of what you want to do it is easy to translate things to a low-level representation. Each of the above lines easily convert into a maximum of about 4 lines of their equivalents in assembly.
Here is a very handy INT 21h table.
Looking at that table I see that function 09h writes a string to the standard output. The string must be terminated with a '$' character. So:
.data
ask_for_first_number db 'Please enter the first number: $'
.code
; required initializations
mov ax, @data
mov ds, ax
; printf( "Please enter the first number: " );
mov ah, 09h
lea dx, ask_for_first_number
int 21h
; etc...
Do this and post again when you get stuck.
The problem is that you are trying to multiply strings, which you cannot do.
Remember, the string '12' is different from the number 12.
So, you must first convert the PARADATA strings into numbers, multiply them together, then convert the resulting number back to a string, which you can print.
Since you seem to have a pretty good grasp of things, might I recommend you use some subroutines? (You don't need to, but it'll make things nicer.)
I haven't read anything past the attempt to multiply strings...
Hope this helps.
Hey Sara, I don't mean to be too harsh, but at your current level this is waaay over your head.
It appears that you have been hacking at the above code for some time because it is a mess. If this is a school assignment it might be a good idea to drop the assembly class and concentrate on the C/C++/Java classes first. If this is just on your own then save assembly for some time after you become comfortable with C/C++/etc...
I can help you, but you must know that assembly requires a great deal more concentration and organization of your thoughts than typically required to pass courses in high-level languages (like C/etc.), and I have no intention of just giving you answers so you'll have to work for it.
Let me know what you want to do.
You are making two errors:
1.
The type of Q.Data[n] is a Flight (aka ItemType) --not a pointer. You cannot assign NULL to a struct.
When I tested it, the following compiled correctly: Q.Data[i].C_TIME = 0;
(which is what you were complaining about, so I cannot replicate your problem).
2.
Your for loop has a fencepost error. It should be: for (i = 0; i < MAXSIZE; i++)
Also, I would recommend against using typedef gratuitously. If ItemType is a Flight, then use "Flight" in your QType structure, instead of renaming it to something else...
Hope this helps.
The difference between an procedural and an object-oriented approach is how you bind the data and the functions that do something to it together.
Right now you have a very good structure. You have structs that hold the data, and functions that operate on specific data.
What you need to do is turn those structs into classes, and make the procedures and functions that operate on the structs into member functions (or methods) of the class.
Keep in mind that the member functions should generally work only on its own data. So, for example, you have the functions EnterData() and EnterFilter(). The first would make a good method of your TheData class, and the second would make a good method in your TheFilter class.
Your DisplayData() function operates on a number of different structures, but not any of them at the same time. Each of your classes, then, should have a DisplayData() method, which only displays it's own data.
You will have to decide how to use the filter class and the data classes all together. You could:
You will still have to create three separate variables, but instead of assigning them initial (or default) values in main(), have the class constructor initialize the data.
…
We can help you if you make an effort.
How do you expect to accomplish your program goal? As a hint: roman numerals are representations of numbers; you will want to convert them to integers, perform your operation, and convert the resultant integer back to a roman representation. This suggests at least two functions you can write.
Post again with your code and we'll help you more.
I'm not sure how I have failed to address your problem.
In both your first and your latest post, you indicated that you need to do three things:
The link article I gave you specifically deals with 1 and 2, which can be done at the same time. Further, the article is aimed at making a full copy --where it is not cross-linked between the old table and current data-- which is what a backup generally entails. The article deals with Paradox tables using Delphi.
To delete an old backup table, delete it just as you would any other table.
If I have misunderstood your problem please try to be more specific about exactly what it is that you are trying to do.
Here's a Delphi Corner article that may help you.
Personally, I dislike playing with databases... so my knowledge is a bit weak in this area. Let me know if it helps.
It is just an idiom. See here. In this context, it means that you should take a look at the lists I gave you and choose the one you think best fits your needs.
GUI building always requires you to think about what you are doing and how the user expects to interact with your application. Some toolkits make implementing your design easier than others. Some even come with GUI builders or form designers.
Difficulty does not correlate to language (well, usually).
MIPS is specifically designed to have as few instructions as possible/reasonable. Therefore, there aren't any string opcodes. You'll have to do it char by char. Sorry.
All those functions are for dealing with GUI stuff. Linux is an operating system. On top of that sits "X", the GUI. Unless you are a fanatic, you don't want to deal with xlib directly, so you'll have to choose a GUI framework. (I just responded to a similar post here: http://www.daniweb.com/forums/thread102629.html).
Good luck.
Free Cross-platform GUI Frameworks
The GUI Toolkit, Framework Page
Pick your poison. Others will post here with favorites.
This is the Pascal language subforum.
What programming language are you using? And what database are you using?
Ah, I misunderstood.
Just mmap the file, then every time you fork() the child should inherit the handle to the mmapped file.
Each child should append to the file. The parent needs only seek to EOF and check the file position to see if something has happened.
I've got to ask though, why so many processes forking each second? You'll overload your processor.
Use function overloading:
void LoadFile( std::string filename, std::string key )
{
// blah
}
void LoadFile( std::string filename )
{
LoadFile( filename, filename );
}
Have fun!
Yes, it is bad practice. But the caller's question was, as I understood it, more to the way the stack actually works than to the propriety of doing it.
I could be wrong.
The parent is the only process that needs to keep a list. Each child needs to worry about only one RequestLog.
The call to mmap() is the same, but what you do with the result is different: the parent stores the result in a vector, while the child just saves it in a single variable and writes and closes its end before terminating.
Hope this makes sense.