Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Let's see
Message
From
30/03/2021 16:30:28
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
30/03/2021 07:19:52
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
01679334
Message ID:
01679370
Views:
77
Likes (1)
>>
lcString="ABC,DEF,GHI,JKL"
>>lcString2=""
>>x=0
>>do while x<len(m.lcString)
>>  x=m.x+1
>>  IF SUBSTR(m.lcString,m.x,1)<>","
>>    lcString2=m.lcString2+substr(m.lcString,m.x,1)
>>  ENDIF
>>enddo X
>>?m.lcString2
>
>Why not just:
>
>
>lcString="ABC,DEF,GHI,JKL"
>lcString2 = STRTRAN(m.lcString, ',', '')
>?lcString2
>
>
>Tamar

What I was really trying to see is if programmers can resist providing a better way to write given code expecting not to be told off off for doing what is natural to us or having someone insist that this should go elsewhere. I am well able to decide where and what to post and I don't need any security guard telling me what to do and how to do it. That is a sure-fire way to reduce one's willingness to contribute. In fact, it's fun to offer alternatives and we should be free to do so. Why did you use strtran? :)

I actually had to struggle to write that CRAP. Learn better ways. Make them habits and never use the primitive ways unless there is no choice.

Main.prg
PUBLIC gcAllChars
gcAllChars=""
gcAllChars=GetAllChars(@m.gcAllChars)

GetAllChars.prg &&could have been a constant, but too much effort to retroactively implement
LPARAMETERS m.tcAllChars
LOCAL m.lnI
FOR m.lnI = 0 TO 255
m.tcAllChars = m.tcAllChars + CHR(m.lnI)
ENDFOR
RETURN m.tcAllChars

LOCAL lcBadChars
m.lcBadChars = CHRTRAN(m.gcAllChars, "0123456789", "") && everything except numbers are bad
if !empty(m.wLine) and m.wLine==CHRTRAN(m.wLine, m.lcBadChars, "")

Drew Speedie had this code in MaxFrame:
    LOCAL lcString, lcPName, yy
    FOR yy = 1 TO ALEN(taParms,1)
      lcString = "LOCAL " + m.taParms[m.yy,1]
      &lcString
      lcName = m.taParms[m.yy,1]
      STORE m.taParms[m.yy,2] TO &lcName    
    ENDFOR
I showed him this and he added the comments. He gladly took all good code. It was one of my proudest moments showing Drew something.
    LOCAL yy
    FOR yy = 1 TO ALEN(taParms,1)
      LOCAL (taParms[m.yy,1])                      &&& declare the variable in taParms[yy,1]
      STORE (taParms[m.yy,2]) TO (taParms[m.yy,1])   &&& store the variable whose name is in taParms[yy,1] with the value in taParms[yy,2]
    ENDFOR
Thanks
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform