bugs:
- ? next alphanumeric chars isn't highlighted
- .E is allowed in numbers
Weird code:
DEF ISALPHNUM(C$) DIM C0=C$=="_" DIM C1=C$>="0",C2=C$<="9" DIM C3=C$>="A",C4=C$<="Z" DIM C5=C$>="a",C6=C$<="z" RETURN C0||C1&&C2||C3&&C4||C5&&C6 END 'vs DEF ISALPHNUM(C$) RETURN C$=="_"||C$>="0"&&C$<="9"||C$>="A"&&C$<="Z"||C$>="a"&&C$<="z" END 'etcSB is very very good at optimizing comparison chains like this; here's a disassembly of the bytecode generated:
== param(0),"_" JF @RET >= param(0),"0" JNF @30 <= param(0),"9" JF @RET @30: >= param(0),"A" JNF @4C <= param(0),"Z" JF @RET @4C: >= param(0),"a" JNF @RET <= param(0),"z" @RET: MOVFLAG ->return ENDDEF(JF: jump if flag set (if comparison was true) JNF: jump if flag not set (if compare was false)) vs your function:
== param(0),"_" MOVFLAG ->local(0) >= param(0),"0" MOVFLAG ->local(1) <= param(0),"9" MOVFLAG ->local(2) >= param(0),"A" MOVFLAG ->local(1) <= param(0),"Z" MOVFLAG ->local(2) >= param(0),"a" MOVFLAG ->local(1) <= param(0),"z" MOVFLAG ->local(2) != local(0),0 JF @RET != local(1),0 JNF @7E != local(2),0 JF @RET @7E: != local(3),0 JNF @96 != local(4),0 JF @RET @96: != local(5),0 JNF @RET != local(6),0 @RET:MOVFLAG ->return ENDDEF