Variables and Definition Errors

Moderator: Rathinagiri

ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Re: Variables and Definition Errors

Post by ROBROS »

Hi Alan, take a look at DATA_BOUND in the samples, the screenshot shows the path in your installation-folder. I fancy you could use it for your app.
Attachments
databound.png
databound.png (920.9 KiB) Viewed 3804 times
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Variables and Definition Errors

Post by serge_girard »

Hi Alan,

Looks good. 1 type LIBRARY->ART_NO instead of LIBRARY->ARTNO + cAlbumRef.

It seems you are on your way !

Serge
There's nothing you can do that can't be done...
User avatar
dragancesu
Posts: 920
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: Variables and Definition Errors

Post by dragancesu »

First: check LIBRARY.dbf structure and field name (artno or art_no), indexing field ref, not in structure

MISTAKE: IF cTitle := ""
CORRECT: IF cTitle = ""

But, generaly not good practice
LOCAL cTitle := ""
and
@ 200,400 TEXTBOX cTitle

use different name,
when work with TEXTBOX cTitle than IF WindowName.cTitle.Value = "aaa"...
asharpham
Posts: 55
Joined: Sat Mar 24, 2018 2:48 pm
DBs Used: DBF

Re: Variables and Definition Errors

Post by asharpham »

Thanks so much for your input. I'm just curious about the use of := instead of =. I don't quite understand the purpose of := and I didn't use it in my Clipper programming years ago.

The DATA_BOUND sample looks very helpful. But there's a couple of things it doesn't tell me which someone may be able to assist me on. In the DATA_BOUND example, how would you do a Search for a specific record (as opposed to scrolling through them all to find it) and how to add a new record. Nerither of these are included in DATA_BOUND.

However, I think I have enough to continue from here and probably simplify my program somewhat.

Regards,
Alan
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Variables and Definition Errors

Post by andyglezl »

Hola asharpham
This program is unfinished so not all of the menu buttons work. It loads the main menu and loads "Add New Music" but none of the other menu items work, as well as the 3 buttons at the bottom. Some of the labels aren't displaying properly either but I know I can fix that as I work on it.
De entrada, me desplegó los siguientes mensaje de error
-------------------------------------------------------------------------
From the outset, your program showed me the following error message
error1.png
error1.png (6.85 KiB) Viewed 3743 times
error2.png
error2.png (12.12 KiB) Viewed 3743 times
Hice algunas correcciones a tu programa para hacerlo funcional
los comentarios vienen dentro del programa
---------------------------------------------------------------------------------
I made some corrections to your program to make it functional
the comments come within the program

Code: Select all

/* MUSIC LIBRARY MAIN MENU
   by Alan Sharpham
   2018 Revision from "The Schedule"
   Version 1.0
*/

#INCLUDE "hmg.ch"
#INCLUDE "inkey.ch"

FUNCTION Main()

PUBLIC nFontSize:=12
PUBLIC nHeaderLength:=0
PUBLIC nColumn,cHeader
PUBLIC nLastRecNumber:=0
PUBLIC nNewRecNo:=0, NewRec:=.T.

SET DATE BRITISH
SET CENTURY ON
SET NAVIGATION EXTENDED

*set procedure to open_dbf
*set procedure to open_ntx

if ! file ("LIBRARY.dbf")		// <=======================
   alist_fld := {} 
   aadd(alist_fld,{"TRACKNUM","N",4,0})
   aadd(alist_fld,{"ALBUM_NO","C",6,0})
   aadd(alist_fld,{"ALBUM_TITL","C",40,0})
   aadd(alist_fld,{"TITLE","C",33,0})
   aadd(alist_fld,{"ARTIST","C",40,0})
   aadd(alist_fld,{"ART_NO","N",4,0})
   aadd(alist_fld,{"TRACK","N",2,0})
   aadd(alist_fld,{"DUR","C",5,0})
   aadd(alist_fld,{"YR","C",2,0})
   aadd(alist_fld,{"FILENAME","C",8,0})
   dbcreate("LIBRARY",alist_fld)
endif

USE library NEW

