Murtan 317 Practically a Master Poster

If you're running the commview tool on your same computer, I guess the packets are on your network (though I wouldn't have expected them to be).

Is there any way to associate a 239.x.x.x address with your computer (as well as your current ip address) so that you are 'entitled' to the messages?

If not, I vaguely recall a mode for a connection or card that allowed it to 'see' network packets that were not addressed to it. (If commview is seeing the 239 broadcasts I think that's how it works), but I'm not aware of how to put it in that mode.

I remembered the name 'promiscuous mode' for this type of connection. Looking it up as a definition I find:
http://en.wikipedia.org/wiki/Promiscuous_mode

Murtan 317 Practically a Master Poster

It was my understanding (and I did a little searching that didn't disagree) packets sent to 239.255.255.255 should be available to anyone with a 239.x.x.x address.

Does your computer have a 239.x.x.x address?

Are you listening to the right port?

Murtan 317 Practically a Master Poster

Think about it...how would YOU do it?

All you really have to do is additional testing in the year they would turn 18.
If they would turn 17 (or younger) this year they fail.
If they would turn 19 (or older) this year they pass (they're already 18).
If they turn 18 this year you have to compare the months.
If they turn 18 this month, you have to compare the date.

Write some more and ask again if you still can't figure it out, but post what you write along with a specific problem. Something like "It's doing X but I want it to do Y".

Murtan 317 Practically a Master Poster

I don't get it...I modified your file only slightly (below) and the run looks like this:

$VAR1 = {
          'C2_GLH3' => 'GLUC + ATP = GLUC6P + ADP',
          'A1_HTTT24' => 'GLUC_ext = GLUC',
          'B3_PGAI1' => 'GLUC6P = FRUC6P'
        };
Enter reaction name for searching:C2_GLH
Can't find 'C2_GLH' in the file
Enter reaction name for searching:C2_GLH3
C2_GLH3,GLUC + ATP = GLUC6P + ADP
Enter reaction name for searching:APPLE
Can't find 'APPLE' in the file
Enter reaction name for searching:B3_PGAI1
B3_PGAI1,GLUC6P = FRUC6P
Enter reaction name for searching:

and the output file contains this:

C2_GLH3,GLUC + ATP = GLUC6P + ADP
B3_PGAI1,GLUC6P = FRUC6P

Source:

use strict; 
use warnings; 
use Data::Dumper; 

my %reacts;
my $database = "reaction_database.txt";
open(Dbase,"<$database") or die "can't open $database $!";

# Simplified read loop
# Sample input data
#A1_HTTT24 : GLUC_ext = GLUC .
while (my $line = <Dbase>) {
	# optional whitespace, KEY, optional whitespace, required ':', optional whitespace, VALUE, required whitespace, required '.'
	$line =~ m/^\s*(\S+)\s*:\s*(.*)\s+\./;
	$reacts{$1} = $2;
}

close(Dbase);

#debug to confirm file contents -- left in so I could 'see' something to type
print Dumper \%reacts;

my $input;
open (DATA,"+>react_out.txt") or die "Can't open data"; 

do { 
	print "Enter reaction name for searching:"; 
	$input=<>; 
	chomp($input); 
	if (not $input=~/^\s*$/) {
		if(exists $reacts{$input}) { 
			# feedback on what was matched
			print "$input,$reacts{$input}\n"; 
			print DATA "$input,$reacts{$input}\n"; 
		} 
		else { 
			# explicit feedback for what was not found
			print "Can't find '$input' in the file\n"; 
		} 
	}
}until($input=~/^\s*$/); 

close(DATA);
Murtan 317 Practically a Master Poster

Did you try letting the dumper run?
What did you see?

The $1 and $2 in my code are from the regular expression.
They evaluate to the first and second 'groups' in the regex.

$line =~ m/^\s*(\S+)\s*:\s*(.*)\s*\./;
# The above regular expression is decoded as:
#    Starting at the beginning of the line    ^
#    Match zero or more white space           \s*
#    Match one or more non-white space        (\S+)
#         saving it as group 1
#    Match zero or more white space           \s*
#    Match a colon                            :
#    Match zero or more white space           \s*
#    Match zero or more of any character      (.*)
#         saving it as group 2
#    Match zero or more white space           \s*
#    Match a period                           \.
$reacts{$1} = $2;
# This then uses the first saved group as the key and the
# second saved group as the value

You left the split in, but you're using the $1 and $2 from the regex.

Try this (modified from your last post):

use strict; 
use warnings; 
use Data::Dumper; 
 
my ($key,$val);
my $database = 'file.txt'; 
my (%hash,$input); 
open(Dbase,"<$database") or die "can't open $database $!"; 
while (my $line = <Dbase>){ 
chomp $line;  
$line =~ m/^\s*(\S+)\s*:\s*(.*)\s*\./;
	#$reacts{$1} = $2;
#my ($key,$val)=split('\s*:\s*',$line);
#$key =~ /([^\s]+)/;
$key = $1;
#$val =~ /(^\s+)(.+)(\s\.)/;
$val = $2;
$hash{$key}=$val; 
} 
close Dbase; 
#print Dumper \%hash; 
open (DATA,"+>data.txt") or die "Can't open data"; 
do { 
	print "Enter reaction name for searching:"; 
	$input=<>; 
	chomp($input); 
	if(exists $hash{$input}) …
Murtan 317 Practically a Master Poster

I don't think you're adding what you think you are. I think the regex match inside the split is overwriting $1 and $2 before you save them.

I would tend to declare $key and $val outside the loop on line 5, and then comment out the split on line 11 to make sure $1 and $2 are preserved -- you don't use the results from the split anyway.

I think that will work.

For debug, you might print all of the key values you add to the hash or with a little more work, you could just print the first ten added or some other subset of the whole.

Murtan 317 Practically a Master Poster

Here's my test code for the read and store portions...you still need to write the retrieval code. If you have any questions about the code, please ask.

my %reacts;
$database = "reaction_database.txt";
open(Dbase,"<$database") or die "can't open $database $!";

# Simplified read loop
# Sample input data
#A1_HTTT24 : GLUC_ext = GLUC .
while (my $line = <Dbase>) {
	# Regex [whitespace]KEY[whitespace]:[whitespace]VALUE[whitespace].
	# optional whitespace, key, optional whitespace, required ':', optional whitespace, value, optional whitespace, required '.'
	$line =~ m/^\s*(\S+)\s*:\s*(.*)\s*\./;
	$reacts{$1} = $2;
}

close(Dbase);

#debug to make sure I read my data file correctly
#    I only had the three lines -- you may want to skip this if you have a lot of lines
while ( my ($kk, $vv) = each(%reacts) ) {
	print "$kk => $vv\n";
}
Murtan 317 Practically a Master Poster

I don't see where you're storing them.

Did you possibly mean to declare a hash?

#declaration
my %reacts;
# store one
$reacts{$key} =$value;
# test to see if one exists
if exists $reacts{$testkey} { ... }

Declare before the read loop
add a store between original lines 11 and 12
use the test in place of original line 21's while loop

Try that and if it doesn't work, post the new code and we'll look at it.

Murtan 317 Practically a Master Poster

did you mean to save the key and value pairs you read in so you can search them when you open the second file?

Murtan 317 Practically a Master Poster

You put your variable definitions in a .py file you could name it definevble.py if you wanted to.

Then from the other python file (.py) that wanted the variables you add a line:

from definevble import *

That imports everything in that file into this file.

I think that will do what you want.

For example if vardefs.py contains:

pie="Apple"

and vartest.py contains:

from vardefs import *
print pie

The output of vartest.py will be "Apple"

Murtan 317 Practically a Master Poster

In C# a function can return only one value. You're passing the fraction into the simply function as a numerator and a denominator and the function is unable to return both.

Alternatives would be to 'package' the numerator and denominator into a struct or class which you could pass in and return, or you could make the parameters reference parameters allowing the function to make changes 'in-place' in the variables passed to the function.

Murtan 317 Practically a Master Poster

Well, I personally prefer to help with code that will at least compile...

Your original lines 36-39:

status = fscanf(filep, "%d%d%d%d", measuredp->site_id_num
	measuredp->wind_speed
	measuredp->day_of_month
	measuredp->temperature;

are missing the closing ')' for the function call and the ',' separating the arguments.

What dragon was referring to was that with your previous data structure, all of those parameters were arrays which made them implied pointers for the function.

If you make the changes to the data structure he recommended (and I agree with him -- no surprise there) you need to turn these into pointers here so fscanf can fill them in.

status = fscanf(filep, "%d%d%d%d", 
		&measuredp->site_id_num,
		&measuredp->wind_speed,
		&measuredp->day_of_month,
		&measuredp->temperature );
Murtan 317 Practically a Master Poster

You're iterating too far.

The element indexed by cnt wasn't fully read.

On Line 25 the loop limit should be i < cnt not i <= cnt

Murtan 317 Practically a Master Poster

You need to seek before you read (saw you have that), but you need to seek to the same location before writing (by default, the act of reading moved the file pointer).

//Insde main:
     else if(choice==2)
     {
       cout<<"\nEnter the sl.no. of the book :";
       cin>>bno;
       int loc=(bno-1)*(sizeof(books));
       // seek for reading
       file.seekg(loc);
       file.read((char*)&B,sizeof(books));
       B.update();
       // seek for writing
       file.seekp(loc); 
       file.write((char*)&B,sizeof(books));
       file.seekp(0,ios::end);
     }
abhaymv commented: Thank you again! +1
Murtan 317 Practically a Master Poster

I think your problem is that you don't read the records from the file when you're making changes to them.

For example if the first thing I did after starting the program was to check-out or check-in a book, I select menu choice 2 and this is the code:

else if(choice==2)
     {
       cout<<"\nEnter the sl.no. of the book :";
       cin>>bno;
       int loc=(bno-1)*(sizeof(books));
       file.seekp(loc);
       B.update();
       file.write((char*)&B,sizeof(B));
       file.seekp(0,ios::end);
     }

You seek to the position but don't read the data.
Then you update whatever the B class had in memory.
Then you write out the contents of the B class.

It would probably be obvious if the check-out/check-in process displayed the name of book and the number of copies you thought it had.

Unless you're running with a debugger (and you'd probably not be asking the same questions if you were) add more printing (at least for debugging, you can comment it out later if you don't want it in the final version). Knowing what your program is doing and understanding why it is doing what it is are the keys to making it all work.

Here's a personal style comment, feel free to ignore it:
Which is easier to read?

cout<<"\n1.Add new book.\n2.Issue/return book.\n3.Edit book info.\n4.Show book info.\n5.Add new user.\n6.Update user info.\n7.View user info.\n8.Delete data base .\n9.Aboout\n10.quit.\nEnter your choice: ";

or (this works because the compiler merges adjacent strings)

cout<<"\n"
          "1.Add new book.\n"
          "2.Issue/return book.\n"
          "3.Edit book info.\n"
          "4.Show book info.\n"
          "5.Add …
Murtan 317 Practically a Master Poster

I don't see anything obvious about the login...maybe you could describe the problem you're having better?

As not all of the code required to validate the login is shown, I'm presuming that all of the variable declarations are ok and that the user input for the login and password don't have problems.

I'm not sure why you have the while loop that starts on line 5 in your first code fragment. You never loop as the if statement either causes the while to break (in the true clause) or return (in the else clause).

I didn't really look at the second code fragment, but I did look at the listed contents for BankData.txt and it appeared to be ok.

Murtan 317 Practically a Master Poster

There may be design issues here...

The base class can declare any function it likes as pure virtual, but all of the child classes must implement it using the same concrete argument list.

If your generic list contained instances derived from the base class, how would someone using the list have any idea about which kind of object it was? (I thought the idea was to make it so users of the list could treat them all the same.)

If you need different behavior (function calls) then you need different types and the caller needs to know what kind it is. (You're back to looking at the type of each item and handling it appropriately.)

Murtan 317 Practically a Master Poster

So your array class is intended to transparently represent the result of possibly many allocations as a single array. Due to the HUGE size of the array, it is absolutely CRITICAL that the allocation take as little time as possible.

Also, if your 'example' allocation which wants to allocate 198,145,029,864,623,361,045,926,400 array entries is even vaguely accurate, you have a much larger problem. Even if the allocation were only for 1 byte each it would take 198,145,029 terabytes (if I did the math right). I don't think you'll find that much memory (or even disk space) in any computer I've ever heard of.

If your example was 'over eager' and I were in your situation right now, I'd be looking at malloc (if it's available to you and the array will contain a 'standard' C type) but it would be a significant change from your current structure.

If your array won't fit in memory, you could end up virtualizing it to disk...but if you think calling constructors on memory was slow, disk access will not be a pleasant surprise.

I've asked questions several time attempting to get some real scope on the problem. I'm not putting any more of MY time into this unless you can show me hard data that its worth more than I've already invested. As I stated before, speed is always important, but if you're not careful, you'll spend more man-hours on speed improvements than you would ever save.

Questions I've asked …

Murtan 317 Practically a Master Poster

I don't see much point in allocating all available memory unless you're trying to stress-test another application, and if you're stress testing, I'm not sure what the hurry is.

I'm pretty sure you can override new to create custom allocators, but because this is a template, we don't know what we're allocating.

The language requires that the constructor be called for all of the array elements (I'm pretty sure this is why the new for the array is slower).

You might try using malloc to allocate the memory, you can allocate largish chunks and even if the memory is initialized to zero, it won't be calling multiple constructors.

I don't think your line 19 will compile, the xarray constructor I can see will accept either 0 or 1 argument. Your call is providing 2.

Add some debug:
* how long does it take to perform the first allocation?
* how big was the first allocation?
* how long does it take to perform the last allocation?
* how big was the last allocation?
* how long did it take overall for all of the allocations?

As I don't see that you're actually planning to use the data at all, why did you bother making a template with built-in recursive allocation, why not just a function to repeatedly allocate memory??

Murtan 317 Practically a Master Poster

If the data is large enough, I suppose it can take a while, but I've done some fairly large data sets and never really felt the need to 'speed up' allocation.

How much data are you allocating?

Have you measured how long it takes, if so how long does it take?

How often do you make this allocation?

(Speed is always important, but if you're not careful, you'll spend more man-hours on speed improvements than you would ever save.)

Murtan 317 Practically a Master Poster

The data would only be somewhat harder to access in a SQL database than in an access database if you can get access to the file.

That's one of the benefits of a true SQL Server, your application talks to the SQL Sever application and you don't have to have access to the data file. The computer with the data file could be physically secured and wouldn't have to share the file for others.

If you can't secure the file, (and maybe even if you can,) you're going to have to secure the data, probably using a form of encryption. If this is the route you take, you will have to put extra effort into securing the encryption (decryption) keys. (I don't recall if SQL Server has any direct support for ecrypted fields.)

Secondarily, the data you want to secure would appear to be readily available to the user at the terminal. Should the data be secured there as well? Is the data your trying to secure being printed on any forms? (Say insurance claims or something?)

I think some of the data you have may be protected by HIPAA and I'm not familiar with the standards. If you're writing the program, you should probably be familiar with the requirements and make sure that you're supporting them as well.

Murtan 317 Practically a Master Poster

You need to associate a method with the button's "on click" event.

The code in the method will need to generate the textbox.

If you want more detailed help you're going to need to tell us more about your code environment, and preferably show us some code to show that you're trying to solve the problem.

Murtan 317 Practically a Master Poster

.mdf is just a file extension, in a database context, it is usually associated with SQL Server. The file doesn't have any intrinsic support for anything. It's the database libraries that handle the file.

You stated that Access has 'lousy security' which I won't argue, but what level of security do you really need?

The level of security relates to how critical the information is and what you need to protect it from. Do you need to secure the data against reading? Against modification? Something else?

What is the impact (cost?) if the data is not secured?

What value is there to a third party to access the data?

The greater the impact (and/or the greater the value) the more that you will need to do to secure the data. If the impact and value are low, then you don't have to try very hard.

Murtan 317 Practically a Master Poster

You need to associate a method with the button's "on click" event.

The code in the method will need to generate the textbox.

(Did you mean a message box?)

If you want more detailed help you're going to need to tell us more about your code environment, and preferably show us some code to show that you're trying to solve the problem.

Murtan 317 Practically a Master Poster

Why don't you want the memory set to zero?

Are you trying to extract some 'previous' value from the memory?

Murtan 317 Practically a Master Poster

It would be possible to share the file across a network. However whether or not multiple people can use your application to access it at one time would depend on the file locking performed either by your code, or the library you use.

If your application or library supports file locking, it can either support whole-file locking or locking for part of the file. How your application / library handle the failures (due to someone else having a lock) would determine what if any error messages the user might see.

Murtan 317 Practically a Master Poster

if you're using code tags, you can leave the spaces where they are in the code. (don't add the periods)

The intent of code tags is to provide syntax highlighting, line numbers and to preserve white-space.

The 'code' you have posted (when I replace the '.'s with ' 's) won't even start to run...it has an indentation error (you seem to like them).


If you want help with your original progam's speed, why don't you post what you're trying to run (in code tags) and we can look at it.

If you have a new question on a new topic, you should start a new thread.

Murtan 317 Practically a Master Poster

If you're wanting to support multiple users across a network, you're probably going to want more of a real database, whether your users have to install it manually or not.

Murtan 317 Practically a Master Poster

If you haven't gotten the hint yet...indentation (leading white-space) is CRITICAL to python programs.

In the case of the import os line...it should be all the way to the left...there should be no white-space characters in front of it.

Just like it was in the code I posted.

If you think you already have it to the left, paste ALL of your code here...(inside code tags)

[code=python] # Your code here

[/code]

Murtan 317 Practically a Master Poster

The compiler requires that the 'interface' function1() declared in the base class have a concrete argument list.

What kind of abstraction do you think it needs?

Could that abstraction be implemented with another base class?

If the function call is abstract, how will the caller know what to pass the abstraction?

Murtan 317 Practically a Master Poster

The reason you lose the first character of the title is because the first loop is different from the second and third loop. Look at the difference yourself and see if you can figure it out. You're actually losing all but the last character of the title, but in this case keeping the last means only the first is missing.

If you ever attempted to add spaces, I haven't seen it in your code. Show us where and how you tried to add spaces and it failed.

You don't need to pass the string lengths into concat, if it needs them it can calculate them just like you did. If you use an algorithm that looks for the character that marks the end of the string, it may not need need to know how many characters are in the string anyway.

Murtan 317 Practically a Master Poster

I took your code and touched it up a bit...

import os

# put this part back if you're really attached to changing directories
#while True:
    #targetfolder = raw_input('Enter target folder to search:\n')
    #if isdir (targetfolder):
        #os.chdir(targetfolder)
        #break
    
targetfile = raw_input('Enter file to search:\n')
infile = open(targetfile)

searchword = raw_input('Enter string to search for::\n')

found = False
for line in infile:
    if searchword in line:
        print line
        found = True

if not found:
    print "Searchword %s not found in file %s" % (searchword, targetfile)
Murtan 317 Practically a Master Poster

What about posting the code in code tags so we can see the indents and have a chance at being able to help?

Murtan 317 Practically a Master Poster

Templates require the users to see all of the member functions. You can't have the methods 'hidden' in a c++ file.

If the code creating the instance of the template doesn't "see" the method, the method does not get implemented.

This is due to the way templates are implemented. They are not implemented as generic methods that work for any type, they are implemented as specific methods for the types identified.

If you had a tree with two different argument types (say IntBinaryTree<foo> and IntBinaryTree<goo>) there must be an insert node defined for each...(IntBinaryTree<foo>::insertNode() and IntBinaryTree<goo>::insertNode()) they will not find or use a 'generic' insertNode().

(It is possible to have the template derive from an actual base class if there are methods that can actually operate without the type, and the implementation for the base class methods would be 'hidden' in a cpp file and linked to the code.

Murtan 317 Practically a Master Poster

My original thought was that you would track the current editor as a frmEditor in your code. Upon further thought and contemplation (see reading the manual) I have revised my opinion.

We can use this.ActiveMdiChild but it is of type Form and not the class we want (frmEditor). We need to 'cast' it to our type so we can call our method (as our method is not defined in the Form class).

We can use the c# 'as' to make the conversion for us, without throwing an exception if the cast fails. (If the cast fails, as returns null.)

frmEditor currentEditor = this.ActiveMdiChild as frmEditor;
if (currentEditor != null)
    currentEditor.method(arguments);
Murtan 317 Practically a Master Poster

When posting python code, please use python code tags

You have to post your code with code tags so we can see the indents.

And as this is your second thread on the same topic and you didn't answer my question in the first...is searching a single file what the assignment was supposed to do?

Murtan 317 Practically a Master Poster

You're losing the first character of the full name inside the first for loop (of concat()). The second and third loops add each character to what was in fullname, but the first loop assigns each character to fullname. The second character in title overwrites the first. (If the title were more characters long, you would be missing more.)

As to the spaces that are missing, where did you put them in?

Maybe you should just add a space to fullname between the first and second loops and again between the second and third?

Murtan 317 Practically a Master Poster

So you just want to output the percentage calculation for heads and tails?

Wouldn't you just divide the number collected by the total sample size?

Murtan 317 Practically a Master Poster

I don't think I understand the second example...

input: i have 2 bananas and 3 oranges
print: 1+2+3= 6

Where'd the 1 come from?

Code comments:

line 6:

data = input("Please enter a string\n")

Should use raw_input to get string data.

You appear to be dividing the characters up based on whether or not they are digits, seems like a sound idea. Where are you building the multi-digit numbers?

Where are you building the sum of the numbers you've found?

You can iterate all of the characters in a string and only output the digits with something like:

digits = "0123456789"
for x in data:
    if x in digits:
        print x

I don't know if that make your problem any easier, but I find it easier to read and understand.

Murtan 317 Practically a Master Poster

That makes sense I suppose, but if it is a MDI container, and there is an active child window, when the user clicks the menu on the main form, does that make the child window lose focus? If it loses focus would using this.ActiveMdiChild work?

Also...I'm a little lost about why you would call a function in that way, it seems like you are doing it backwards... like...

frmEditor is the location of the method I want to run, so in order to run a method there I need to call the method by making a new object and then assigning that object a value that is never used anywhere? That's what it looks like you are doing. frmEditor currentEditor = this.activeEditor. so what is currentEditor and activeEditor? other than within the if statement where you reference currentEditor.method(), why would you bother doing frmEditor currentEditor = this.activeEditor. ...couldn't you just say frmEditor.method()...it seems to me that it would be the same? Maybe I'm thinking of it wrong?

Clicking on the menu or toolbar in an MDI parent does not change the MDIChild focus. (Note that it is tracking an MDI focus, the menu or tool bar might have the event focus, but the MDI child focus was not changed.)

You have to have an instance to call a method. If you have 3 editors open, which one would you mean if you say frmEditor.method() ?

The frmEditor currentEditor = this.activeEditor; makes a copy of a reference that the …

Murtan 317 Practically a Master Poster

Wow, deja vu, but better problem description.

The last word won't be followed by a space...

add another if (counter > longest_word) outside the for loop to handle the last word.

or alternatively...you could just add a space to the end of the string to make sure that there is one.

Murtan 317 Practically a Master Poster

as far as I can tell, you're only "drawing" the sides of the square, you didn't do the top or bottom yet...

In the sides code, the internal loop (for the spaces) is destructively decrementing your limit. (I'm referring to the s-- that limits your loop.) You should either reset s (to sides - 2) just before the loop starts every time, or use another variable to count up to s instead of destroying it.

As an alternative, you could build a string up to be the "* *" with as many spaces as you require and then just output the string the appropriate number of times.

Murtan 317 Practically a Master Poster

I'm presuming that x is the number of array entries you filled. A more descriptive name would be more appropriate.

line 15 in your code would be executed for every pass of the loop.

If the first one doesn't match, then line 15 assumes you can't find it and terminates the loop.

You need to move the line 15 test outside the for loop and remove the break.

You will also need to set look to false before the for loop starts.

Murtan 317 Practically a Master Poster

You generally call methods on an object instance. (This is why I was talking about 'keeping' a reference to the child windows you created and 'knowing' which child was the current one.) You would ask the current form to save.

// If you setup using a framework and setup your main window to support MDI
// you might be able to use this.ActiveMdiChild
// but it will be of type Form and not frmEditor
frmEditor currentEditor = this.activeEditor.
if (currentEditor != null)
    currentEditor.Method(arguments)
Murtan 317 Practically a Master Poster

For a multiple form interface, you will need to keep a list of all of the open forms and keep the list current when forms are closed or opened. You will also need a method to reference the 'current form', the one the user is currently interacting with.

When the user clicks save, you should save the data from the current form. (You might consider adding a 'save all' button that would iterate all of the forms saving each of them.) It also might be beneficial to have a 'dirty' flag that would let you know if the form had any changes to save. You could set the dirty flag any time a change is made to the text field.

Based on your described implementation, I think I would be tempted put the serialization in the child form. The main form would only call a method to tell the child it was time to save and the child would take care of getting it done.

Murtan 317 Practically a Master Poster

This code will not compile because I am trying to assign a myTemplateClass <int> pointer or myTemplateClass <char> pointer to myTemplateClass pointer.


Can we declare a pointer array that can hold myTemplateClass pointer of any type?

Using void pointer will not help much, since it needs a lot of type casting that may introduce bugs. Also it calls for type tracking of each object, which is nasty.

The only way I can think of to be able to store untyped or generic pointer to either template instance would be to have the template class inherit from a base class the defines all of the operations that you might need to perform on the instances of the template. You could then declare your array to be an array of pointers to the base class and any template instance would satisfy the pointer.

Another approach I can think of is to declare two arrays of pointers, one to myTemplateClass<int> and one to myTemplateClass<char> , both of size 10. If you pre-initialized both arrays to NULL values, you could look at either one first, if the value is NULL, the data item is of the other type.

A third approach might be to have a structure that contains the data type and a union of pointers to the possible implementations. You could then have an array of those.

Both of the last two cases require you to keep re-evaluating the type and handling the pointers in a type-safe …

Murtan 317 Practically a Master Poster

Either the record doesn't exist (the dfSicilNo.Text does not exist) or if the record does exist, the field is null.

You should be able to ask the query how many rows (records) it returned (if it is zero, then the record wasn't found).

If there was a row returned, you can use the IsDBNull test from your previous post to make sure that there is data before you try to extract it.

Murtan 317 Practically a Master Poster

I've never actually done it for a website, so you may want to take this with a grain of salt.

The concept is that as a user is added to the 'database' of users, you generate a random 'validation value' that is also stored with the user. You then generate an SMTP messsage (assuming your web host will let you) which sends the user's registered email address a message which identifies the user that is registering and includes a link to another page on your website. The link includes at least 2 pieces of information, one should be enough to 'find' the user in the database again, the second is the previously randomly generated validation value.

The web page that you link to will look at the parameter data, find the user record and confirm that the validation string matches. If it does, someone who can read messages sent to that email address agreed that the registration was valid, so you mark the record as having a valid email address.

Is that what you were looking for or did you want something more specific?

Murtan 317 Practically a Master Poster

I didn't download or open your project (FYI)

I believe that your compiler error on line 18 is related to you attempting to set a member variable in a class scope, and because the thing you are setting it to (if it even resolves) is a property of an object instance that you reference through the class name.

I believe there are a couple of 'normal' ways to access data that will be updated in child forms. One way would be to pass a communication structure (that the parent owns or also references) for the child form to update (as appropriate -- usually when the user clicks OK). A second way would be for the parent form to keep the reference to the child form (from when it creates the child form) and use that reference to access the child forms data.

In your project example, I would probably have the parent form keep a reference to the open editor frame.

NOTE: You don't want to make the private string serializeme and initialize it from the child frame. It would only get the initial value. You need to ask the editor frame for the current contents when the save strip tool menu item is selected. When the open strip tool menu item is selected, you need to make the editor frame (if it does not already exist) and then tell it to update its contents from what you read. The current implementation where it sets the …

Murtan 317 Practically a Master Poster

I would also have leaned toward re-shuffling for each set of random words. Just as long as you don't re-read the words from the file, you've saved most of the work.

You could also use choice() instead of shuffling, but you'd have to protect against selecting the same word more than once in a set.