PWCT 1.9 Art Documentation ( http://doublesvsoop.sourceforge.net ) 2006-2019, Mahmoud Fayed ( msfclipper@users.sourceforge.net ) _____________________________________________________________________________________ Table of contents 1 - Introduction 2 - Implementation steps 3 - Final Steps Tree 4 - Application during the runtime 1 - Introduction When you need to save files inside a database you will need to convert files to a stream then saving that stream into the database. To restore files from the database you need to read a stream from the database then convert that stream to a file. In this lesson we are going to learn how to convert a file to a stream and how to convert a stream to a file. In our sample the application will ask the user to select an image file then the application will convert the selected image file to stream, after that the application will ask the user to determine the name of a new image file then the application will convert the stream to the new image file determined by the user. Note : We are not restricted with image files as a type because the conversion process can be done on any file regardless of it's type (image, sound, video, ...etc) , i.e. you can use this technique to store any file inside a database. 2 - Implementation Steps Fig. (1) Goal Desginer - Steps Tree Select the step (The First Step) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Windows) 3 - Select the component (Define New Window) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (Define New Window) Note : Stop typing when you see the required component is selected Fig. (2) Component Browser – Select the component (Define New Window) After selecting the component click Ok or press ENTER Fig. (3) Interaction page - Set the properties and enter the required data as in the image above Fig. (4) Form Designer Fig. (5) Goal Desginer - Steps Tree Select the step (Window Properties) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Windows) 3 - Select the component (Window Class) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (Window Class) Note : Stop typing when you see the required component is selected Fig. (6) Component Browser – Select the component (Window Class) After selecting the component click Ok or press ENTER Fig. (7) Interaction page - Set the properties and enter the required data as in the image above Fig. (8) Interaction page - Set the properties and enter the required data as in the image above Fig. (9) Interaction page - Set the properties and enter the required data as in the image above Fig. (10) Form Designer Fig. (11) Goal Desginer - Steps Tree Select the step (Window Controls) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Controls) 3 - Select the component (Button) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (Button) Note : Stop typing when you see the required component is selected Fig. (12) Component Browser – Select the component (Button) After selecting the component click Ok or press ENTER Fig. (13) Interaction page - Set the properties and enter the required data as in the image above Fig. (14) Form Designer Fig. (15) Goal Desginer - Steps Tree Select the step (Button Events) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Events) 3 - Select the component (Button Events) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (Button Events) Note : Stop typing when you see the required component is selected Fig. (16) Component Browser – Select the component (Button Events) After selecting the component click Ok or press ENTER Fig. (17) Interaction page - Set the properties and enter the required data as in the image above Fig. (18) Goal Desginer - Steps Tree Select the step (Window Controls) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Controls) 3 - Select the component (Button) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (Button) Note : Stop typing when you see the required component is selected Fig. (19) Component Browser – Select the component (Button) After selecting the component click Ok or press ENTER Fig. (20) Interaction page - Set the properties and enter the required data as in the image above Fig. (21) Form Designer Fig. (22) Goal Desginer - Steps Tree Select the step (Button Events) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Events) 3 - Select the component (Button Events) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (Button Events) Note : Stop typing when you see the required component is selected Fig. (23) Component Browser – Select the component (Button Events) After selecting the component click Ok or press ENTER Fig. (24) Interaction page - Set the properties and enter the required data as in the image above Fig. (25) Goal Desginer - Steps Tree Select the step (The First Step) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Structure Programming) 3 - Select the component (Define Procedure) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (Define Procedure) Note : Stop typing when you see the required component is selected Fig. (26) Component Browser – Select the component (Define Procedure) After selecting the component click Ok or press ENTER Fig. (27) Interaction page - Set the properties and enter the required data as in the image above Fig. (28) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Files / Folders) 3 - Select the component (Get File) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (Get File) Note : Stop typing when you see the required component is selected Fig. (29) Component Browser – Select the component (Get File) After selecting the component click Ok or press ENTER Fig. (30) Interaction page - Set the properties and enter the required data as in the image above Fig. (31) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Files / Folders) 3 - Select the component (Check File) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (Check File) Note : Stop typing when you see the required component is selected Fig. (32) Component Browser – Select the component (Check File) After selecting the component click Ok or press ENTER Fig. (33) Interaction page - Set the properties and enter the required data as in the image above Fig. (34) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Control Structure) 3 - Select the component (IF Statement) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (IF Statement) Note : Stop typing when you see the required component is selected Fig. (35) Component Browser – Select the component (IF Statement) After selecting the component click Ok or press ENTER Fig. (36) Interaction page - Set the properties and enter the required data as in the image above Fig. (37) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Structure Programming) 3 - Select the component (Call Function) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (Call Function) Note : Stop typing when you see the required component is selected Fig. (38) Component Browser – Select the component (Call Function) After selecting the component click Ok or press ENTER Fig. (39) Interaction page - Set the properties and enter the required data as in the image above Fig. (40) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Files / Folders) 3 - Select the component (Put File) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (Put File) Note : Stop typing when you see the required component is selected Fig. (41) Component Browser – Select the component (Put File) After selecting the component click Ok or press ENTER Fig. (42) Interaction page - Set the properties and enter the required data as in the image above Fig. (43) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Control Structure) 3 - Select the component (IF Statement) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (IF Statement) Note : Stop typing when you see the required component is selected Fig. (44) Component Browser – Select the component (IF Statement) After selecting the component click Ok or press ENTER Fig. (45) Interaction page - Set the properties and enter the required data as in the image above Fig. (46) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Structure Programming) 3 - Select the component (Call Function) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (Call Function) Note : Stop typing when you see the required component is selected Fig. (47) Component Browser – Select the component (Call Function) After selecting the component click Ok or press ENTER Fig. (48) Interaction page - Set the properties and enter the required data as in the image above Fig. (49) Goal Desginer - Steps Tree Select the step (The First Step) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Structure Programming) 3 - Select the component (Define Function) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (Define Function) Note : Stop typing when you see the required component is selected Fig. (50) Component Browser – Select the component (Define Function) After selecting the component click Ok or press ENTER Fig. (51) Interaction page - Set the properties and enter the required data as in the image above Fig. (52) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Structure Programming) 3 - Select the component (Scope of Variable) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (Scope of Variable) Note : Stop typing when you see the required component is selected Fig. (53) Component Browser – Select the component (Scope of Variable) After selecting the component click Ok or press ENTER Fig. (54) Interaction page - Set the properties and enter the required data as in the image above Fig. (55) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Tools & Extensions) 3 - Select the component (OLE Automation) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (OLE Automation) Note : Stop typing when you see the required component is selected Fig. (56) Component Browser – Select the component (OLE Automation) After selecting the component click Ok or press ENTER Fig. (57) Interaction page - Set the properties and enter the required data as in the image above Fig. (58) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Tools & Extensions) 3 - Select the component (OLE Automation) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (OLE Automation) Note : Stop typing when you see the required component is selected Fig. (59) Component Browser – Select the component (OLE Automation) After selecting the component click Ok or press ENTER Fig. (60) Interaction page - Set the properties and enter the required data as in the image above Fig. (61) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Tools & Extensions) 3 - Select the component (OLE Automation) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (OLE Automation) Note : Stop typing when you see the required component is selected Fig. (62) Component Browser – Select the component (OLE Automation) After selecting the component click Ok or press ENTER Fig. (63) Interaction page - Set the properties and enter the required data as in the image above Fig. (64) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Tools & Extensions) 3 - Select the component (OLE Automation) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (OLE Automation) Note : Stop typing when you see the required component is selected Fig. (65) Component Browser – Select the component (OLE Automation) After selecting the component click Ok or press ENTER Fig. (66) Interaction page - Set the properties and enter the required data as in the image above Fig. (67) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Tools & Extensions) 3 - Select the component (OLE Automation) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (OLE Automation) Note : Stop typing when you see the required component is selected Fig. (68) Component Browser – Select the component (OLE Automation) After selecting the component click Ok or press ENTER Fig. (69) Interaction page - Set the properties and enter the required data as in the image above Fig. (70) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Tools & Extensions) 3 - Select the component (OLE Automation) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (OLE Automation) Note : Stop typing when you see the required component is selected Fig. (71) Component Browser – Select the component (OLE Automation) After selecting the component click Ok or press ENTER Fig. (72) Interaction page - Set the properties and enter the required data as in the image above Fig. (73) Goal Desginer - Steps Tree Select the step (The First Step) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Structure Programming) 3 - Select the component (Define Function) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (Define Function) Note : Stop typing when you see the required component is selected Fig. (74) Component Browser – Select the component (Define Function) After selecting the component click Ok or press ENTER Fig. (75) Interaction page - Set the properties and enter the required data as in the image above Fig. (76) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Structure Programming) 3 - Select the component (Scope of Variable) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (Scope of Variable) Note : Stop typing when you see the required component is selected Fig. (77) Component Browser – Select the component (Scope of Variable) After selecting the component click Ok or press ENTER Fig. (78) Interaction page - Set the properties and enter the required data as in the image above Fig. (79) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Tools & Extensions) 3 - Select the component (OLE Automation) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (OLE Automation) Note : Stop typing when you see the required component is selected Fig. (80) Component Browser – Select the component (OLE Automation) After selecting the component click Ok or press ENTER Fig. (81) Interaction page - Set the properties and enter the required data as in the image above Fig. (82) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Tools & Extensions) 3 - Select the component (OLE Automation) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (OLE Automation) Note : Stop typing when you see the required component is selected Fig. (83) Component Browser – Select the component (OLE Automation) After selecting the component click Ok or press ENTER Fig. (84) Interaction page - Set the properties and enter the required data as in the image above Fig. (85) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Tools & Extensions) 3 - Select the component (OLE Automation) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (OLE Automation) Note : Stop typing when you see the required component is selected Fig. (86) Component Browser – Select the component (OLE Automation) After selecting the component click Ok or press ENTER Fig. (87) Interaction page - Set the properties and enter the required data as in the image above Fig. (88) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Tools & Extensions) 3 - Select the component (OLE Automation) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (OLE Automation) Note : Stop typing when you see the required component is selected Fig. (89) Component Browser – Select the component (OLE Automation) After selecting the component click Ok or press ENTER Fig. (90) Interaction page - Set the properties and enter the required data as in the image above Fig. (91) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Tools & Extensions) 3 - Select the component (OLE Automation) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (OLE Automation) Note : Stop typing when you see the required component is selected Fig. (92) Component Browser – Select the component (OLE Automation) After selecting the component click Ok or press ENTER Fig. (93) Interaction page - Set the properties and enter the required data as in the image above Fig. (94) Goal Desginer - Steps Tree Select the step (Start Here) We will start now new interaction process to generate new steps to our steps tree. The slow way (Using Mouse): 1 - Click Interact to open the components browser 2 - Select the domain (Tools & Extensions) 3 - Select the component (OLE Automation) The fast way (Using Keyboard shortcuts): 1 - Get the component using its name by typing (OLE Automation) Note : Stop typing when you see the required component is selected Fig. (95) Component Browser – Select the component (OLE Automation) After selecting the component click Ok or press ENTER Fig. (96) Interaction page - Set the properties and enter the required data as in the image above Fig. (97) Goal Desginer - Final Steps Tree 3 - Final Steps Tree The First Step Define New Window ( win1 ) , Title : "Image To Stream & Stream To Image" Window Events Window Properties win1.Center ( ) Window Controls Define New Button ( btn1 ) , Caption : "Load Image to Stream - Then Save Stream to Image" Button Events Event: ON CLICK : Action myWork Button Properties Define New Button ( btnClose ) , Caption : "Close" Button Events Event: ON CLICK : Action win1.release Button Properties End Of Window Activate window Define Procedure myWork Start Here GetFile := Get File CheckFile := Check File GetFile IF ( CheckFile ) Start Here MyStream = Call Function FileToStream ( GetFile ) PutFile := Put File IF ( .not. PutFile == "" ) Start Here Call Function StreamToFile ( MyStream,PutFile ) END OF IF STATEMENT END OF IF STATEMENT End of Procedure Define Function FileToStream ( cFileName ) Start Here Local sStream,oMyObj Create OLE Object oMyObj of Type "adodb.stream" oMyObj.type := 1 oMyObj.open ( ) oMyObj.LoadFromFile ( cFileName ) sStream = oMyObj.Read ( ) oMyObj.close ( ) End of Function (Return sStream) Define Function StreamToFile ( sStream,cFileName ) Start Here Local oMyObj Create OLE Object oMyObj of Type "adodb.stream" oMyObj.type := 1 oMyObj.open ( ) oMyObj.write ( sStream ) oMyObj.SaveToFile ( cFileName,1 ) oMyObj.close ( ) End of Function 4 - Application during the runtime Fig. (98) Application during the runtime Fig. (99) Application during the runtime Fig. (100) Application during the runtime
|