forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


String evaluation - alphabetic/alphanumeric/numeric

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code
View previous topic :: View next topic  
Author Message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Fri Sep 20, 2002 8:06 am    Post subject: String evaluation - alphabetic/alphanumeric/numeric Reply with quote

Hmmm, am I spamming this forum? Wink

Well, at any rate, here is a tool for evaluating strings in alphabetic/alphanumeric/numeric mode:

The basic idea for this is Mac's. It has been enhanced to support extended chars in the normal Western European character set.

Code:

  option decimalsep,"."
  dialog CREATE,Find characters,-1,0,260,220
  dialog ADD,EDIT,EvalString,5,5,250,,1st Enter string!
  dialog ADD,RADIO,mode,35,5,140,,Select mode:,1. Alphabetic|2. Alphanumeric|3. Numeric,"1. Alphabetic",CLICK
  dialog ADD,CHECK,case,120,5,200,,case-sensitive
  dialog ADD,CHECK,extended,135,5,250,,"use extended character set (Western European)"
  dialog ADD,BUTTON,Go,180,40,140,,Go!
  dialog ADD,TEXT,Dread,205,180,140,,.. by Dr. Dread
  dialog SHOW

  %%mode = "alpha"
 
:Evloop
  wait event
  wait .2
  goto @event()

:modeCLICK
  %M = @substr(@dlgtext(mode),1,)
  if @equal(%M,1)
    %%mode = "alpha"
   dialog enable,case
   dialog enable,extended
  end
  if @equal(%M,2)
    %%mode = "alphanum"
   dialog disable,case
   dialog enable,extended
  end
  if @equal(%M,3)
    %%mode = "numeric"
   dialog disable,case
   dialog disable,extended
  end
  goto evloop

:GoBUTTON
  %i = @dlgtext(EvalString)
  if @null(%i)
    warn Enter string to be evaluated!
  end
  if @null(@dlgtext(case))
    %%casesense = "0"
  else
    %%casesense = "1"
  end 
  if @null(@dlgtext(extended))
    %%extended = "0"
  else
    %%extended = "1"
  end 

 
  if @equal(%%mode,alpha)
    if @equal(%%casesense,0)
        if @equal(%%extended,1)
          %%chars = "abcdefghijklmnopqrstuvwxyz                               íŸ€íµŸ"
         gosub alpha
      else
          %%chars = "abcdefghijklmnopqrstuvwxyz"
         gosub alpha
      end
   else
      if @equal(%%extended,1)
        %%LC = "abcdefghijklmnopqrstuvwxyz"
        %%LCextended = "                "
        %%UCextended = "               íŸ€íµŸ"
        gosub alpha-sense
     else
        %%LC = "abcdefghijklmnopqrstuvwxyz"
        %%LCextended = ""
        %%UCextended = ""
        gosub alpha-sense
     end
   end
  end

  if @equal(%%mode,alphanum)
    if @equal(%%extended,1)
      %%chars = "0123456789abcdefghijklmnopqrstuvwxyz                               íŸ€íµŸ"
     gosub alphanum
   else
      %%chars = "0123456789abcdefghijklmnopqrstuvwxyz"
     gosub alphanum
   end
  end

  if @equal(%%mode,numeric)
     gosub numeric
  end
 
goto evloop

:CLOSE
  exit



REM ######## SUBs ##########

:alpha
  if %i
    %x = 1
   %a = ""
   %u = ""
    repeat
      %%pos = @pos(@substr(%i,%x),%%chars)
     %%char = @substr(%i,%x)
      if @greater(%%pos,0)
       %a = %a%%char
      else
       %u = %u%%char
      end
      %x = @succ(%x)
    until @greater(%x,@len(%i))
    info String: %i@tab()@cr()@cr()Alphabetic: %a@cr()@cr()Not alphabetic: %u
  end
EXIT

:alpha-sense
  if %i
    %x = 1
   %l = ""
   %u = ""
   %n = ""
    repeat
      %%pos = @pos(@substr(%i,%x),%%LC)
     %%char = @substr(%i,%x)
      if @greater(%%pos,0)
        if @equal(%%char,@substr(%%LC,%%pos),EXACT)
          %l = %l%%char
        else
          %u = %u%%char
        end
      else
        %%extpos1 = @pos(%%char,%%LCextended)
      %%extpos2 = @pos(%%char,%%UCextended)
        if @greater(%%extpos1,0)@greater(%%extpos2,0)
          if @greater(%%extpos2,0)
            %u = %u%%char
          else
            %l = %l%%char
          end
        else
          %n = %n%%char
        end
      end
      %x = @succ(%x)
    until @greater(%x, @len(%i))
    info String: %i@tab()@cr()@cr()Upper case: %u@cr()@cr()Lower case: %l@cr()@cr()Not alphabetic: %n
  end
EXIT


:alphanum
  if %i
    %x = 1
   %a = ""
   %u = ""
    repeat
      %%pos = @pos(@substr(%i,%x),%%chars)
     %%char = @substr(%i,%x)
      if @greater(%%pos,0)
       %a = %a%%char
      else
       %u = %u%%char
      end
      %x = @succ(%x)
    until @greater(%x,@len(%i))
    info String: %i@tab()@cr()@cr()Alphanumeric: %a@cr()@cr()Not alphanumeric: %u
  end
EXIT


:numeric
  if %i
    %x = 1
   %u = ""
   %n = ""
    repeat
     %%char = @substr(%i,%x)
      if @numeric(%%char)
       %n = %n%%char
      else
       %u = %u%%char
      end
      %x = @succ(%x)
    until @greater(%x,@len(%i))
    info String: %i@tab()@cr()@cr()Numeric: %n@cr()@cr()Not numeric: %u
  end
EXIT


_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group