IF LASTREC() = 0
	DBAPPEND()					// <=======================  At least there must be a record to create the indices
	//LIBRARY->RECORD   := ""	// <=======================  There is no RECORD field in the DB
	//LIBRARY->REF   	:= ""	// <=======================  There is no REF field in the DB
	LIBRARY->TITLE      := ""
	LIBRARY->ARTIST     := ""
	//LIBRARY->ARTNO    	:= 0	// <=======================  There is no ARTNO field in the DB
	LIBRARY->ART_NO    	:= 0	
	LIBRARY->TRACK      := 0
	LIBRARY->DUR        := ""
	LIBRARY->YR         := ""	// <=======================  There is no YEAR field in the DB
ENDIF

if ! file ("iTITLE.ntx")
   index on TITLE to iTITLE
endif

if ! file ("iARTIST.ntx")
   index on ARTIST to iARTIST
endif

if ! file ("iARTNO.ntx")
   //index on ARTNO to iARTNO	// <=======================  There is no ARTNO field in the DB
   index on ART_NO to iARTNO
endif

//if ! file ("iALBUMREF.ntx")		// <=======================  There is no REF field in the DB
//   index on REF to iALBUMREF
//endif

if ! file ("iFILENAME.ntx")
   index on FILENAME to iFILENAME
endif							// <=======================

//SET INDEX TO iTITLE,iARTIST,iARTNO,iALBUMREF,iFILENAME	//  <========================  From here you can open all the indices
SET INDEX TO iTITLE,iARTIST,iARTNO,iFILENAME		//  <========================  There is no REF field in the DB and not indice

nLastRecNumber := LASTREC()
cHeader := "My Music Library"
nHeaderLength := LEN(cHeader)

DEFINE WINDOW Library_1 ; 
	AT 0,0 ; 
	WIDTH 800 ; 
	; //HEIGHT 800 ;  		// <==================   My monitor is smaller
	HEIGHT 700 ; 
	TITLE "My Music Library" ; 
	NOSIZE ;
	NOMAXIMIZE ;
	ICON "CloudsIcon.jpg" ;
	BACKCOLOR {231,255,249} ;  // Light green
	MAIN 

	DEFINE LABEL Heading 
		ROW 10
		COL 290
		AUTOSIZE .T.
		VALUE cHeader
		nFontSize := 24
		FONTNAME "Van Dijk"
		FONTSIZE nFontSize 
		FONTCOLOR {102,51,0} 
		FONTBOLD .T.
		TRANSPARENT .T.
	END LABEL
	
	DEFINE LABEL Date
		ROW 60
		COL 370
		AUTOSIZE .T.
		VALUE DTOC(Date())
		FONTNAME "Arial"
		FONTSIZE 12
		FONTBOLD .T.
		TRANSPARENT .T.
	END LABEL
	
	DEFINE BUTTON AddButton
		ROW	100
		COL	310
		CAPTION "   Add New Music      " 
		TOOLTIP "Click to add a new album"
		WIDTH 200							
		HEIGHT 50							
		TRANSPARENT .T.
		ACTION ENTER() 
	END BUTTON

	DEFINE BUTTON EditButton
		ROW	200
		COL	310
		CAPTION " Edit Tracks / Albums " 
		TOOLTIP "Click to edit tracks or albums"
		WIDTH 200							
		HEIGHT 50							
		ACTION MUSICED() 
	END BUTTON
	
	DEFINE BUTTON DeleteButton
		ROW	300
		COL	310
		CAPTION "Delete Tracks / Albums" 
		TOOLTIP "Click to delete tracks or albums"
		WIDTH 200							
		HEIGHT 50							
		ACTION DELETEmusic()
	END BUTTON

	DEFINE BUTTON DisplayButton
		ROW	400
		COL	310
		CAPTION "     Display Menu     "
		TOOLTIP "Click for display menu"	
		WIDTH 200							
		HEIGHT 50							
		ACTION DISPLAY()
	END BUTTON

	DEFINE BUTTON PrintButton
		ROW	500
		COL	310
		CAPTION "      Print Menu       "
		TOOLTIP "Click for print menu"	
		WIDTH 200							
		HEIGHT 50							
		ACTION PRINTmenu()
	END BUTTON

	DEFINE BUTTON ExitButton
		ROW	600
		COL	310
		CAPTION "         Quit          "
		TOOLTIP "Click to Exit"	
		WIDTH 200							
		HEIGHT 50							
		ACTION Library_1.Release
	END BUTTON

