We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2016-09-01 01:12 PM
2016-09-01 01:13 PM
2016-09-01 01:14 PM
2016-09-01 01:15 PM
2016-09-05 01:51 PM
IF DATA = "KEYNOTEDB" THEN TEXT2 0,J, DATA[i+2]is not working
n=0 DIM DATA[], xxx[] nnn = REQUEST ("ASSOCEL_PROPERTIES", "dbsetname,iscomp,keycode,keyname,code,name,fullname,quantity,totquantity,unitname,unitformatstr,propobjname", n, DATA) if n = 0 then TEXT2 0, 0, "No properties" ELSE j = 0 for i=1 to n !!!! xxx = strlen (data) !string functions or string expressions do not work IF i/intype = 1 or (i-intype)/12 = int((i-intype)/12) THEN TEXT2 0, -j, DATA !!!! text2 -1,-j, xxx !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! j=j+1 ENDIF NEXT i ENDIF
!lock "xxx" !!!!!!!!!!!!! tryied to pass data from DATA[] to other !values "xxx" xxx !!!! !! parameters or variables---doesn't work---- values "_intype" "dbsetname" ,"iscomp" ,"keycode" ,"keyname" ,"code" ,"name" ,"fullname" ,"quantity" ,"totquantity" ,"unitname" ,"unitformatstr" ,"propobjname" IF _intype = "dbsetname" then values "intype" 1 IF _intype = "iscomp" then values "intype" 2 IF _intype = "keycode" then values "intype" 3 IF _intype = "keyname" then values "intype" 4 IF _intype = "code" then values "intype" 5 IF _intype = "name" then values "intype" 6 IF _intype = "fullname" then values "intype" 7 IF _intype = "quantity" then values "intype" 8 IF _intype = "totquantity" then values "intype" 9 IF _intype = "uniname" then values "intype" 10 IF _intype = "unitformatstr" then values "intype" 11 IF _intype = "propobjname" then values "intype" 12
2016-09-05 05:57 PM
ispyridis wrote:Hi.
Generally filtering within the array can be made only by index.
I tried many combinations of string functions and expressions and nothing works you cannot make string comparisons or filter info by string contents.
for example
IF DATA = "KEYNOTEDB" THEN TEXT2 0,J, DATA[i+2]is not working
if I want to get the keycodes of the descriptors that come from keynotedb
I could filter iscomp for descriptors 0 or 1 then the database "keynotedb" and ask for KEYCODE but this seems not be possible
I also noticed that descriptor info is read first then it reads the components
they are stored linearly in the 1D array in a series of packets of requested values in the order that was requestd by the REQUEST command
IF DATA = "KEYNOTEDB" THENbut you have to make sure that you are comparing the same thing (contents of the array vs checked value): a requested array could be of mixed value types and you could be comparing a numeric value vs a string, and in this case it is better if all
DATA[i+2]but you just stated that the value in
DIM iselection[], stSelection[] iselection[1]=1 :stSelection[1]="dbsetname" iselection[2]=2 :stSelection[2]="iscomp" iselection[3]=3 :stSelection[3]="keycode" iselection[4]=4 :stSelection[4]="keyname" iselection[5]=5 :stSelection[5]="code" iselection[6]=6 :stSelection[6]="name" iselection[7]=7 :stSelection[7]="fullname" iselection[8]=8 :stSelection[8]="quantity" iselection[9]=9 :stSelection[9]="totquantity" iselection[10]=10 :stSelection[10]="uniname" iselection[11]=11 :stSelection[11]="unitformatstr" iselection[12]=12 :stSelection[12]="propobjname" values{2} "intype" iselection,stSelection !!!OPTIONAL VALUE ASSIGNMENT !!!values{2} "intype",\ !!!1,"dbsetName",\ !!!2,"iscomp",\ !!!3,"keycode",\ !!!4,"keyname",\ !!!5,"code",\ !!!6,"name",\ !!!7,"fullname",\ !!!8,"quantity",\ !!!9,"totquantity",\ !!!10,"uniname",\ !!!11,"unitformatstr",\ !!!12,"propobjname"You'll notice that your integer parameter gives text descriptions instead of the numeric value. The first way (with two arrays) is the better option as it would allow you to iterate between all array values in a loop, or call anything based on the selection, you just have to manage two arrays. The second, more static option will let you have index and value in the same sentence but wouldn't give you looping options. Works great when giving simple options to the user to select from.
IF intype=5 !!!you know that 5=code
IF intype=iselection[5] !!!but this is exactly the same as just using "5"Be careful to NOT use
IF intype="code" !!!intype is an integer parameter!
IF intype=stSelection[5] !!!intype is an integer parameter!I would place both arrays (integer and descriptors) in master script though, and just leave values{2} in parameter script.
2016-09-05 07:09 PM
It is quite easy to loose track of this, for example, after your comparison you put
Code:
DATA[i+2]
but you just stated that the value inwas as string for comparison, so "i+2" wouldn't work.
2016-09-05 08:41 PM
ispyridis wrote:
Hi SinceV6,
in your answer you state:It is quite easy to loose track of this, for example, after your comparison you put
Code:
DATA[i+2]
but you just stated that the value inwas as string for comparison, so "i+2" wouldn't work.
__i__ is an index counter and is integer
the data we don't know but what we do know is the sequence.
what I'm trying to do is point out the second record after the record "keynotedb"
Another thing is that string arrays can be compared string by string. Frank Beister in a GDLTips.zip has an example for sorting alphabetically the contents of an array.
The problem is when you request the data array. For some reason they are not stored as simple characters I think, so the data cannot pass on other variables or parameters.
just try to store the results in another array and then text2 that array. you will not get satisfactory results
IF DATA = "KEYNOTEDB" THENBut if "i+2" is not working, then something else is happening. You might not have anything there, not have that exact value "KEYNOTEDB" (so IF is FALSE) or even be running out of values by asking for [i+2] in a loop.
2016-09-06 11:31 PM
2016-09-07 02:00 AM
DIM texts[][] FOR i=1 TO n texts[1] = DATA IF VARTYPE(DATA)=1 THEN texts[2]="number" ELSE texts[2]="string" NEXT i FOR i=1 TO n text2 4,0,texts[1] text2 12,0,texts[2] ADD2 0,-1 IF i MOD 12 = 0 THEN LINE2 0,0,15,0 NEXT i DEL nIn the current example, I think you could simplify things a lot. I didn't really dig that much in the code to understand what you are trying to do, but I don't think you need to separate everything into different arrays (don't take my word on it though).