Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Building object name and calling it
Message
From
04/03/2017 05:46:17
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
04/03/2017 00:24:27
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01648762
Message ID:
01648770
Views:
58
>Sorry if I offend rules and regulations here by asking this, but Thomas, seeing as you understand what I am doing - If I have say 4 records in the table, and make 4 line objects visible, my next problem is to make each visible line object display the data in it's record in the table. Any suggestions how to achieve that? EG: Object1 to display record 1 data, Object2 to display record 2 data, etc.
>
>Many thanks!


There are a few ways To Do This including & usage (but certainly it Is the one you should avoid). Probably the most effective way is:
Local ix
For ix=1 To Reccount()
	With Getpem(Thisform, 'Dayjobsline'+Ltrim(Str(m.ix)))
		.Visible=.T.
		* any other propery get/set or method call
	Endwith
Endfor
As per displaying data, it depends on what kind of an object that is. If say, it is an object with a ControlSource property, you could scatter the records to an array and bind array objects as controlsources (and gather if would be saved). ie:
If Reccount() > 0
	AddProperty(Thisform, Textmerge('aRecords[<< RECCOUNT() >>]'))
	Scan
		Scatter Name Thisform.aRecords[RECNO()] Memo
		With Getpem(Thisform, 'Dayjobsline'+Ltrim(Str(Recno())))
			.Visible=.T.
			.ControlSource = Textmerge('(thisform.aRecords[<< RECNO() >>].MyField)')
		Endwith
	Endscan
Endfor
A more detaied sample might be:
Select Top 5 * From (_samples+'data\customer') Order By cust_id Into Cursor crsTest Readwrite
Use In 'customer'

Public oForm
oForm = Createobject('Myform')
oForm.Show()


Define Class myForm As Form
	Add Object btnFillCustom As CommandButton

	Add Object Dayjobsline1 As TextBox With Top= 40, Left = 10, Visible=.F.
	Add Object Dayjobsline2 As TextBox With Top= 70, Left = 10, Visible=.F.
	Add Object Dayjobsline3 As TextBox With Top=110, Left = 10, Visible=.F.
	Add Object Dayjobsline4 As TextBox With Top=140, Left = 10, Visible=.F.
	Add Object Dayjobsline5 As TextBox With Top=170, Left = 10, Visible=.F.

	Procedure btnFillCustom.Click
		Select crsTest
		If Reccount() > 0
			AddProperty(Thisform, Textmerge('aRecords[<< RECCOUNT() >>]'))
			Scan
				Scatter Name Thisform.aRecords[RECNO()] Memo
				With Getpem(Thisform, 'Dayjobsline'+Ltrim(Str(Recno())))
					.ControlSource = Textmerge('(thisform.aRecords[<< RECNO() >>].Company)')
					.Visible=.T.
				Endwith
			ENDSCAN
			this.Enabled = .F.
		Endif
	Endproc
Enddefine
PS: A question would be, why not a grid.
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform