|
Thanks Dave, I will look into that.
Thanks for the help !
My advice is free, and you may get what you paid for.
|
|
|
|
|
I think "SELECT CASE TRUE" would always select the same case. Did you want to switch on the name?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi,
In VB the switch works like this. In other words, "Select the first case which' outcome conforms to the main statement".
It appears that the codeproject editor dropped the stars from the pattern matching.
Regards,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Johan Hakkesteegt wrote: In VB the switch works like this. Never seen it before; nice to learn something new
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Im starting a new personal project and it is years since I have done any coding. I do understand C++ to a basic level, however Im looking for convenience here and not attempting to program the next OS of the future.
Anyway Im basically wanting to write a program that stores basic rehearsal scripts for a language class I am part of.
I want to be able to quickly create a script to practice various language techniques from.
The basic scripts will fall into categories.
The basic structure goes something like this (I want to be able to alter this if needs be, in fact I probably will want to alter this).
Script Type 1
Script Type 2 part a
Script Type 2 part b
Script Type 2 part c
Script Type 3
Script Type 4 part a
Script Type 4 part b
Script Type 4 part c
For example script Type 1 will be an introductionary statement
Type 2 will be information about me. And so forth. The idea being I can print off a sheet of conversation for someone to speak from. SO they dont need to think what they are saying just how to say it.
For each of these script types I will have a collection of different scripts of varying length.
Each type will have multiple lines in the structure of
ME:
YOU:
ME:
YOU:
....
Im sure you get the idea.
I want to be able to select which scripts I use for each of the Types and Parts from a growing collection.
Now here is where my issues arise.
Should I create a database or use some sort of text file parsing?
I am unsure how many Script types that I want (basic at the minute but this could grow).
If I use text file parsing, will it make sense to have a different (small) text file for each script and some sort of header at the top so it can be recognised?
Or should I do one big text file with Headers?
Or a text file for each script type?
As for printing this off, I am planning on having it outputted in HTML to a web browser so that the print out looks attractive.
My other thought is to maybe use a database, but I think this is possibly overkill for this.
I also want to create a script input screen so I can input new scripts to be stored, using whatever storage medium is the best.
Please advise. I have used text parsing in the past and I have used databases in the past. But for this project I am just wondering what would bee most effective.
By the way when I say language I mean foreign language.
Please advise.
|
|
|
|
|
I would suggest you to go with a database. While certainly possible, I would find a collection of text files where I have to parse headers a bit messy. And updates to the data and structure would be more convenient with SQL (with the exception of single-file updates where you otherwise could just use a text editor). If you would ever decide to introduce more relational data you would start running into trouble with single files.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Thank you for your response.
Final question should I store all the scripts in the database or just use the database to point to a file name.
This might sound a dumb question, but I have only used databases for storing specific information such as personal info and billing info?
|
|
|
|
|
I would store the scripts in the database. The only advantage I could see not doing this (and just storing the file name instead) would be the ease of editing a script by opening it with a text editor - so you wouldn't have to implement a functionality for that. But the drawback would be that you give up one of the database's benefits: data integrity.
If you probably want to offer your application to your class mates you might want to choose a single-file database system for ease of setup (SQLite would be my recommendation).
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Thanks, I am looking into SQLite now.
What I am planning on doing is having two tables.
One table as follows
Script_ID (PK, FK)
Script Name
Type
And the other
Line_ID (PK)
Script_ID (FK)
Line
Speaker (Me/You)
Then I can leave the formatting for when an HTML file is created.
Cheers for your help. Makes sense now on how I can make this work.
modified 21-Apr-15 14:03pm.
|
|
|
|
|
Your schema draft looks alright.
cyberphreak1981 wrote: Cheers for your help. You're welcome!
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
I'm using entity framework I'm trying to make a general function that works for an object for which the class is known only at runtime. I have an instruction that use an expression similar to this :
context.ChangeTracker.Entries(of Myobj1)
Of course that if I know the class name "MyObj1" the above expression is working correctly.
But at runtime , I only have an variable :
Dim tp as type which contain the class , and i need an expression like this :
context.ChangeTracker.Entries(of tp)
Thank you !
|
|
|
|
|
My bad. I misunderstood what you were doing.
In order for a Generic to work, the types used must be known at compile-time, not run-time.
I've never done what you're trying to do, nor seen it done specifically with EF before, but you may want to look into these[^] possibilities. You'd have to create a method that generates the entire ChangeTracker.Entities() call at runtime.
modified 21-Apr-15 8:42am.
|
|
|
|
|
I'm using vb.net , and I have this situation :
I have a button on the form( Mybutton1 ) .
I have also a sub that contains a for..next loop :
.....
for I=1 to nr1
{.... some instructions...}
if condition1 then Mybutton1.enable=true
Next
On every step of this For loop , the button became enabled when a condition is true .In this case I want that this loop to stop until the user press the Button. ( the button's click event , at the end has some instructions that makes the button disabled again )
Is there any way to do this behavior ?
Thank you !
|
|
|
|
|
You probably don't want a for loop.
|
|
|
|
|
I described my problem in my post.
So I need response for the case when I need a for loop.
|
|
|
|
|
Contrarywise; you described a case where you don't want a for loop.
|
|
|
|
|
I described a case when I already have a for loop.
And if in one step of this loop , the button became enabled , the loop should be stopped , and to go to to the next step the user should press the button.
If the condition is always false , the for loop should continue until the end without interruption.
This is my case.
Is there any solution for this case ?
Thank you !
( I'm not asking if there's another way to do , because you can't give an opinion since you don't know nothing about my program , except the little part that I have described here)
|
|
|
|
|
You should add a test in your loop to see if the button is enabled, so you can exit the loop if it is. There are other ways to do this, which is why PIEBALDconsult[^] made the comments that he did.
dilkonika wrote: you can't give an opinion since you don't know nothing about my program Comments like that do not endear you to people here. And given the number of questions you have posted recently, you really do not want to get a reputation as someone who does not accept well meaning advice.
|
|
|
|
|
I think you misunderstand what I mean with my words.
I mean that someone can't give an opinion that should I use or not an For..Next loop because he don't know all the logic of my program.
So why you want to comment the question instead of try to give a response. The question is very clear.
If there's no answer , respond "it's not possible.".
And about the reputation , I'm not interested , because I'm more interested about the answers of my questions.
|
|
|
|
|
dilkonika wrote: And about the reputation , I'm not interested , because I'm more interested about the answers of my questions.
If you won't listen the answers you're given, you gain a reputation where nobody will give them to you.
|
|
|
|
|
sorry , but could you tell me what is the response that should I accept ? Until now in the answers I read only words. I think that if someone doesn't know an idea about the response is better not to respond ( as is happen for some of my other recent questions where nobody has given a single response. )
|
|
|
|
|
dilkonika wrote: So why you want to comment the question instead of try to give a response. I gave you a response.
|
|
|
|
|
How about I restart PIEBALD's answer.
You CAN'T do this with a for loop.
A Windows Forms app is a state machine that reacts to inputs like mouse and keyboard events. You CAN'T stop a loop and wait for input as your UI code is busy in the middle of the loop and cannot process input events until the code goes back to an idle state, meaning it's not executing any of your code!
|
|
|
|
|
Ok , I'm ready to accept any other solution , but first let explain something :
In the form I have this button.
This button do some actions. and may be enable on several situations . so this button does not depend on the for..Next loop. so even the For..next loop will be never executed , the code inside the button may be executed on several occasions when the user press the button.
The for ..next loop is on another sub , that when is executed , sometimes can make the button enabled. On this cases , the loop should wait until the user press that button and after continue to next step.
What are your new solutions to resolve this case ?
Thank you !
|
|
|
|
|
I have no idea. Why? Because we don't know the business rules and logic of your application. Who's fault is that? Hint: Not ours.
Since we know nothing of what you're really trying to do with this, there's really nothing that we can tell you to make something like this work. The only answer we can give is why you're current design will NOT work.
Which we've done.
|
|
|
|