Page 1 of 1

bug found with square bracket

Posted: Mon Aug 29, 2022 10:43 pm
by xabierpayet
I found a bug, how i can solve this problem with the open square bracket?

code.

cc="(Kr) 4d8 5s1"
ces=ReplaceStr(cc,"(","\[")
ces=ReplaceStr(cc,")","\]")
DebugPrint(ces)

output.

(Kr] 4d8 5s1

Re: bug found with square bracket

Posted: Mon Aug 29, 2022 10:45 pm
by airsoftsoftwair
Huh, why are you escaping the square bracket? That shouldn't be done. Is that what you're looking for?

Code: Select all

cc="(Kr) 4d8 5s1"
ces=ReplaceStr(cc,"(","[")
ces=ReplaceStr(ces,")","]")
DebugPrint(ces)

Re: bug found with square bracket

Posted: Mon Aug 29, 2022 10:59 pm
by xabierpayet
hello andreas, if i don´t escape i have this error, the item is in a table
item to print ---->[Ar] 3d5 4s2

Error in line 684 (Taula.hws): Text format tag after square bracket not recognized!

Re: bug found with square bracket

Posted: Mon Aug 29, 2022 11:03 pm
by xabierpayet
i test with a table alone now and the result is the same, error

code:

ces={}
ces[0]="[Kr] 4d8 5s1"
DebugPrint(ces[0])
Print(ces[0])

debug:

Error in line 4 (Unnamed1): Text format tag after square bracket not recognized!

Re: bug found with square bracket

Posted: Tue Aug 30, 2022 5:45 am
by PEB
I can't test this right now, but I think the way I've done it before was to replace "[" with "[[" and replace "]" with '']]" (double brackets).

Re: bug found with square bracket

Posted: Tue Aug 30, 2022 6:51 pm
by xabierpayet
thanks for your repply Peb, this is working fine with your method!

code:

electroconfigsemantic="[Ar] 3d10 4s2 4p2"
ss=ReplaceStr(electroconfigsemantic,"[","[[")
ss=ReplaceStr(ss,"]","]]")

debugprint result ---> [[Ar]] 3d10 4s2 4p2

textout result ----->[Ar] 3d10 4s2 4p2

interesting

Re: bug found with square bracket

Posted: Tue Aug 30, 2022 9:04 pm
by airsoftsoftwair
xabierpayet wrote: Tue Aug 30, 2022 6:51 pm interesting
It's all documented here. Quote:
Please note that because of these format tags you have to use two square brackets if you want to have a square bracket in your text. If there is only one square bracket Hollywood will always expect a format tag.
So not a bug.

Re: bug found with square bracket

Posted: Wed Aug 31, 2022 1:40 am
by xabierpayet
correct, the problem is solved, thanks again.