View Full Version : manipulate string
stickck
12-27-2005, 11:17 PM
how can i search a string and return the value between 2 values?
example:question_list [1] = "What's between 4 and 6?\n\nA - 1.\n\nB - 3.\n\nC - 5.\n\nD - 7."; I want to populate an input box with the value between \n\nC - and \n\nD. How can i do that? what i'm doing is using 5 input boxes, 1 to show the question and 4 to show the answers and letting the user edit test files. i was using excel for this but i wanted to make it easier. i didnt want the user to have to deal with the Scripting code, only the questions and answers.
any suggestions?
chris
Is there a reason you are trying to do it all in one string? Why not use the table to seperate it for you.
question_list = {};
question_list[1].Question = "What's between 4 and 6?";
question_list[1].AnswerA = "A - 1."
question_list[1].AnswerB = "A - 3."
question_list[1].AnswerC = "A - 5."
question_list[1].AnswerD = "A - 7."
question_list[1].Correct = "C"
stickck
12-28-2005, 04:08 PM
i originally used some of the code from the sample quiz in ams5. i put a sample here on the forum a few weeks ago for someone else that very similar to what you just posted but i was hoping not to have to change the test formats. i'm going to anyways just to save myself time and Advil.
thanks Worm :cool
chris
stickck
12-28-2005, 06:12 PM
Is there a reason you are trying to do it all in one string? Why not use the table to seperate it for you.
question_list = {};
question_list[1].Question = "What's between 4 and 6?";
question_list[1].AnswerA = "1."
question_list[1].AnswerB = "3."
question_list[1].AnswerC = "5."
question_list[1].AnswerD = "7."
question_list[1].Correct = "C"
hey Worm, if i wanted to have a True or False question in this test, could i just add this to each question to tell the program to hide the unused buttons?
question_list[1].TorF = "0" -- 0 is for multiple choice
question_list[1].Question = "What's between 4 and 6?";
question_list[1].AnswerA = "A - 1."
question_list[1].AnswerB = "A - 3."
question_list[1].AnswerC = "A - 5."
question_list[1].AnswerD = "A - 7."
question_list[1].Correct = "C"
question_list[2].TorF = "1" -- 1 is for true or false
question_list[2].Question = "4 = 6?";
question_list[2].AnswerA = "True."
question_list[2].AnswerB = "False."
question_list[2].AnswerC = ""
question_list[2].AnswerD = ""
question_list[2].Correct = "B"
i would like to have mixed tests if i could. i'm already using the TorF function to set up the bottons for the entire test. i would like to be able to set the buttons for each question.
thanks for any suggestions
chris
stickck
12-28-2005, 07:42 PM
i figured it out. here is a sample of it. not much here. i just wanted to be able to hide objects (buttons) if the question was true or false so the user wouldnt click the unused buttons. now i'm going to have it change the text on the buttons to display T or F also.
thanks Worm! your code you posted helped alot.
chris
also, this sample is in AMS 5. i only have version 5 at work.
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.