  option decimalsep,.

  rem -- A Simple VDS screensaver that Bounces text around. By Mac --

  rem -- NOTES - SPACEBAR, ENTER Key and mouse movement will kill it.
  rem --         It doesn't use external DLLs and creates its' own INI
  rem --         file at setup to set text, color, and can optionallly
  rem --         ignore a running program (like Media Player).
  rem --         It also has password protection, but it must be
  rem --         activated (on/off) in its' own setup, the Windows
  rem --         password checkbox has no effect. Also you must
  rem --         have entered a password, or there is none to activate.
  rem --         You must compile this to an EXE, change the extension
  rem --         to SCR, and copy it to your Windows directory. It
  rem --         shows up as "Bounce" on the screen saver list.

  rem -- Windows sends these parameters to the screensaver:
  rem -- If the display properties window is open, Windows
  rem -- constantly calls the screensaver with "/p xxxx"
  rem -- (I found out "xxxx" may not always be the same number).
  rem -- Preview button= "/p"
  rem -- Settings button= "/c"
  rem -- Change Password button= "/a xxxx" (once again, the "xxxx"
  rem -- may not always be the same number).
  rem -- Normally sends "/s" when starting the screensaver.

  rem -- Kill the "/p xxxx" parameters.
  if @equal(%1, "/p")
    if %2
      exit 
    end 
  end 

  rem -- Allow only 1 instance of program --
  if @winexists("Mac's Bouncing Screensaver")
    exit 
  end 

  option SCALE, 96
  option PRIORITY, IDLE
  %%ini_file = @windir()\SSBounce.ini

  rem -- Change password  button --
  if @equal(%1, "/a")
    if %2
:Password
      %p = @input(Enter your new password,,PASSWORD)
      wait 
      %q = @input(Enter your password again for verification,,PASSWORD)
      if @equal(%p, %q, EXACT)
        if @file(%%Ini_File)
          if %p
            inifile OPEN, %%Ini_File
            inifile WRITE, OPTIONS, Pass, %p
          end 
        else 
          info You must run Setup first@tab()
        end 
      else 
        info Password entries do not match.@tab()
      end 
      exit 
    end 
  end 

  rem -- Setup for screensaver --
  if @equal(%1, "/c")
    rem -- Create default INI file if none --
    if @not(@file(%%Ini_File))
      list CREATE, 1
      list ADD, 1, "[OPTIONS]"
      list ADD, 1, "Text=VDS Rules!"
      list ADD, 1, "Color=LTBLUE"
      list ADD, 1, "Ignore="
      list ADD, 1, "Pass="
      list ADD, 1, "Activate="
      list SAVEFILE, 1, %%Ini_File
      list CLOSE, 1
      inifile OPEN, %%Ini_File
    else 
      inifile OPEN, %%Ini_File
    end 
    dialog CREATE, "Mac's Bouncing Screensaver Setup",-1,0,300,120,NOSYS,ONTOP
    dialog ADD,TEXT,ColorTxt,3,5,,,Color
    dialog ADD,COMBO,ColorList,0,40,80,20,,LIST
    dialog ADD,TEXT,TextTxt,33,5,,,Text
    dialog ADD,EDIT,TextToBounce,30,40,250
    dialog ADD,TEXT,IgnoreTxt,63,5,,,Ignore
    dialog ADD,EDIT,Ignore,60,40,250
    dialog ADD,BUTTON,Save,1,130,50,22
    dialog ADD,BUTTON,Exit,1,181,60,22,"Exit Setup"
    dialog ADD,BUTTON,Help,1,242,50,22
    dialog ADD,BUTTON,Pass,90,5,100,22,"Change Password"
    dialog ADD,CHECK,Activate,88,120,175,14,"Activate Password Protection",@iniread(OPTIONS,Activate)
    dialog ADD,TEXT,InfoTxt,104,138,,,""
    dialog SHOW
    list ADD, ColorList, "RED"
    list ADD, ColorList, "LTBLUE"
    list ADD, ColorList, "LTGREEN"
    list ADD, ColorList, "YELLOW"
    dialog SET, TextToBounce, @iniread(OPTIONS,Text)
    if @match(ColorList, @iniread(OPTIONS,Color))
    end 
    dialog SET, Ignore, @iniread(OPTIONS,Ignore)