END WINDOW

Library_1.CENTER
Library_1.ACTIVATE 

RETURN NIL 

/*-----------------------------------------------------------------------------*
Functions in Child_Windows
*-----------------------------------------------------------------------------*/

FUNCTION ENTER()

LOCAL cTitle := " "
LOCAL lAddRecords := .T.
LOCAL cArtist := ""
LOCAL nArtno := 0
LOCAL cAlbumTtl := ""
LOCAL cDura := ""
LOCAL nYear := 0
LOCAL cAlbumRef := ""
LOCAL cFileName := ""
	
DEFINE WINDOW Library_2 ;
	AT 0,0 ;
	; //  WIDTH 1100 HEIGHT 1000 ; 		// <==================   My monitor is smaller
	WIDTH 1100 HEIGHT 700 ;
	TITLE 'My Music Library - Add Menu' ;
	NOSIZE ;
	BACKCOLOR {247,226,223} ;  // Light pink
	CHILD

	
//IF Used()			// <==================   Why the question if from the beginning is already open ???
//	SELECT Library
//ELSE
//	USE Library NEW
//ENDIF

DEFINE LABEL AddHeading 
	PARENT Library_2
	ROW 10
	COL 370
	AUTOSIZE .T.
	VALUE cHeader 
	FONTNAME "Van Dijk"
	FONTSIZE nFontSize 
	FONTCOLOR {102,51,0} 
	FONTBOLD .T.
	TRANSPARENT .T.
END LABEL

DEFINE LABEL Add_SubHeading
	PARENT Library_2
	ROW 80
	COL 400
	AUTOSIZE .T.
	VALUE "Add New Music"
	FONTNAME "Arial"
	FONTSIZE 20
	FONTCOLOR {255,0,0}
	FONTITALIC .T.
	TRANSPARENT .T.
END LABEL

DEFINE LABEL Label_Add_1
	PARENT Library_2
	ROW 200
	COL 200
	VALUE "Track Title:"
	FONTNAME "Arial"
	FONTSIZE 16
	FONTCOLOR {0,0,0}
	TRANSPARENT .T.
END LABEL

DEFINE LABEL Label_Add_2
	PARENT Library_2
	ROW 250
	COL 200
	VALUE "Artist:"
	FONTNAME "Arial"
	FONTSIZE 16
	FONTCOLOR {0,0,0}
	TRANSPARENT .T.
END LABEL

DEFINE LABEL Label_Add_2a
	PARENT Library_2
	ROW 250
	COL 630
	VALUE "Artist Code: "+AllTrim(STR(nArtNo))
	FONTNAME "Arial"
	FONTSIZE 10
	FONTCOLOR {0,0,0}
	TRANSPARENT .T.
	TOOLTIP "Artist Number"
END LABEL

DEFINE LABEL Label_Add_3
	PARENT Library_2
	ROW 300
	COL 200
	VALUE "Album No:"
	FONTNAME "Arial"
	FONTSIZE 16
	FONTCOLOR {0,0,0}
	TRANSPARENT .T.
END LABEL

DEFINE LABEL Label_Add_3a
	PARENT Library_2
	ROW 300
	COL 630
	WIDTH 500
	VALUE "Type HD if on hard drive"
	FONTNAME "Arial"
	FONTSIZE 10
	FONTCOLOR {255,0,0}
	TRANSPARENT .T.
END LABEL

DEFINE LABEL Label_Add_4
	PARENT Library_2
	ROW 350
	COL 200
	VALUE "Album Title:"
	FONTNAME "Arial"
	FONTSIZE 16
	FONTCOLOR {0,0,0}
	TRANSPARENT .T.
END LABEL

