What's up with this? (Page 1) ● SmileBASIC Source Forums

Register
💀

# What's up with this?

• #1 ✎ 284 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Slot 0: ```OPTION STRICT EXEC 1 USE 1 A "FHFYFYF","FYYFUFH",3,6,8``` Slot 1: ```OPTION STRICT VAR _I% DIM A\$[0] DIM B\$[0] DIM A%[0] DIM B%[0] DIM C%[0] COMMON DEF A _A\$,_B\$,_A%,_B%,_C% FOR _I%=LEN(A\$)-1 TO 0 STEP -1 IF A\$[_I%]==_A\$ THEN _A\$=_A\$+"_" BREAK ENDIF NEXT PUSH A\$,_A\$ PUSH B\$,_B\$ PUSH A%,_A% PUSH B%,_B% PUSH C%,_C% END``` Results with a type mismatch in 1:12. Why? Posted
• #2 ✎ 74 kitesinpowerlines Avatar Block I didn't change my avatar for 30 days. Website Avatar Embargo I didn't change my avatar for 90 days Website Avatar Taboo I didn't change my avatar for 180 days Website Would it be because LEN(A\$) already equals 0? So when you `FOR _I%=LEN(A\$)-1 TO 0 STEP -1` LEN(A\$)-1 would be -1 and you are trying to increase it by -1 to get to 0 when you should increase by +1, unless I am misreading. EDIT: I think if the array was larger it might work. It's interesting to see the _I%=LEN rather than LEN being the condition to end the loop, so it is a little confusing to me. Posted Edited by kitesinpowerlines
• #3 ✎ 284 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Problem solved; USE 1 in slot 0 was not required and had to be removed.
Would it be because LEN(A\$) already equals 0? So when you `FOR _I%=LEN(A\$)-1 TO 0 STEP -1` LEN(A\$)-1 would be -1 and you are trying to increase it by -1 to get to 0 when you should increase by +1, unless I am misreading. EDIT: I think if the array was larger it might work. It's interesting to see the _I%=LEN rather than LEN being the condition to end the loop, so it is a little confusing to me.
Kinda. When the loops begins with a number that is "beyond" the target number it doesn't execute.
Posted Edited by spaceturtles
• #4 ✎ 74 kitesinpowerlines Avatar Block I didn't change my avatar for 30 days. Website Avatar Embargo I didn't change my avatar for 90 days Website Avatar Taboo I didn't change my avatar for 180 days Website
Problem solved; USE 1 in slot 0 was not required and had to be removed.
Would it be because LEN(A\$) already equals 0? So when you `FOR _I%=LEN(A\$)-1 TO 0 STEP -1` LEN(A\$)-1 would be -1 and you are trying to increase it by -1 to get to 0 when you should increase by +1, unless I am misreading. EDIT: I think if the array was larger it might work. It's interesting to see the _I%=LEN rather than LEN being the condition to end the loop, so it is a little confusing to me.
Kinda. When the loops begins with a number that is "beyond" the target number it doesn't execute.
Ah okay thanks. I didn't know it didn't execute, I thought it would've produced an error.
Posted
• #5 ✎ 1561 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Second Year My account is over 2 years old Website (anyway the problem was that he was calling the function before the arrays had been created) EDIT: (replace EXEC 1:USE 1 with just EXEC 1) Posted Edited by 12Me21