WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

OK, now we know where to go. Look into the instr() function. It will look thru string A to see if string B is contained in A. Using the code you posted:

InFile = FreeFile
sFile = txtFile.Text

Open sFile For Input As InFile
'' Open the output file to hold the edited data

While Not EOF(InFile)
    Line Input #InFile, sTemp
    '' here use the instr() function to see if you should output 
    '' the line to a second file.  If so, output the line.
Wend
Close InFile
Close OutFile
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
While (b not 0)
{
    test odd or even
    {
        save the result (0 or 1) in an array
    }
    shift b right 1 bit (or divide by 2)

}
output the array from last value to the first.

If you use the division version, b should be an unsigned value.

Alternate for the loop, if your value is 32 bits, simply use a for loop and you won't have to worry about signed/unsigned and your output would be a full 32 bits.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Question #3?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What are something.X files and how to edit them?

Thanks!

Don't know. And if you don't know, why would you want to edit them?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

thanks to your reply,but sir a want a sample code..thanks

Please sir, first answer these questions:
1) do you know how to open a file?
2) Do you know how to read the file one line at a time?
3) Do you know how to check if a line (string) contains specific substring?

And finally
4) Are you trying to learn how to program, or have the program written for you?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What have you tried? The code posted doesn't have any file read at all.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Read each line
If it contains "Event:Access, Door:entry, Card No.", write it to the file
If not, don't
If not at end-of-file, go back to read the next line

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Now I wonder if someone can give an idea on how would be the best way to assemble a function to do this task. Maybe which C function would be the most appropiate to handle the strings and do the word extraction without touching the tags.

So you want to know which one single function you should use? That's a tough one :eek:

Seriously, the way to handle this is to
- read a line at a time
- remove all the html tags leaving only the 'real information' from the line
- then process what's left to get the information you want

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hi WaltP,

You are so funny. :-)

:o

So, I have to learn Perl and PHP script, right?

No, just one.

Are they the same? Which one is better?

It would be best for you do make that determination. Only you can tell what you'd be comfortable with. I'm not an expert in either, but I personally found PHP easier. Perl I believe is more powerful.

Do you know any other languages? If you know C++, PHP might be the way to go. Otherwise, take a couple days to look into both and see which one makes sense to you.

Maybe other will jump in with their recommendations.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

> with a return 0 at the end of the program, as defined by the C++ Standard.

Actually, return 0 is implicit for main() if a return statement is omitted. It's probably still good practice to explicitly return something, however.

Then why bother with the comment, other than to just confuse the newbie who's already confused? ;)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

That depends. Since we don't know what websites you're talking about, we can't tell. It could be a couple things.

One way to find out is view the source of the page you're interested in. Sometimes there's information there on what they did.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hi,

Sorry to ask this question, may be some kind of stupid but I just learning web design for my website only.

Sorry to have to answer this question :D Gee I'm funny -- NOT!

Can anyone recommend any link or web address where I can learn how to build the register page, log in page and link to us page on my website, please? Or if you can tell me, how to build, it would be really appreciated.

It depends on what scripting possibilities you have available. Can your target system handle Perl, PHP, or ASP? If not, you're SOL. If so, GR8!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

YEs, there are quitre a few people here that can help. What have you got so far?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Multiplication generally works. Even for AU dollars.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What S.O.S. said.

And indent more. 3-4 spaces, not 1, is standard.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

But it still doesn't work for me.
I'm just a freshmen. I set up a blank workplace, then win32 application project, then a c++ cource file.
Then type as below:

#include <iostream>

void main()
{
std::cout <<"welcome" <<std::endl;
}

No matter I use "main" or "WinMain" in the second line, it just doesn't work.
Also the linking problem.

This is not a "win32 application", it's a "console application". They are two completely different things.

And "it just doesn't work" tells us nothing. It outputs the Gettysburg Address instead of "welcome"? It turns your computer off? It has compiler errors? There are hundreds of ways it might not work. Be specific. Like void main() is wrong. It is supposed to be int main() with a return 0 at the end of the program, as defined by the C++ Standard.

