:Start of GadgetXDictionary GadgetXDictionary.dsc
DragonSphereSoftware

DragonSphere Software Demos


If you are viewing this script in your browser you can save it as a VDS 5.x source file (*.dsc) to run it.




#
# DragonSphere Software's Home Page
#  
# All Source Files for this demo
#
# This Script demostartes the use of the GadgetX Dictionary commands and functions.
#

Title GadgetX Dictionary
If @Greater(@Name(@SYSINFO(DSVER)),4)

External gadgetx.dll,@Sysinfo(DSVER)

  #DEFINE COMMAND,DEFINE,DICTIONARY
  #DEFINE FUNCTION,DICTIONARY
Else
  Warn This demo will only work with VDS 5+
  Stop
End
# Define your dictionary
Define Dictionary,IMSlang 
# Load the dict.txt
Dictionary LoadFile,IMSlang,@Path(%0)dict.txt

  DIALOG CREATE,IM Slang Gadget,-1,0,146,136,SNAP,SMALLCAP
REM *** Modified by Dialog Designer on 3/4/2007 - 10:31 ***
  DIALOG ADD,TEXT,TEXT1,1,5,30,13,Slang:
  DIALOG ADD,COMBO,COMBO1,16,5,139,21,,,CLICK,EXIT,SORTED
  DIALOG ADD,TEXT,TEXT2,41,5,49,13,Definition:
  DIALOG ADD,EDIT,EDIT2,55,5,137,75,,,WRAP,MULTI,SCROLL
  DIALOG SHOW
  List Assign,COMBO1,@Dictionary(NAMES,IMSlang)
  %%OldText = @dlgtext(COMBO1)
:evloop 
  wait event,0.3
  %E = @event() 
  If %E 
    goto %E
  End 
goto evloop 
:TIMER
  %B =
  %Z =
  %A = @dlgtext(COMBO1)
  if %A
    %A = @lower(%A)
    if @UnEqual(%A,%%OldText)
      %%OldText = %A
      %L = @len(%A)
      %c = 1
      %W = @substr(%A,1,1)
      while @Not(@Equal(%c,%L))
        %W = %W?
        %B = %B@Dictionary(PARTIAL,IMSlang,%W,?,NAMES)
        If %B
          %B = @Trim(%B)@CR()
        End
        %c = @succ(%c)
      wend
      %B = @Trim(%B)
      If @NULL(%B)
        %B = @Dictionary(NEAR,IMSlang,%A,@succ(@len(%A)),NAMES)
      End
      List clear,COMBO1
      List Assign,COMBO1,%B
      Dialog set,COMBO1,%A
      WINDOW SEND,~COMBO1,@KEY(END)
    end
  end
goto evloop
:COMBO1EXIT
  %A = @dlgtext(COMBO1) 
  if %A
    %B = @match(COMBO1,%A)
  end
goto COMBO1CLICK  
:COMBO1CLICK
   %A = @Item(COMBO1) 
   if %A
    DIALOG SET,COMBO1,%A 
    Window Send,~COMBO1,@KEY(END)    
    %%Found = @Dictionary(Find,IMSlang,@LOWER(%A)) 
    If %%Found
      Dialog Set,EDIT2,%%Found
    Else 
      Dialog Set,EDIT2,
    End 
  else
    Dialog Set,EDIT2,
  end 
goto evloop
:QUITBUTTON 
:CLOSE 
    #%%Values = @Dictionary(TEXT,IMSlang," = ") 
    
    Dictionary SaveFile,IMSlang,@Path(%0)dictpairs.txt,TEXT
    Dictionary SaveFile,IMSlang,@Path(%0)dictnames.txt,NAMES
    Dictionary SaveFile,IMSlang,@Path(%0)dictvalues.txt,VALUES
    Dictionary Close,IMSlang
Exit

: