Jump to content

How do I catch empty string with weidu?


Gort

Recommended Posts

Try

COPY_EXISTING SW1H01.ITM OVERRIDE
READ_ASCII 0x0 nil (0)
PATCH_IF !("%nil%" STRING_COMPARE_CASE "") BEGIN
 PATCH_PRINT "Empty string HUZZAH!!!"
END
BUT_ONLY_IF_IT_CHANGES

If that works, your "%string%" must not be a true zero-length string. If it doesn't work, shout at the_bigg on the WeiDU forums at PPG.

Link to comment

I generally use this to set up an array of all the ascii characters:

OUTER_PATCH ~this_is_not_a_variable~ BEGIN
 FOR ("i1" = 0x0; "i1" < 0x100; "i1" += 0x1) BEGIN
WRITE_BYTE 0x0 "i1"
READ_ASCII 0x0 ~c~ (0x1)
SPRINT EVALUATE_BUFFER ~0t%i1%~ ~%c%~
 END
END

 

Which will allow detecting of any whitespace characters, or nothing, with:

PATCH_IF !(~%string%~ STRING_MATCHES_REGEXP ~\(%0t0%\|%0t9%\|%0t10%\|%0t13%\|%0t32%\)*~) THEN BEGIN

 

You could also rob Cam's EXTRA_REGEXP_VARS lib for some of these.

Link to comment
Try
COPY_EXISTING SW1H01.ITM OVERRIDE
READ_ASCII 0x0 nil (0)
PATCH_IF !("%nil%" STRING_COMPARE_CASE "") BEGIN
 PATCH_PRINT "Empty string HUZZAH!!!"
END
BUT_ONLY_IF_IT_CHANGES

If that works, your "%string%" must not be a true zero-length string. If it doesn't work, shout at the_bigg on the WeiDU forums at PPG.

this works, therefore my string is not empty

 

I generally use this to set up an array of all the ascii characters:
OUTER_PATCH ~this_is_not_a_variable~ BEGIN
 FOR ("i1" = 0x0; "i1" < 0x100; "i1" += 0x1) BEGIN
WRITE_BYTE 0x0 "i1"
READ_ASCII 0x0 ~c~ (0x1)
SPRINT EVALUATE_BUFFER ~0t%i1%~ ~%c%~
 END
END

 

Which will allow detecting of any whitespace characters, or nothing, with:

PATCH_IF !(~%string%~ STRING_MATCHES_REGEXP ~\(%0t0%\|%0t9%\|%0t10%\|%0t13%\|%0t32%\)*~) THEN BEGIN

 

You could also rob Cam's EXTRA_REGEXP_VARS lib for some of these.

thanks, I'll try this

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...