DEFINE LABEL Label_Add_5
	PARENT Library_2
	ROW 400
	COL 200
	VALUE "Track No:"
	FONTNAME "Arial"
	FONTSIZE 16
	FONTCOLOR {0,0,0}
	TRANSPARENT .T.
END LABEL

DEFINE LABEL Label_Add_6
	PARENT Library_2
	ROW 450
	COL 200
	VALUE "Track Length:"
	FONTNAME "Arial"
	FONTSIZE 16
	FONTCOLOR {0,0,0}
	TRANSPARENT .T.
END LABEL

DEFINE LABEL Label_Add_7
	PARENT Library_2
	ROW 500
	COL 200
	VALUE "Year Produced:"
	FONTNAME "Arial"
	FONTSIZE 16
	FONTCOLOR {0,0,0}
	TRANSPARENT .T.
END LABEL

DEFINE LABEL Label_Add_8
	PARENT Library_2
	ROW 550
	COL 200
	VALUE "Track Filename:"
	FONTNAME "Arial"
	FONTSIZE 16
	FONTCOLOR {0,0,0}
	TRANSPARENT .T.
END LABEL

DEFINE LABEL Label_Add_8a
	PARENT Library_2
	ROW 550
	COL 630
	WIDTH 500
	VALUE "Leave blank if not on hard drive"
	FONTNAME "Arial"
	FONTSIZE 10
	FONTCOLOR {0,0,0}
	TRANSPARENT .T.
END LABEL

DEFINE BUTTON AddNewEntry
	PARENT Library_2
	ROW 620
	COL 200
	WIDTH 100
	HEIGHT 50
	CAPTION "Add"
	TRANSPARENT .T.
	FONTCOLOR {0,0,0}
	FONTSIZE 12
	FONTBOLD .T.
	ONCLICK AddEntry(cTitle,cArtist,cAlbumRef,cAlbumTtl,nTrack,cDura,nYear,nArtNo,cFileName)
END BUTTON

DEFINE BUTTON ClearEntry
	PARENT Library_2
	ROW 620
	COL 400
	WIDTH 100
	HEIGHT 50
	BACKCOLOR { 255,0,0 }  // Red
	CAPTION "Clear Entry"
	FONTCOLOR {0,0,0}
	FONTSIZE 12
	FONTBOLD .T.
//			ONCLICK ClearEntry(cTitle,cArtist,nArtNo)
END BUTTON

DEFINE BUTTON ExitWindow
	PARENT Library_2
	ROW 620
	COL 600
	WIDTH 100
	HEIGHT 50
	CAPTION "Exit"
	FONTCOLOR {0,0,0}
	FONTSIZE 12
	FONTBOLD .T.
	lAddRecords := .F.
	ONCLICK Library_2.RELEASE	// <======================= To exit this window
END BUTTON

//dbGoBottom()				// <=======================  Why go to the end if you are going to create a new one ???
//nArtno := LIBRARY->ARTNO
//cArtist := AllTrim(LIBRARY->ARTIST)
//cAlbumRef := AllTrim(LIBRARY->REF)
//nYear := LIBRARY->YEAR	// <=======================

@ 200,400 TEXTBOX cTitle ;		// Matches Label 1
	PARENT Library_2 ;
	WIDTH 200 ;
	MAXLENGTH 33 ;
	ON LOSTFOCUS IF( Empty( Library_2.cTitle.Value ), Library_2.cTitle.Setfocus, Nil )	// <=======================  from here you can validate that cTitle contains a value
																						// <=======================  it works when you press Enter or TAB not with the mouse
@ 250,400 TEXTBOX cArtist ;		// Matches Label 2
	PARENT Library_2 ;
	WIDTH 200 ;
	MAXLENGTH 40

@ 300,400 TEXTBOX cAlbumRef ;	// Matches Label 3
	PARENT Library_2 ;
	WIDTH 200 ;
	MAXLENGTH 6

@ 350,400 TEXTBOX cAlbumTtl ;	// Matches Label 4
	PARENT Library_2 ;
	WIDTH 200 ;
	MAXLENGTH 40

//IF Upper(AllTrim(cAlbumRef)) <> "HD"
	nTrack := 0
	@ 400,400 TEXTBOX nTrack ;	// Matches Label 6
		PARENT Library_2 ;
		WIDTH 200 ;
		MAXLENGTH 4