And code tags are to surround all code postings. Begin code with [[I]code[/I]] and end with [[I]/code[/I]]

Salem commented: Agrees - Salem +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Write down the steps your program takes -- from top to bottom -- including inputs and variable values. Skip nothing.

I repeat -- write the steps -- this does not mean post code. Line by line convert your code to text, executing the statements as you go on paper.
When you have an input statement, what value on paper goes into the the variable. When you get to the while, what happens? When you get to the ifs, what happens?

This is desk checking your code -- a required step in most programs. I remember testing my code this way with little pieces of paper all around me while I sat on the floor. My boss thought I was nuts, but the program worked when I ran it...

And what is that dang getch() doing in there? I thought we got rid of that 5 hours ago! This is not helping me help you... Neither is your formatting. Indent 4 spaces after every { and unindent 4 spaces before every }. Each and every one!

~s.o.s~ commented: so helpful and patient, hats off to you Sir - ~s.o.s~ +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I thought this was supposed to start my loop and end it, if the user pressed 0. That was the intent....If the user presses 0, then the loop is supposed to end.....

What loop? [edit]rephrase -- Why loop? Why where you put it?[/edit]

Write down the steps your program takes -- from top to bottom -- including inputs and variable values. Skip nothing.

What do you come up with? Post it here...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What does while (iResponse == 0) { do?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Okay for your first question I should change the for statement to i<6

Yes now that you have pointed it out I see that there is a correlation between the two sets.

My outer loop is:
0, 1,2,3,4,5
the difference between that and what I need to print is
2,3,4,5,6,7
so the inner loop actually would appread to be the outer loop number +1 right?
so I could add 1 to i for the inner loop such as j=i+2; ?

Thank you

In both cases -- BINGO! Two loops is all you need. One outer for the lines, one inner for the *s based on teh line you're on...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

OK, I changed like you said, but now my formulas are not even calculating.....

Is there something about formatting you don't understand?

And I see a getch() in there....

Oh, you posted the code you originally had....

Did we just waste the past hour or two?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

WaltP it never occured to me at the time to preview my post but your absolutely correct and thank you for the pointer on initialization of the variable.

Hmmmm.... no comment :)

My thinking was that I since I needed to print six lines of star's that I would have the outer loop run six times, ...

Good thought.

then I needed an inner loop to run six times but increment by 2 such that I would have another loop run 2 times, then 4, then 6, then 8, 10 and finally 12 times so that my cout <<STAR; statement would be printed by the same number each time through so that I would have the following output:

** print 2 times
**** print 4 times
****** print 6 times
******** print 8 times
********** print 10 times
************ print 12 times

You just complexed it out of reason.

Let's think about this... (yeah, I know that's what we're doing... ;))
You have one outer loop that goes from 0 to 6 for(i=0; i<7; i++) That's 7 lines... What's wrong here? That you can fix easily.

Now you want 6 lines of 2, 4, 6, 8... *s. Your loop goes 0, 1, 2, 3...
Is there a correlation between what you want and your loop?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

As I mentioned in another thread, "formatting is of primary importance. Every time you use { indent 4 spaces. Just before you use every }, unindent."

No I have never heard of that function. OK, I looked up fgets() and it says it is used to read a line of data from an external source, but I am not sure what that means. Here is the code I have so far...

Bummer. OK, change your getchar() to:

while ((myChar = getchar()) != '\n');  // clean the input buffer
getchar();
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If I understand right I needed to enclose my code in [] right?

No. You enclose the code in tags. You could possiblly use the PREVIEW button to see if your post looks right... ;)

I re-wrote the for statements although I thought that it was okay to declare variables earlier in the program and just place a ";" in the place of the the variable declaration in the for statement? I was unable to get the k variable to compile without first declaring it.

Yes you should declare your variables earlier in the program. And yes you can just ";" if you know what you're doing. The first position is not a variable declaraction is a variable initialization, the first value the variable has thru the loop.

Also, formatting is of primary importance. Every time you use { indent 4 spaces. Just before you use every }, unindent.

Formatted properly, you code looks like:

