Capitalization Routine?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2006-01-13 05:27 PM
This is in the Parameter script. Any other suggestions are certainly welcome!
!!ROUTINE FOR CAPITALIZING THE ROOM NAME
IF GLOB_MODPAR_NAME = `pCapitalize` THEN
NameLen = STRLEN(ROOM_NAME)
NewName = ""
SubChar = ""
FOR Idx = 1 TO NameLen - 1
NameChar = STRSUB(ROOM_NAME, Idx, 1)
GOSUB 1000
IF SubChar = "" THEN
NewName = NewName + NameChar
ELSE
NewName = NewName + SubChar
ENDIF
NEXT Idx
pCapitalize = 0
PARAMETERS ROOM_NAME = NewName
PARAMETERS pCapitalize = pCapitalize, ROOM_NAME = ROOM_NAME
ENDIF
GOTO 2000:
1000:
IF NameChar = "a" THEN SubChar = "A"
IF NameChar = "b" THEN SubChar = "B"
IF NameChar = "c" THEN SubChar = "C"
IF NameChar = "d" THEN SubChar = "D"
IF NameChar = "e" THEN SubChar = "E"
IF NameChar = "f" THEN SubChar = "F"
IF NameChar = "g" THEN SubChar = "G"
IF NameChar = "h" THEN SubChar = "H"
IF NameChar = "i" THEN SubChar = "I"
IF NameChar = "j" THEN SubChar = "J"
IF NameChar = "k" THEN SubChar = "K"
IF NameChar = "l" THEN SubChar = "L"
IF NameChar = "m" THEN SubChar = "M"
IF NameChar = "n" THEN SubChar = "N"
IF NameChar = "o" THEN SubChar = "O"
IF NameChar = "p" THEN SubChar = "P"
IF NameChar = "q" THEN SubChar = "Q"
IF NameChar = "r" THEN SubChar = "R"
IF NameChar = "s" THEN SubChar = "S"
IF NameChar = "t" THEN SubChar = "T"
IF NameChar = "u" THEN SubChar = "U"
IF NameChar = "v" THEN SubChar = "V"
IF NameChar = "w" THEN SubChar = "W"
IF NameChar = "x" THEN SubChar = "X"
IF NameChar = "y" THEN pSubChar = "Y"
IF NameChar = "z" THEN pSubChar = "Z"
RETURN
2000:
!!END

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2006-01-13 05:52 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2006-01-13 06:01 PM
TomWaltz wrote:I start with ROOM_NAME being "Test Name", and after the routine runs, ROOM_NAME is still "Test Name" -- no change at all. It has clearly attempted something because the floor plan preview in the GDL editor blinks when I execute this routine.
How does it not work? What results do you get from it?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2006-01-13 09:33 PM
Jay wrote:Jay,
!!ROUTINE FOR CAPITALIZING THE ROOM NAME IF GLOB_MODPAR_NAME = `pCapitalize` THEN NameLen = STRLEN(ROOM_NAME) NewName = "" SubChar = "" FOR Idx = 1 TO NameLen - 1 NameChar = STRSUB(ROOM_NAME, Idx, 1) GOSUB 1000 IF SubChar = "" THEN NewName = NewName + NameChar ELSE NewName = NewName + SubChar ENDIF NEXT Idx ... ENDIF
One thing I see in a quick scan is that SubChar is set to "" outside of the loop, so after it ias assigned once in your 1000 Sub, it will never be "" again ... hence your IF will always be concatenating SubChar... so if you had "ab123c", your routine would produce "ABBBBC".
Rather than move the initialization into the loop, I don't see a need for that variable or the IF block ... just reassign NameChar in your 1000 Sub.
Tip for code on ac-talk ... there is a 'code' button in the format bar when you enter a message - keeps the indentation of the original.
Karl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2006-01-13 09:48 PM
Karl wrote:Oops. I originally had it set to "" at the beginning of the 1000 loop, but it still had the same result -- nothing.
One thing I see in a quick scan is that SubChar is set to "" outside of the loop, so after it ias assigned once in your 1000 Sub, it will never be "" again ... hence your IF will always be concatenating SubChar... so if you had "ab123c", your routine would produce "ABBBBC".
Karl wrote:Thanks! I never noticed that. A wish granted before I even posted it!
Tip for code on ac-talk ... there is a 'code' button in the format bar when you enter a message - keeps the indentation of the original.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2006-01-13 09:52 PM
IF GLOB_MODPAR_NAME = `pCapitalize` THEN NameLen = STRLEN(ROOM_NAME) NewName = "" FOR Idx = 1 TO NameLen - 1 NameChar = STRSUB(ROOM_NAME, Idx, 1) IF NameChar = "a" THEN NameChar = "A" IF NameChar = "b" THEN NameChar = "B" IF NameChar = "c" THEN NameChar = "C" <...> IF NameChar = "x" THEN NameChar = "X" IF NameChar = "y" THEN NameChar = "Y" IF NameChar = "z" THEN NameChar = "Z" NewName = NewName + NameChar NEXT Idx pCapitalize = 0 PARAMETERS ROOM_NAME = NewName PARAMETERS pCapitalize = pCapitalize, ROOM_NAME = ROOM_NAME ENDIFThis still doesn't work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2006-01-13 10:17 PM
OR, did you actually turn on pCapitalize in the Parameters window to trigger GLOB_MODPAR_NAME?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2006-01-14 12:59 AM
TomWaltz wrote:Right. pCapitalize is a Boolean parameter. Turning it on triggers the capitalization, at the end of the capitalization the programming switches pCapitalize back to 'off'.
OR, did you actually turn on pCapitalize in the Parameters window to trigger GLOB_MODPAR_NAME?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2006-01-16 08:37 AM
pCapitalize = 0 PARAMETERS ROOM_NAME = NewName PARAMETERS pCapitalize = pCapitalize, ROOM_NAME = ROOM_NAMEbut:
pCapitalize = 0 ROOM_NAME = NewName PARAMETERS pCapitalize = pCapitalize, ROOM_NAME = ROOM_NAMEHaven't proofed, but this should do it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2006-01-16 08:48 AM
1000: IF NameChar = "a" THEN SubChar = "A" IF NameChar = "b" THEN SubChar = "B" IF NameChar = "c" THEN SubChar = "C" ...is a bit raw.
Try this:
low=ROOM_NAME result="" downT=" abcdefghijklmnopqrstufwxyz" upT=" ABCDEFGHIJKLMNOPQRSTUVWXYZ" FOR i=1 TO STRLEN(low) subT=STRSUB(low,i,1) posT=STRSTR(downT,subT) IF posT THEN result=result+STRSUB(upT,posT,1) ELSE result=result+subT ENDIF NEXT i