LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

truth or dare- gaming code

Solved!
Go to solution

how can we create a database or questions { a place where some set of pre-defined data is kept } and also to retrieve information randomly and display n the front panel?? 

Anyone please help me out in creating a pre-defined database and retrieving that information randomly 

0 Kudos
Message 1 of 10
(4,095 Views)

You already started down the simple route: use a simple text file.  Each line in the text file should be a new question.  If you right-click on the Read From Text File, you will see an option to "Read Lines".  Enable that and set your number to read to -1 (read all lines).  You will now have an array of questions.

 

Now you just have to figure out the randomization.  There are plenty of examples on that, but see how far you can get and let us know where you are stuck.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 10
(4,060 Views)

though.. i select read all lines also , the obtained result form the text file to labview is in different language i.e i mean the result is showing in different format not as it is given in the text file also how to obtain randomly those queries from the text file ?? help me out how to randomise if possible provide some info abbout randomisation methods ??

0 Kudos
Message 3 of 10
(4,027 Views)

Hi ivan,

 

the obtained result form the text file to labview is in different language i.e i mean the result is showing in different format not as it is given in the text file

Does LabVIEW translate the text from one language to another language? I don't believe this… 😄

Does you text contain any Unicode characters? LabVIEW isn't good at handling such char encodings and reads your text as plain ASCII by default!

(Maybe you should provide your VI and an example text file to help us solve your problem…)

 

help me out how to randomise

There is a random() function in the numerics palette…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 10
(4,024 Views)

different language means .. there is a different format showing in string (result) indicator 

0 Kudos
Message 5 of 10
(4,021 Views)

Hi Ivan,

 

unfortunately I can only open VIs for upto LV2014 right now, so you need to down-convert your VI and attach it again (file menu -> save for previous)…

And please also attach your text file!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 10
(4,019 Views)

here i selected some random question in the text file .. also with previous version vi 

Download All
0 Kudos
Message 7 of 10
(4,015 Views)
Solution
Accepted by topic author ivanjoel

Try saving in a text format, instead of a Word format. For example, "t_and_d.txt" with the same data will be much easier to parse.


GCentral
0 Kudos
Message 8 of 10
(4,002 Views)

Greetings ! 

i would like to select a random line from the given text file without taking the empty spaces .i.e it is taking empty spaces also though i specified read lines in read from text file icon .

Is there any option to make like 'it should only take the lines upto which i specified but not going beyond which results in empty spaces in the display.

0 Kudos
Message 9 of 10
(3,951 Views)

I have a VI that specifically goes through the array of strings and removes the empty strings.  This is what I recommend you do.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 10
(3,947 Views)