#include <iostream>
#include <string>
using std::cin;
using std::string;
using std::cout;
using std::endl;
int main()
{
    int i;
    int j;
    int k;

    const char STAR ='*';
    k=2;                    // What does this statement do for you?
                            // What's the value the second time thru the I loop?
    for(i=0; i<7; i++)
    {
        for(j=0;j<k;j=j++)
        {
            cout << STAR;
        }
        {                   // Why are you starting a new block?
            for(k=0;k < 14; k= k+2)
            cout << endl;
        }
    }
    return 0;
} //end of main function
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I take it back.... you used scanf() -- therein lies your problem. It leaves your input buffer dirty. Do you know the fgets() function?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Don't know how you changed your program. What's it look like from the while down?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Yep. That's the first start. Be sure to use code tags... except for the #include " stdafx. h" part.

For the rest, you have to decide what your 'block letters' should look like, how many characters high and wide. Then use a series of cout statements to output a line at a time.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Wow! A first time poster that used code tags!!!! Thank you ! while (iResponse = 0) { sets iReponse to 0, which by definition is FALSE and the loop does not execute.
== maybe? getch() is not standard and should be avoided. Use getchar() instead.

And the bottom of your code should be indented, too, for proper formatting.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Where are the code tags?
Where is main() defined (unresolved external symbol _main)
Did you link with the debug library?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Format your code properly with code tags and finish your for statements (3 parameters, not 2) and repost...

Then we have something readable to work with.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Why not try to make the variable persistent throughout the program by declaring it as global static variable ?

You can best (I think) make an global variable or an automatic variable in main called counter and then add it if the button is pressed.

No, you shouldn't make it global if you don't need it outside the function.
Don't know what you mean by an "automatic variable in main called counter"

i think u better to use static counter instead of counter so that it can retreive the value in betwwen the function calls

Yes. Simply define the counter as static int counter; instead.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

See this. IMO it make this FTP stuff much easier. The FTP site simply becomes a drive on your computer. I use personally use Webdrive.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

huh?

Huh, what. can you be less vague? ;)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I used this to add to one of my pages -- very simple.

I added document.theForm.theMenu.selectedIndex = 0; after the window.open command to reset the selection.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hey this problem is too simple to implemented in an objecft oriented way. Programs this small do not need to have good programming practices. Especially if teyt are just for fun. For somthing this small it only matters if it works IMO.

Well said, if all you want to be is a hobby programmer. For anyone looking at programming as a profession, this is the worst advice they can receive.

All programs should be written using good programming practices. It never "only matters if it works." Have pride in your work.

Im not that good a coder and this program is unweildy and long...

Now we know why... ;)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

probably because BGI requires a 32-bit compiler, which TurboC is not. Upgrade to one of the free compilers mentioned in that link.

Just the opposite. I was using BGI back with Turbo C++ 1.

Download from Borland:
Turbo C++ version 1.01
Turbo C++ version 2.01

Other old Borland stuff can be found here.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

the problem is how could i store the current record in the variable ? Can you give some example ?

I have tried it before but the previous input have been overwrited...

Did you read in the current record? Is it still in the variable space? If so, move it to a new variable (maybe called LastRec) just before you go back to read the next record from the user.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Look under your menus for "Package and Deployment Wizard". This will create an installation package that will install you rprogram on the destination computer.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Even I am not sure what he meant but I didn't ask because that would have spoiled his fun :D

See Wolfpack's signature...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You've mostly got it.

Each C 'string' ends in a character value of 0. That's what your "out of bounds" is really checking, really it's "end of string.

Commented (and formatted properly)

