home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 4 / AACD04.ISO / AACD / Programming / CanDo / Decks1 / Complex / NewPhone.ctx < prev    next >
Encoding:
Text File  |  1998-09-26  |  8.3 KB  |  377 lines

  1. *************
  2. * Deck "NewPhone"
  3. *************
  4.  
  5. *************
  6. * Card(s) in deck.
  7. *  Card "Card#1"
  8. *************
  9. * 1 Card(s), 1 were printed.
  10. *************
  11.  
  12. *************
  13. * Natural order of Cards
  14. *  Card "Card#1"
  15. *************
  16.  
  17. *************
  18. * There are no Global routines in this deck.
  19. *************
  20.  
  21. *************
  22. * Card "Card#1"
  23.     BeforeAttachment
  24.         LoadSubDeck "SubDecks/PhoneSearch","PhoneSearch"
  25.         LoadSubDeck "SubDecks/SimpleReq","SimpleReq"
  26.         SetBusyPointer "CanDo:Brushes/Cover.Pntr"
  27.     EndScript
  28.     AfterAttachment
  29.         FastFeedBack On
  30.         Let FieldNames[1] = ".Name"
  31.         Let FieldNames[2] = ".Address"
  32.         Let FieldNames[3] = ".Phone"
  33.         Let FieldNames[4] = ".Comments"
  34.         SetPen 2
  35.         DrawRectangle 8,13,622,58
  36.         SetPen 1
  37.         DrawRectangle 7,12,622,58
  38.         SetPen 2
  39.         DrawRectangle 8,74,622,123
  40.         SetPen 1
  41.         DrawRectangle 7,73,622,123
  42.         PrintText "Name",42,79
  43.         PrintText "Address",19,96
  44.         PrintText "Phone",412,96
  45.         PrintText "Comments",11,149
  46.         Let DataModified = False
  47.         Let DataFile = "NewPhone.DAT"
  48.         If Exists(DataFile)
  49.             Do "Load DataFile" ;does a stop script on an error
  50.         Else
  51.             Let PhoneData[1] = GetDBObjects ;debug
  52.         EndIf
  53.         Do "Get Entry",1
  54.         Do "Set Field",1
  55.     EndScript
  56.     MessageFromSubDeck
  57.         If Arg1 <> ""
  58.             Do Arg1,Alias("Arg2"),Alias("Arg3"),Alias("Arg4")
  59.         EndIf
  60.     EndScript
  61.     Routine "Quit"
  62.         If Arg1
  63.             SaveVariable PhoneData,DataFile
  64.         EndIf
  65.         Quit
  66.     EndScript
  67.     Routine "Set Field"
  68.         If Arg1 = Nothing
  69.             Let CurrField = CurrField + 1
  70.         Else
  71.             Let CurrField = Arg1
  72.         EndIf
  73.         If CurrField > LastArrayIndex(FieldNames)
  74.             Let CurrField = 1
  75.         EndIf
  76.         SetObjectState FieldNames[CurrField],ON
  77.     EndScript
  78.     Routine "Search Next"
  79.         Local NewEntry
  80.         SetSearchArrayFlags NOCASE FORWARD SUBSTRING 
  81.         Let NewEntry = SearchArray(PhoneData,SearchText,"." || SearchField,Entry+1)
  82.         If Not SearchFound
  83.             Let NewEntry = SearchArray(PhoneData,SearchText,"." || SearchField)
  84.         EndIf
  85.         If SearchFound
  86.             Do "Goto Entry",NewEntry
  87.         EndIf
  88.     EndScript
  89.     Routine "Do Search"
  90.         If Arg1
  91.             Let SearchText  = Arg2
  92.             Let SearchField = Arg3
  93.             Do "Search Next"
  94.         EndIf
  95.         Do "Set Field",1
  96.     EndScript
  97.     Routine "Delete Entry"
  98.         DeleteArrayEntry PhoneData,Arg1
  99.         PositionOnLine Arg1
  100.         If TheLineNumber = LinesInDocument
  101.             Clear LINE 
  102.             Delete CHARACTER ,-1
  103.         Else
  104.             Delete LINE 
  105.         EndIf
  106.     EndScript
  107.     Routine "Load Error"
  108.         OpenRequester "SimpleReq","Comment","","Error while loading " || DataFile,ErrorText
  109.         Let PhoneData[1] = GetDBObjects ;debug
  110.         Do "Get Entry",1
  111.         StopScript
  112.     EndScript
  113.     Routine "Load DataFile"
  114.         DoOnError "Load Error"
  115.         Let PhoneData = LoadVariable(DataFile)
  116.         WorkWithDocument "Name List"
  117.         Clear DOCUMENT 
  118.         Let Entry = FirstArrayIndex(PhoneData)
  119.         While SearchFound
  120.             Type PhoneData[Entry].Name,NEWLINE 
  121.             Let Entry = NextArrayIndex(PhoneData,Entry)
  122.         EndLoop
  123.         Delete CHARACTER ,-1
  124.         MoveCursorTo STARTOF DOCUMENT 
  125.         Let Entry = 1
  126.     EndScript
  127.     Routine "Put Name In List"
  128.         Local TempName
  129.         Let TempName = UpperCase(Arg1)
  130.         MoveCursorTo STARTOF DOCUMENT 
  131.         If SizeOfDocument <> 0
  132.             Loop
  133.                 If UpperCase(TheLine) < TempName
  134.                     If TheLineNumber = LinesInDocument
  135.                         NewLine
  136.                         ExitLoop
  137.                     EndIf
  138.                     MoveCursor DOWN 
  139.                 Else
  140.                     SplitLine
  141.                     MoveCursor UP 
  142.                     ExitLoop
  143.                 EndIf
  144.             EndLoop
  145.         EndIf
  146.         Type Arg1
  147.     EndScript
  148.     Routine "Store Entry"
  149.         WorkWithDocument "Name List"
  150.         Let Work = GetDBObjects
  151.         If Work <> PhoneData[Entry]
  152.             If Work.Name <> PhoneData[Entry].Name
  153.                 Do "Delete Entry",Entry
  154.                 Do "Put Name In List",Work.Name
  155.                 Let Entry = TheLineNumber
  156.                 InsertArrayEntry PhoneData,Entry
  157.             EndIf
  158.             Let PhoneData[Entry] = Work
  159.             Let DataModified = True
  160.         EndIf
  161.     EndScript
  162.     Routine "Get Entry"
  163.         Let Entry = Arg1
  164.         SetDBObjects PhoneData[Entry]
  165.         WorkWithDocument "Name List"
  166.         PositionOnLine Arg1
  167.     EndScript
  168.     Routine "Goto Entry"
  169.         If Arg1 <> Entry
  170.             Do "Store Entry"
  171.             Do "Get Entry",Arg1
  172.         EndIf
  173.     EndScript
  174.     Window "UserWindow"
  175.         Definition
  176.             Origin 0,0
  177.             Size 640,200
  178.             Title "Phone List"
  179.             NumberOfColors 4
  180.             DefaultColors 0,1,0
  181.             WindowObjects CLOSEBUTTON DEPTHBUTTONS DRAGBAR 
  182.             WindowFlags ACTIVATE TOFRONT ; WORKBENCH
  183.             VisualEffects NONE ,WAIT 
  184.         EndScript
  185.         OnCloseButton
  186.             Do "Store Entry"
  187.             If DataModified
  188.                 OpenRequester "SimpleReq","YesNo","Quit","Phone Data has been modified.","Save it before leaving?"
  189.             Else
  190.                 Do "Quit",False
  191.             EndIf
  192.         EndScript
  193.     EndObject
  194.     AKey "Ctrl Return Key"
  195.         Definition
  196.             QualifiersPressed CONTROL 
  197.             KeyPressed RETURN 
  198.         EndScript
  199.         OnDown
  200.             Do "Set Field"
  201.         EndScript
  202.     EndObject
  203.     List "Name List"
  204.         Definition
  205.             Origin 81,18
  206.             Size 324,48
  207.             Font "topaz",8 ; FontName, PointSize
  208.             Style PLAIN 
  209.             TextColors 1,2 ; PenA, PenB, DrawMode
  210.             Border DOUBLEBEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen
  211.             ListDocument "Name List" ; where the text comes from
  212.         EndScript
  213.         OnClick
  214.             Do "Goto Entry",TheLineNumber
  215.         EndScript
  216.         OnDrag
  217.             Do "Goto Entry",TheLineNumber
  218.         EndScript
  219.         OnRelease
  220.             Do "Set Field",1
  221.         EndScript
  222.     EndObject
  223.     TextButton "Search Button"
  224.         Definition
  225.             Origin 420,26
  226.             Font "topaz",8 ; FontName, PointSize
  227.             Style PLAIN ,2,3
  228.             TextColors 1,0,JAM1  ; PenA, PenB, DrawMode
  229.             Text "  Search...  "
  230.             Border BEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen
  231.             Highlight COMPLEMENT 
  232.             ButtonFlags NONE 
  233.         EndScript
  234.         OnRelease
  235.             OpenWindow "PhoneSearch","SearchCard","Do Search",SearchText,SearchField
  236.         EndScript
  237.     EndObject
  238.     TextButton "Search Next Button"
  239.         Definition
  240.             Origin 420,46
  241.             Font "topaz",8 ; FontName, PointSize
  242.             Style PLAIN ,2,3
  243.             TextColors 1,0,JAM1  ; PenA, PenB, DrawMode
  244.             Text " Search Next "
  245.             Border BEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen
  246.             Highlight COMPLEMENT 
  247.             ButtonFlags NONE 
  248.         EndScript
  249.         OnRelease
  250.             Do "Search Next"
  251.             Do "Set Field",1
  252.         EndScript
  253.     EndObject
  254.     TextButton "Add Button"
  255.         Definition
  256.             Origin 535,26
  257.             Font "topaz",8 ; FontName, PointSize
  258.             Style PLAIN ,2,3
  259.             TextColors 1,0,JAM1  ; PenA, PenB, DrawMode
  260.             Text "   Add    "
  261.             Border BEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen
  262.             Highlight COMPLEMENT 
  263.             ButtonFlags NONE 
  264.         EndScript
  265.         OnRelease
  266.             Do "Store Entry"
  267.             SetDBObjects Nothing
  268.             If SizeOfDocument <> 0
  269.                 WorkWithDocument "Name List"
  270.                 MoveCursorTo STARTOF DOCUMENT 
  271.                 SplitLine
  272.                 MoveCursor UP 
  273.                 Let Entry = 1
  274.                 InsertArrayEntry PhoneData,Entry
  275.             EndIf
  276.             Let PhoneData[Entry] = GetDBObjects ;debug
  277.             Let DataModified = True
  278.             Do "Set Field",1
  279.         EndScript
  280.     EndObject
  281.     TextButton "Delete Button"
  282.         Definition
  283.             Origin 535,46
  284.             Font "topaz",8 ; FontName, PointSize
  285.             Style PLAIN ,2,3
  286.             TextColors 1,0,JAM1  ; PenA, PenB, DrawMode
  287.             Text "  Delete  "
  288.             Border BEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen
  289.             Highlight COMPLEMENT 
  290.             ButtonFlags NONE 
  291.         EndScript
  292.         OnRelease
  293.             WorkWithDocument "Name List"
  294.             Do "Delete Entry",TheLineNumber
  295.             Do "Get Entry",TheLineNumber
  296.             Let PhoneData[Entry] = GetDBObjects ;debug
  297.             Do "Set Field",1
  298.         EndScript
  299.     EndObject
  300.     TextField ".Name"
  301.         Definition
  302.             Origin 82,79
  303.             Size 321,8
  304.             Justification LEFT 
  305.             MaxFieldLength 255
  306.             InitialText Nothing
  307.             Border DOUBLEBEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen
  308.         EndScript
  309.         OnClick
  310.             Let CurrField = 1
  311.         EndScript
  312.         OnRelease
  313.             Do "Store Entry"
  314.             Do "Set Field"
  315.         EndScript
  316.     EndObject
  317.     Memo ".Address"
  318.         Definition
  319.             Origin 83,95
  320.             Size 319,44
  321.             Font "topaz",8 ; FontName, PointSize
  322.             Style PLAIN 
  323.             TextColors 1,0 ; PenA, PenB, DrawMode
  324.             Border DOUBLEBEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen
  325.             MemoDocument "Address Doc" ; where the text comes from
  326.             ScrollBars RIGHT 
  327.             InputStyle NORMAL 
  328.         EndScript
  329.         OnClick
  330.             Let CurrField = 2
  331.         EndScript
  332.         OnRelease
  333.             Nop
  334.         EndScript
  335.     EndObject
  336.     Memo ".Phone"
  337.         Definition
  338.             Origin 458,95
  339.             Size 160,44
  340.             Font "topaz",8 ; FontName, PointSize
  341.             Style PLAIN 
  342.             TextColors 1,0 ; PenA, PenB, DrawMode
  343.             Border DOUBLEBEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen
  344.             MemoDocument "Phone Doc" ; where the text comes from
  345.             ScrollBars RIGHT 
  346.             InputStyle NORMAL 
  347.         EndScript
  348.         OnClick
  349.             Let CurrField = 3
  350.         EndScript
  351.         OnRelease
  352.             Nop
  353.         EndScript
  354.     EndObject
  355.     Memo ".Comments"
  356.         Definition
  357.             Origin 83,148
  358.             Size 534,44
  359.             Font "topaz",8 ; FontName, PointSize
  360.             Style PLAIN 
  361.             TextColors 1,0 ; PenA, PenB, DrawMode
  362.             Border DOUBLEBEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen
  363.             MemoDocument "Comments Doc" ; where the text comes from
  364.             ScrollBars RIGHT 
  365.             InputStyle NORMAL 
  366.         EndScript
  367.         OnClick
  368.             Let CurrField = 4
  369.         EndScript
  370.         OnRelease
  371.             Nop
  372.         EndScript
  373.     EndObject
  374. * End of Card "Card#1"
  375. *************
  376.  
  377.