//ENDIF

@ 450,400 TEXTBOX cDura ;		// Matches Label 7
	PARENT Library_2 ;
	WIDTH 200 ;
	MAXLENGTH 5

@ 500,400 TEXTBOX nYear ;		// Matches Label 8
	PARENT Library_2 ;
	WIDTH 200 ;
	MAXLENGTH 4

@ 550,400 TEXTBOX cFileName ;	// Matches Label 9
	PARENT Library_2 ;
	WIDTH 200 ;
	MAXLENGTH 8

	END WINDOW	
	Library_2.CENTER
	Library_2.Activate

//IF cTitle := ""		<======================   I do not understand this
//	RELEASE ALL
//	RETURN
//ELSE
//	AddEntry(cTitle,cArtist,cAlbumRef,nTrack,cDura,nYear,nArtNo,cFileName)
//ENDIF

Return Nil

//-----------------------------------------------
FUNCTION AddEntry(cTitle,cArtist,cAlbumRef,nTrack,cDura,nYear,nArtNo,cFileName)

*IF cTitle := ""	<===============   := is to assign a value, not to ask if it has that value

//IF cTitle = ""	// <=======================  Already validated from the moment of capture
//	lAddRecords := .F.
//	RETURN
//ENDIF

// SELECT Library		// <==================   Again, Why this if from the beginning is already open ???
// SET INDEX TO iTITLE,iARTIST,iARTNO,iALBUMREF,iFILENAME


dbAppend()

// FUNCTION AddEntry(cTitle,cArtist,cAlbumRef,nTrack,cDura,nYear,nArtNo,cFileName)		
// <================  The values that you pass as parameters are the values that you assigned at the beginning of this function, you must use the value
// <================  which brings each TEXTBOX control that you defined

//LIBRARY->RECORD   	:= LIBRARY->(RECNO())
//LIBRARY->REF   		:= cAlbumRef
LIBRARY->TITLE      := Library_2.cTitle.Value
LIBRARY->ARTIST     := Library_2.cArtist.Value
//LIBRARY->ART_NO    	:= Library_2.ArtNo.Value		// <=================  TEXTBOX NOT DEFINED
LIBRARY->TRACK      := VAL( Library_2.nTrack.Value )
LIBRARY->DUR        := Library_2.cDura.Value
LIBRARY->YR         := Library_2.nYear.Value

//cAlbumRef := AllTrim(cAlbumRef)
//IF cAlbumRef := "HD"
//	LIBRARY->FILENAME   := cFILENAME
//ELSE
//	LIBRARY->FILENAME   := ""
//ENDIF

dbCommitall()
//SET INDEX TO		// <==================   Why disable indices ???

// ClearEntry(cTitle,Cfilename)

RETURN		


//----------------------------------------------

FUNCTION LastEntry(nYear,nArtNo,cArtist,cAlbumRef)

	nArtno := LIBRARY->ARTNO
	cArtist := AllTrim(LIBRARY->ARTIST)
	cAlbumRef := AllTrim(LIBRARY->REF)
	nYear := LIBRARY->YEAR

RETURN



//--------------------------------------------------------

FUNCTION MUSICED()
	DEFINE WINDOW Library_3 ;
		AT 0,0 ;
		WIDTH 1000 HEIGHT 1000 ;
		TITLE 'My Music Library - Edit Menu' ;
		BACKCOLOR {196,253,230} ;
		CHILD
	END WINDOW
	
	Library_3.CENTER
	Library_3.Activate

Return Nil


FUNCTION DELETEmusic()
	DEFINE WINDOW Library_4 ;
		AT 0,0 ;
		WIDTH 1000 HEIGHT 1000 ;
		TITLE 'My Music Library - Delete Menu' ;
		CHILD
	END WINDOW
	
	Library_4.CENTER
	Library_4.Activate

Return Nil