int find_ substr( char *s1, char *s2)
{
    register int t;
    char *p, *p2;
    for( t= 0; s1[t]; t++)  // Move character by character thru the source string
                            // start at the first character t=0 and s1[t] 
                            // until the current character s1[t] is 0 (FALSE)
    {
        p = &s1[t];         // p becomes the address of the current character
        p2 = s2;            // p2 becomes the search string

// Following tests to see if the current position in the source string and the seach string
// matches...
        while (*p2  &&      // Continue while *p2 is not 0 (TRUE) -- end of string not found
               *p2 == *p)   //            and source and search characters are identical
        {
            p++;            // skip to the next character
            p2++;           //    in both strings
        }
        if (!*p2) return t; // out of loop -- if the current character in the seach string
                            //    is 0, we have a match.  Return the substript of the start
                            //    of the sub-string
    }
    return -1;  // substring not found 
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Stupid question. I've noticed that most of the posts seem to sink to the very bottom of the page. Is it possible to reply to a specific post without this happening?

This is a stack, so no. All you have to do to respond to a specific post and still be understood is use "Reply with Quote" button.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

stan yost there is a simple way

lets say you want to pass the text feild of text1

1- declare a public variable in the general part of the form like this

public varaiableName as String

2- in the form_load() write

variableName=text1.text

3- you can access this variable from any other form using the form name

lets say you have form2 and you want to pass text1.text which is in form1 to form2 which has a text feild (text2)

you can do that like this:-

text2.text=form1.variableName

- Regarding calling methods You have first to decalre it as public intead of private sub ---> public sub

and u can do the same thing using the form name to call the function

form1.functionName()


I hope this helps

vbmenu_register("postmenu_246662", true);

lover99509, is this easier than using form1.text1.text as already recommended?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hi VinC,

system("pause");

Use instead.

No, don't. Learn your tools. Using scanf() to read characters is even worse than using gets() because not only does it allow you to blow your buffer boundaries but as you can see it also leaves your input stream dirty. The \n is left in the stream for your getchar() to read.

Use a combination of fgets() and sscanf() for safety and to process the input stream cleanly.

fgets(tmpstr, 80, stdin);
    sscanf(tmpstr,"%d %[abcdefg] %s", &i, str, str2);

[edit]Since you already learned this from GID, you could check out the scanf() series there. [/edit]

Grunt commented: Rightly Said - [Grunt] +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i already tried the code that was given by Lerner, but it seems to be have many error that i can't figure out . "parse error before "contactbook" " and other two more error which i don't remember. And i don't used and don't understand getch() function.

You don't need to compile and run his code. Look at what he did in main() to set up a loop. Then you can stop calling main() from your functions.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

hmmm........can u pls explain it in details bcoz i'm still newbie in C programming. and this is group work, so have to do some research on the topic. I still can't imagine how to use loop to recall a function. examples plz if u don't mind.

Lerner already showed you here, about 6 posts ago.

Also, don't PM members to personally solve your problem for you. Ask questions here, read what they say, and attempt what they tell you.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I just added a Randomize line to the code releting to the command button. So randomize is now in both the Command Button and the frame.

You only need the randomize command once, so put it in form.load only.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

VEdit is excellent.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Best current free compiler/editor for Windows is Microsoft Visual C++ Express linked with the Windows 2003 Platform SDK.

I disagree. Dev-C++ is probably much more compliant than any M$ compiler. M$ tries to steer the industry too much and 'enhances' the standard without following it as closely as it should. Although when it comes to the current compilers, they are probably all close enough for the student. You probably won't do anything complex enough to stray into weird compiler territory as long as you stick with the C/C++ standards...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

For now, I'm going to continue using DM only because it's what my instructor has advised us to use....

I really hate hearing this type of comment. An instructor that can't update his tools seems IMO to not care about his students. The first paragraph of the Digital Mars License Agreement states:

The Software is not generally available software. It has not undergone testing and may contain errors. The Software was not designed to operate after December 31, 1999. It may be incomplete and it may not function properly. No support or maintenance is provided with this Software. Do not install or distribute the Software if you are not accustomed to using or distributing experimental software. Do not use this software for life critical applications.

I question the validity using it in any way simply because of this official statement. Oh well. At least you'll learn something about C/C++ and hopefully can get to a real compiler ASAP.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Thanks, i have not yet learnt loops. I will learn this, it is in my hardback tutorial somewhere only i just havent got there yet. But i understand what you mean, it will give me somthing to work on thanks again bill.

Good. Something to look forward to... ;) And who's Bill?

ps i meant to bold the just thread name only.

So dont try. It's not necessary to bold the title. And if you do you will get people to avoid your posts rather than help because you would look pushy and/or arrogant.