PDA

View Full Version : Making program decisions based upon multiple criteria



marcuslee
09-12-2009, 02:21
I've run into a problem with my flash card program.

Each flash card is a bible verse. I am keeping the info in a random file. Besides the front and the back of each card, I am keeping track of what bible book the verse is from, whether or not it is a well known verse, and what format the card is in.

So, I have a UDT that looks something like this:


TYPE FlashCard
Front as ASCIIZ * 400
Back as ASCIIZ * 400
BibleBook as ASCIIZ * 15
Known as ASCIIZ * 17
Format as ASCIIZ * 16
END TYPE


I would like the user to be able to create a deck of cards based upon the above options. For example, the user might create a deck of 20 cards of well known verses in the fill in the blank format from the books of Genesis and Exodus.

I can cycle through the cards, adding or skipping cards based upon the user's criteria. But, since there will be so many options, simple IF statements or SELECT CASE statements seem like they wouldn't do the job. At least how I am picturing it.

The option for the Known & Format variables can be selected by CHECKBOXs, and the BibleBook can be in a multiselect listbox.

The verses are in order in the random file, so all of the Genesis verses are first. So, if I know which records are from the particular bible books, I can narrow down the field. So, the search won't take as long. I could then take the narrowed list and put them in an array.

I don't want anyone to write it for me. Am I on the right track, though? Am I missing anything? Is there something I haven't thought of? Is there an easier way of doing what I want?

I have ideas, but I am not sure how to put them all together. I could tinker for awhile, and I will continue to try things, but any assistance to point me in the right direction would be appreciated.


Mark :violent:

marcuslee
09-12-2009, 03:22
With a suggestion from my wife, I have come up with an idea that will work until I figure out how to do custom decks. The idea is simple: create pre-defined decks.

So, an array could hold the card numbers like this:


Dim A(10) As Word
A(1) = 1, 4, 50, 53, 87, 98, 102, 165, 176, 189


Then, the user could choose a deck from a list of hundreds of decks, each being held in memory with arrays. The only concern with this plan is having to fill up the computer memory with tons of arrays. I suppose array assignment could wait until after the user chooses which deck he wants to use. Would that work?