FUNCTION DISPLAY()
	DEFINE WINDOW Library_5 ;
		AT 0,0 ;
		WIDTH 1000 HEIGHT 1000 ;
		TITLE 'My Music Library - Display Menu' ;
		BACKCOLOR {196,174,253} ;
		CHILD
	END WINDOW
	
	Library_5.CENTER
	Library_5.Activate

Return Nil


FUNCTION PRINTmenu()
	DEFINE WINDOW Library_6 ;
		AT 0,0 ;
		WIDTH 1000 HEIGHT 1000 ;
		TITLE 'My Music Library - Print Menu' ;
		BACKCOLOR {46,227,255} ;
		CHILD
	END WINDOW
	
	Library_6.CENTER
	Library_6.Activate

Return Nil
Andrés González López
Desde Guadalajara, Jalisco. México.
asharpham
Posts: 55
Joined: Sat Mar 24, 2018 2:48 pm
DBs Used: DBF

Re: Variables and Definition Errors

Post by asharpham »

Yes Andres, there is still a long way to go. I'm assessing the DATA_BOUND sample as an option to my code but there are some things written into my code because of future processes I'll be adding.

And the reason I disable the indexes after saving is because in the future I will need to set a different order for a different process. ART_NO is incorrect as I recreated the Database using ARTNO for the field. I seem to have fixed that since uploading the zip file.

Many thanks for your input,
Alan
User avatar
dragancesu
Posts: 920
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: Variables and Definition Errors

Post by dragancesu »

For the beginning, make the structure correct, then indexes
When you open a table open with indexes, if you want to keep the natural order of use SET ORDER TO 0

Look at the BROWSE and GRID commands, they are much more powerful than CLIPPER

Look at windows programs, show data and leave the user to work with them
This is your old concept, sometimes COBOL then old CLIPPER, try to make it more modern, and for commands it's easy, it's learned
ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Re: Variables and Definition Errors

Post by ROBROS »

Hi Alan, see the following sample from Data_Bound, I have changed it to match my needs (change an existing record and write the changes to dbf):

Code: Select all

#include "hmg.ch"

local cPersnr

set navigation extended

use

DEFINE WINDOW form_chg ;
   AT 0,0 ;
   WIDTH 600 ;
   HEIGHT 480 ;
   TITLE 'Stammdaten Fahrer bearbeiten' ;
   On Init OpenBBPERS() ;
   ON RELEASE CloseBBPERS() 
   
    @  50,10 LABEL LABEL_1 VALUE 'PERSNR:'   

     @ 50,80 Textbox Text_seek;
     parent form_chg ;          
	 width 40;
	 height 20;	 
     value cPersnr;
	 font 'ARIAL' size 10 ;
     inputmask "9999" on lostFocus  seek_persnr()

   DEFINE TOOLBAR ToolBar_1 BUTTONSIZE 100,20 FLAT RIGHTTEXT BORDER


         BUTTON SAVE ;
         CAPTION '&Speichern' ;
         PICTURE 'save.bmp' ;
         ACTION ( Save_chg() , Refresh()  )

         BUTTON QUIT ;
         CAPTION '&Quit' ;
		 picture 'exit.bmp' ;
         ACTION ( END() )		

   END TOOLBAR


   @ 100,10 LABEL LABEL_2 VALUE 'VORNAME:'
   @ 130,10 LABEL LABEL_3 VALUE 'NAME:'
   @ 160,10 LABEL LABEL_4 VALUE 'STRASSE:'
   @ 190,10 LABEL LABEL_5 VALUE 'PLZ:'
   @ 220,10 LABEL LABEL_6 VALUE 'ORT:'
   @ 250,10 LABEL LABEL_7 VALUE 'Wegzeit:'
   @ 280,10 LABEL LABEL_8 VALUE 'STATUS:' 


   @ 100,200 TEXTBOX TEXT_2;
            FIELD BBPERS->VNAME ;
            MAXLENGTH 30

   @ 130,200 TEXTBOX TEXT_3;
             FIELD BBPERS->NAME ;
             MAXLENGTH 30
			 
   @ 160,200 TEXTBOX TEXT_4;
            FIELD BBPERS->STR ;
            MAXLENGTH 30
			
   @ 190,200 TEXTBOX TEXT_5 ;
             FIELD BBPERS->plz ;
			 MAXLENGTH 30
			 
   @ 220,200 TEXTBOX TEXT_6 ;
             FIELD BBPERS->ort ;
			 MAXLENGTH 1
			 
   @ 250,200 TEXTBOX TEXT_7 ;
             numeric ;
             FIELD BBPERS->wegzeit ;
         //    inputmask '999'	 
			 			 
 @  280,200 TEXTBOX TEXT_8 ;
            FIELD BBPERS->status ;
			width 15 ;
		    MAXLENGTH 1		 
		    inputmask 'A'