:EVLOOP
    %p = @iniread(OPTIONS,Pass)
    if %p
      dialog SET, InfoTxt, "Password Available"
    else 
      dialog SET, InfoTxt, "No Password Available"
    end 
    dialog FOCUS, Save
    wait EVENT
    goto @event()
:SaveBUTTON
    if @dlgtext(TextToBounce)
      inifile WRITE, OPTIONS, Text, @dlgtext(TextToBounce)
    end 
    if @dlgtext(ColorList)
      inifile WRITE, OPTIONS, Color, @dlgtext(ColorList)
    end 
    inifile WRITE, OPTIONS, Ignore, @dlgtext(Ignore)
    inifile WRITE, OPTIONS, Activate, @dlgtext(Activate)
    rem -- Note: Password is saved at entry (:Program label above) --
    info Changes Saved.@cr()@cr()Default used if no entry.@tab()
    goto EVLOOP
:HelpBUTTON
    info 1.Pick a color for the text.@tab()@cr()2.Enter the text to bounce in the 'Text' box.@tab()@cr()3.Optional - Put Title bar name of a program to ignore it@cr()so screensaver won't come on if it's running.
    goto EVLOOP
:PassBUTTON
    gosub Password
    goto EVLOOP
:ExitBUTTON
    exit 
  end 

  rem -- Screensaver code starts here --
  if @file(%%Ini_File)
    inifile OPEN, %%Ini_File
    %t = @iniread(OPTIONS,Text)
    %c = @iniread(OPTIONS,Color)
    %i = @iniread(OPTIONS,Ignore)
    %p = @iniread(OPTIONS,Pass)
    %a = @iniread(OPTIONS,Activate)
  else 
    %t = "VDS Rules!"
    %c = LTBLUE
  end 

  rem -- Check for ignore program --
  if %i
    list CREATE, 1
    list  WINLIST,1,N
    if @match(1, %i)
      exit 
    end 
  end 

  %w = @sysinfo(SCREENWIDTH)
  %h = @sysinfo(SCREENHEIGHT)

  dialog CREATE, "Mac's Bouncing Screensaver",0,0,%w,%h,NOTITLE,ONTOP
  dialog ADD,STYLE,Style1,,,,BLACK
  dialog ADD,STYLE,Style2,Ariel Black,36,B,BLACK,%c
  dialog ADD,STYLE,BoldText,,10,B
  dialog ADD,TEXT,Background,0,0,%w,%h,"",Style1
  dialog ADD,TEXT,TextToBounce,0,0,,,%t,Style2
  dialog ADD,BUTTON,Default,0,0,0,0,,DEFAULT
  dialog SHOW

  %l = 2
  %m = 1
  %x = 0
  %y = 0

  rem -- Working space minus length and height of text (approx) --
  %f = @prod(@len(%t), 26)
  %w = @diff(%w, %f)
  %h = @diff(%h, 44)

:START
  %%oldpos = @mousepos()
  repeat 
    %z = NEXT
    %e = @event()
    if @equal(%e, "DefaultBUTTON")
      %z = %e
    end 
    goto %z
:NEXT
    %%newpos = @mousepos()
    %x = @sum(%x, %l)
    %y = @sum(%y, %m)
    if @greater(%x, %w)
      %l = -2
      %x = @sum(%x, @prod(2, %l))
    end 
    if @greater(0, %x)
      %l = 2
      %x = @sum(%x, @prod(2, %l))
    end 
    if @greater(%y, %h)
      %m = -2
      %y = @sum(%y, @prod(2, %m))
    end 
    if @greater(0, %y)
      %m = 2
      %y = @sum(%y, @prod(2, %m))
    end 
    dialog SETPOS, TextToBounce, %y, %x
    wait .01
  until @not(@equal(%%oldpos, %%newpos))
:DefaultBUTTON
  %z = ENDALL
  if @equal(%a, 1)
    if %p
      %z = START
      %q = @input(Enter your password,,PASSWORD)
      if %q
        if @equal(%p, %q, EXACT)
          %z = ENDALL
        else 
          wait 2
        end 
      else 
        wait 2
      end 
    end 
  end 
  goto %z

:ENDALL
  exit 
