News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

FORC / problem with spaces in string

Started by peter_asm, May 13, 2014, 11:46:07 AM

Previous topic - Next topic

peter_asm

I've tried to process a string using FORC but for whatever reason, it stops after encountering a space in the string.
Is there a way around this limitation? I've tried to use @SizeStr in combination with @CatStr but still having problems then to identify if quote is in the string.


STRING_MACRO macro s:req
  FORC c, s
    %ECHO c
  ENDM
ENDM

STRING_MACRO "this is the string"


When compiling this, console displays

"
t
h
i
s


What I'd like to have is an if statement to determine what character is in the string like: if (c ne '"')

qWord

In the FORC-line, s must be enclosed in angle brackets:
position = 1
FORC c, <s>
IFIDN <c>,<!">
%echo Position: @CatStr(%position)
ENDIF
position = position + 1
ENDM

If you want to check whether the parameter s holds any quote, simply use @InStr() or INSTR:

position INSTR <s>,<!">
IF position
% echo Position: @CatStr(%position)
ENDIF
; or 
IF @InStr(1,<s>,<!">) NE 0
% echo Position: @InStr(1,<s>,<!">)
ENDIF


EDIT: for more details, see MASM's Programmers Guide, Chapter 9.
MREAL macros - when you need floating point arithmetic while assembling!

peter_asm