END WINDOW

form_chg.Text_seek.SetFocus

ACTIVATE WINDOW form_chg

Return

*********************************************************

Procedure Refresh
   form_chg.TEXT_2.Refresh
   form_chg.Text_3.Refresh
   form_chg.TEXT_4.Refresh
   form_chg.TEXT_5.Refresh
   form_chg.TEXT_6.Refresh
   form_chg.TEXT_7.Refresh   
   form_chg.TEXT_8.Refresh 
//   form_chg.Text_2.SetFocus
Return
********************************************************
Procedure Save_chg
      form_chg.TEXT_2.Save
      form_chg.TEXT_3.Save
      form_chg.TEXT_4.Save
      form_chg.TEXT_5.Save
      form_chg.TEXT_6.Save
      form_chg.TEXT_7.Save
      form_chg.TEXT_8.Save
	  form_chg.text_seek.SetFocus
	  MsgInfo ('SAVED')
Return
*********************************************************
procedure seek_persnr
select bbpers
seek form_chg.text_seek.value
if !found() .and. !empty(form_chg.text_seek.value)
   MsgInfo( form_chg.text_seek.value+' nicht gefunden')
   form_chg.text_seek.SetFocus
endif

if empty(form_chg.text_seek.value)
 //  release window form_chg
   form_chg.text_seek.SetFocus
endif

if found()
   nRecNr:=RecNo()  
   go nRecNr
endif
refresh()
return
************************************************************
function end
use
release window form_chg
return
**************************************************************
Procedure CloseBBPERS
   USE
Return
**************************************************************
Procedure OpenBBPERS
use bbpers alias bbpers new
index on persnr to persnr
return
Regards from Bavaria.
Robert
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Variables and Definition Errors

Post by esgici »

asharpham wrote: Mon Apr 02, 2018 4:03 am ... I'm just curious about the use of := instead of =. I don't quite understand the purpose of := and I didn't use it in my Clipper programming years ago.
...
Hi Alan

:= is "assign" and = is both assign and relational ( comparison ) operator ( further info )

and = operator has a goody: the compiler automatically detect, which you want do, assign or comparison ?

Note : := added to language syntax with CL 5 version )

Happy Clippering :D
Viva INTERNATIONAL HMG :D
asharpham
Posts: 55
Joined: Sat Mar 24, 2018 2:48 pm
DBs Used: DBF

Re: Variables and Definition Errors

Post by asharpham »

Going back to the DATA_BOUND example, the line "Win_1.Add1.Refresh" where Win_1 is the Window name and "Add1" is the Textbox name (I've changed them for my purposes), am I correct in saying that "refresh" refreshes the value of the textbox? In each case the textbox refers to a database FIELD but I presume it doesn't save to the database at this point as these statements are followed by a series of .save statements.

So what are the "refresh" statements refreshing? And are the "save" statements saving to the database or do I still need to use "dbCommit()"?

A problem I am having with my edited version of DATA_BOUND which I've saved as "TestLib.prg" is that I want to include the ability to add new records. In doing this, I want to refresh the screen with mostly empty textboxes but keeping 2 of them the same as the last entry. This seems to work but when I mouse over the textboxes they revert to the previous (or top) entry. I have no "mouseover" commands anywhere in my code so I'm not sure why this is happening.

I'm uploading the TestLib file and including my database and index files so it can be run. I'm getting there but still need some direction and I appreciate all the help being given.

Regards,
Alan
Attachments
TestLib.zip
(4.43 KiB) Downloaded 174 times
Post Reply