Also, I have another idea for custom decks. It is really easy to populate a listbox with the back side of the flash cards (which is where the verse locations are held - for example, the first card's back is Genesis 1:1). Once I have a listbox with all the verses listed, the user can easily pick all the verses he wants in his custom deck. Any other ideas?


Mark

Michael Hartlef
09-12-2009, 09:06
Hi Mark,

I am on my way to work now. So tonight i will reply more.

One thing i would like to know is the ui of your app. Can you create a mockup and descibe it?

marcuslee
09-12-2009, 18:34
One thing i would like to know is the ui of your app. Can you create a mockup and descibe it?


I hadn't gotten as far as creating the UI for this part of the app. I have a UI for the inputing of flash cards which is similar, and I have a simple UI for viewing the cards.

Here's a thrown together mockup of what the Deck Creation UI might look like:



Uses "UI"
'---Constant declarations
Begin Const
%ID_Button_03 = %IDOK
%ID_Listbox_01
%ID_Listbox_02
%ID_Listbox_03
%ID_TextBox_01
%ID_Label_01
End Const
'Arrays and Array Assignments
Dim Books(66) As String
Dim Difficulty(2) As String
Dim QuesType(3) As String
Array Assign QuesType(1) = "Standard", _
"Fill in the Blank", _
"Provide the Answer"
Array Assign Difficulty(1) = "Well Known", _
"Not Well Known"
Array Assign Books(1) = "Genesis", _
"Exodus", _
"Leviticus", _
"Numbers", _
"Deuteronomy", _
"Joshua", _
"Judges", _
"Ruth", _
"1 Samuel", _
"2 Samuel", _
"1 Kings", _
"2 Kings", _
"1 Chronicles", _
"2 Chronicles", _
"Ezra", _
"Nehemiah", _
"Ester", _
"Job", _
"Psalms", _
"Proverbs", _
"Ecclesiastes", _
"Song of Solomon", _
"Isaiah", _
"Jeremiah", _
"Lamentations", _
"Ezekiel", _
"Daniel", _
"Hosea", _
"Joel", _
"Amos", _
"Obadiah", _
"Jonah", _
"Micah", _
"Nahum", _
"Habakkuk", _
"Zephaniah", _
"Haggai", _
"Zechariah", _
"Malachi", _
"Matthew", _
"Mark", _
"Luke", _
"John", _
"Acts", _
"Romans", _
"1 Corinthians", _
"2 Corinthians", _
"Galations", _
"Ephesians", _
"Philippians", _
"Colossians", _
"1 Thessalonians", _
"2 Thessalonians", _
"1 Timothy", _
"2 Timothy", _
"Titus", _
"Philemon", _
"Hebrews", _
"James", _
"1 Peter", _
"2 Peter", _
"1 John", _
"2 John", _
"3 John", _
"Jude", _
"Revelation"

'Global Declarations
Dim hFont1 As DWord Resource = Font_Create("Arial Black", 12)
Dim hFont2 As DWord Resource = Font_Create("Arial Black", 16)
Dim LabelText As String = "Bible Verse Flash Cards"
Dim hDlg As DWord

'------------------------------------------------------------------------------
' Program start point
'------------------------------------------------------------------------------
Function TBMain() As Long
'---Create a new dialog
Dialog NEW PIXELS, 0, "Bible Flash Cards", -1, -1, 600, 400, _
%WS_DLGFRAME | _
%DS_CENTER | _
%WS_CAPTION | _
%WS_SYSMENU | _
%WS_OVERLAPPEDWINDOW, %WS_EX_STATICEDGE To hDlg
'---Set window minimum size
Dialog SET MINSIZE hDlg, 600, 400
Dialog SHOW MODAL hDlg, Call cbDialog
End Function

'------------------------------------------------------------------------------
' Callback procedure for main window
'------------------------------------------------------------------------------
CallBack Function cbDialog() As Long
Select Case CBMSG
Case %WM_INITDIALOG
'---Add controls
Control ADD BUTTON, CBHNDL, %ID_Button_03, "Create Deck", 225, 300, 150, 35, %BS_NOTIFY | %WS_TABSTOP
Control ADD LISTBOX, CBHNDL, %ID_Listbox_01,Books(), 100, 100, 110, 200, %WS_VSCROLL | %LBS_MULTIPLESEL
Control ADD LISTBOX, CBHNDL, %ID_Listbox_02,Difficulty(), 250, 100, 110, 50, %WS_VSCROLL
Control ADD LISTBOX, CBHNDL, %ID_Listbox_03,QuesType(), 400, 100, 110, 50, %WS_VSCROLL
Control ADD LABEL, CBHNDL, %ID_Label_01, LabelText, 0, 40, 600, 50 ,%SS_NOTIFY | %SS_CENTER
Control ADD TEXTBOX, CBHNDL, %ID_TextBox_01, "In a textbox the user could indicate how many cards they want.", _
250, 200, 150, 50, %ES_NUMBER | %ES_MULTILINE
'Set the font
Control SEND CBHNDL, %ID_Label_01, %WM_SETFONT, hFont2, 0
Control SEND CBHNDL, %ID_Button_03, %WM_SETFONT, hFont1, 0
End Select
End Function


Obviously, I would add some labels (text) telling the user what each of the boxes are for. But, you are a smart guy. I betcha you can figure it out! ;) Anywayz, the user chooses which bible books they want their verses to come from, whether or not the verses are commonly known, and what format the flash cards should be in. I suppose I should add the ability to choose all types of formats and difficutulties. For example, the last item in the KNOWN box could be BOTH TYPES, and the last item in the FORMAT box could be ALL TYPES. And, I should probably turn on the multiselect feature like I did with the bible books.

Now, what happens once the user clicks the CREATE DECK button ... that's where I am not sure what to do. That is if I go with the computer automatically creating the deck for them from their selections. Because I really like the idea of having predefined decks for them as well. It seems easy. However, if I can wrap my head around whatever we figure out here, I will probably have both kinds.


Thanks,
Mark

marcuslee
09-12-2009, 18:42
Then, the user could choose a deck from a list of hundreds of decks, each being held in memory with arrays. The only concern with this plan is having to fill up the computer memory with tons of arrays. I suppose array assignment could wait until after the user chooses which deck he wants to use. Would that work?


I got to thinking. I really only need one array for loading a deck if I wait to assign the values of the array after the user picks what deck they want to view. Because right now I can only see loading one deck at a time. I can use SELECT CASE to load the array with the deck they choose. I think that's better! :eusaclap:

Mark

Michael Hartlef
09-12-2009, 20:56
Ok, thanks for the mockup. Your output will be a dialog too where the user will be seeing his deck or will it be printed on paper/cardboard?

Your last idea about assigning the array later is very good. I think you should go that route. Do you store everything into one text file?

marcuslee
09-12-2009, 22:10
Ok, thanks for the mockup. Your output will be a dialog too where the user will be seeing his deck or will it be printed on paper/cardboard?


Everything will be on the computer. Nothing will be printed.



Your last idea about assigning the array later is very good. I think you should go that route. Do you store everything into one text file?


As you can see in the example I have attached, every card is stored in the text file: FlashCards.DAT. What I have attached is a stable copy of the Flash Card viewing program. There are no decks. The program simply brings up a random flash card everytime the user clicks next card. Right now there are 106 cards. In the future I could have thousands.


Mark