Register

Lookup a value in a list

Discuss issues related to the Casio Basic Language
Junior Member
Posts: 8
Joined: Wed Dec 21, 2016 8:29 pm
Calculators: Casio Classpad fx-CP400

Lookup a value in a list

Postby 1q2w3e4rr » Thu Jan 05, 2017 3:53 pm

hi
i have made some list and my list has several rows and columns. i want to search in this list for a special value. and get the row number of where it sit in the list.

for example i input x
and i want to find x in the list1's first column, and find out which row it sit!
like lookup function in excel.

thank for helping me :)

Junior Member
Posts: 9
Joined: Sun Aug 21, 2016 10:33 am
Calculators: None

Re: Lookup a value in a list

Postby Zezombye » Thu Jan 05, 2017 7:11 pm

A simple for loop would be enough, I think.
Code: Select all
For 1->I To 999 //change to 255 if you have an older OS/calc
List 1[I]=X => Break
Next
//I is the row where the variable is

Junior Member
Posts: 8
Joined: Wed Dec 21, 2016 8:29 pm
Calculators: Casio Classpad fx-CP400

Re: Lookup a value in a list

Postby 1q2w3e4rr » Sat Jan 07, 2017 2:55 pm

thank u
the cod i used:


Code: Select all
input j

[[21.3×2,1.21,0.962,0.571,0.536,0.686],[21.3×2.6,1.53,1.21,0.681,0.639,0.668],[21.3×3.2,1.82,1.44,0.768,0.722,0.65]]⇒IP

for 1=>i  to rowdim(IP) ' represent the last row number '
if IP[i,1]=I :then
print IP[i,3]
print IP[i,4]
ifend
next

Return to Casio Basic Development

Who is online

Users browsing this forum: No registered users and 22 guests