datagrid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
datagrid
I can't get enough of Licecode, unless a wooden head.
What's now wrong in this button (copied from the tutorial)
on mouseUp
## Create tab delimited data.
##Note that first line has name of columns.
## Providing names tells Data Grid how to map
## data to appropriate columns.
put "naam" & tab & "adres" & "pc plaats"& cr & \
"ALBADA VAN, A." & tab & "Henricus Muntinghlaan 51" & "9751 PV,HAREN" &cr & \
"ALBERTS, E.J." & tab & "Westerveen 39" &",9745 HT,HAREN" &cr & \
"ALBERTS, J." & tab &"Westerveen 39" &"9751 HV,HAREN" &cr & \
"ALEKSANDER," & tab &"Woortsmandijk 1" &"9608 PK,WESTERBROEK"& cr & \
"ANDERZORG," & tab & "Postbus 1177" &"7500 BD,ENSCHEDE" &cr & \
"BEREGENING, DE BOER" & tab & "Scheiding 12" & tab &"9231 ANSurhuisterveen" into field "adres"
## Let Data Grid know that first line has column names
##put true into firstLineContainsColumnNames
##set the dgText [ firstLineContainsColumnNames ] of group "adres" to theText
end mouseUp
Why is "into the text not accepted? The field is named "adres"
What to do with this:
## Let Data Grid know that first line has column names
put true into firstLineContainsColumnNames
set the dgText [ firstLineContainsColumnNames ] of group "DataGrid" to theText
Where do I find "firstLineContainsColumnNames"
Did "datagrid to be changed for "adres"?
What's now wrong in this button (copied from the tutorial)
on mouseUp
## Create tab delimited data.
##Note that first line has name of columns.
## Providing names tells Data Grid how to map
## data to appropriate columns.
put "naam" & tab & "adres" & "pc plaats"& cr & \
"ALBADA VAN, A." & tab & "Henricus Muntinghlaan 51" & "9751 PV,HAREN" &cr & \
"ALBERTS, E.J." & tab & "Westerveen 39" &",9745 HT,HAREN" &cr & \
"ALBERTS, J." & tab &"Westerveen 39" &"9751 HV,HAREN" &cr & \
"ALEKSANDER," & tab &"Woortsmandijk 1" &"9608 PK,WESTERBROEK"& cr & \
"ANDERZORG," & tab & "Postbus 1177" &"7500 BD,ENSCHEDE" &cr & \
"BEREGENING, DE BOER" & tab & "Scheiding 12" & tab &"9231 ANSurhuisterveen" into field "adres"
## Let Data Grid know that first line has column names
##put true into firstLineContainsColumnNames
##set the dgText [ firstLineContainsColumnNames ] of group "adres" to theText
end mouseUp
Why is "into the text not accepted? The field is named "adres"
What to do with this:
## Let Data Grid know that first line has column names
put true into firstLineContainsColumnNames
set the dgText [ firstLineContainsColumnNames ] of group "DataGrid" to theText
Where do I find "firstLineContainsColumnNames"
Did "datagrid to be changed for "adres"?
Re: datagrid
Dag Rob,
1. you only create 2 columns in your script!
...
put "naam" & tab & "adres" & "pc plaats"
## Missing TAB after "adres"!
...
Is that what you want?
Or do you mean:
..
put "naam" & tab & "adres" & TAB & "pc plaats"
...
In that case you need to add some TABs to your script.
2. The extra parameter:
set the dgText [ firstLineContainsColumnNames ] ...
is only neccessary, if the itemdelimited data are NOT in the order as the columns in your datagrid!
That way it is made sure that the data will get put into the correct columns.
So if the columns in your datagfrid are:
1. naam
2. adres
3 pc plaats
You do not need that parameter, simple omit it:
...
set the dgtext of grp XYZ to THEDATA
...
and also leave out your first line!
...
## put "naam" & TAB & "adres"...
...
3. You set the DGTEXT of your datagrid group, whatever its name is.
Best
Klaus
1. you only create 2 columns in your script!
...
put "naam" & tab & "adres" & "pc plaats"
## Missing TAB after "adres"!
...
Is that what you want?
Or do you mean:
..
put "naam" & tab & "adres" & TAB & "pc plaats"
...
In that case you need to add some TABs to your script.
2. The extra parameter:
set the dgText [ firstLineContainsColumnNames ] ...
is only neccessary, if the itemdelimited data are NOT in the order as the columns in your datagrid!
That way it is made sure that the data will get put into the correct columns.
So if the columns in your datagfrid are:
1. naam
2. adres
3 pc plaats
You do not need that parameter, simple omit it:
...
set the dgtext of grp XYZ to THEDATA
...
and also leave out your first line!
...
## put "naam" & TAB & "adres"...
...
3. You set the DGTEXT of your datagrid group, whatever its name is.
Best
Klaus
Re: datagrid
Hi Klaus,
I have send a wrong script. See the actual scipt here, where that line seems to be correct.
on mouseUp
put "naam" & tab & "adres" &tab& "pcplaats"& cr & \
"ALBADA VAN, A." & tab & "Henricus Muntinghlaan 51" & "9751 PV,HAREN" &cr & \
"ALBERTS, E.J." & tab & "Westerveen 39" &",9745 HT,HAREN" &cr & \
"ALBERTS, J." & tab &"Westerveen 39" &"9751 HV,HAREN" &cr & \
"ALEKSANDER," & tab &"Woortsmandijk 1" &"9608 PK,WESTERBROEK"& cr & \
"ANDERZORG," & tab & "Postbus 1177" &"7500 BD,ENSCHEDE" &cr & \
"AULT, L." & tab & "Gran Sol,0317 0" &"CALPE,Spanje" &cr & \
"BAKKER-KRAGTEN, H." & tab &"Benschopperweg 386" &"IJsselstein" &cr & \
"BARKMEIJER, H." & tab&"Hugo de Vriesweg 12" &"Haren" &cr & \
"BEKKERING-BROUWER, A." & tab &"v.Ketwich Verschuurlaan 25" &"Groningen" &cr & \
"BELASTINGDIENST NOORD," & tab &"Pb 418" &"Groningen" &cr & \
"BELASTINGDIENST, centrale administratie" & tab &"centrale administratie" &"Groningen" &cr & \
"BEREGENING, DE BOER" & tab & "Scheiding 12" & tab &"9231 AN Surhuisterveen" into field "DataGrid" --> compilation error at line 14 (Chunk: can't create a variable with that name (explicitVariables?)) near "table", char 93
end mouseUp
I have send a wrong script. See the actual scipt here, where that line seems to be correct.
on mouseUp
put "naam" & tab & "adres" &tab& "pcplaats"& cr & \
"ALBADA VAN, A." & tab & "Henricus Muntinghlaan 51" & "9751 PV,HAREN" &cr & \
"ALBERTS, E.J." & tab & "Westerveen 39" &",9745 HT,HAREN" &cr & \
"ALBERTS, J." & tab &"Westerveen 39" &"9751 HV,HAREN" &cr & \
"ALEKSANDER," & tab &"Woortsmandijk 1" &"9608 PK,WESTERBROEK"& cr & \
"ANDERZORG," & tab & "Postbus 1177" &"7500 BD,ENSCHEDE" &cr & \
"AULT, L." & tab & "Gran Sol,0317 0" &"CALPE,Spanje" &cr & \
"BAKKER-KRAGTEN, H." & tab &"Benschopperweg 386" &"IJsselstein" &cr & \
"BARKMEIJER, H." & tab&"Hugo de Vriesweg 12" &"Haren" &cr & \
"BEKKERING-BROUWER, A." & tab &"v.Ketwich Verschuurlaan 25" &"Groningen" &cr & \
"BELASTINGDIENST NOORD," & tab &"Pb 418" &"Groningen" &cr & \
"BELASTINGDIENST, centrale administratie" & tab &"centrale administratie" &"Groningen" &cr & \
"BEREGENING, DE BOER" & tab & "Scheiding 12" & tab &"9231 AN Surhuisterveen" into field "DataGrid" --> compilation error at line 14 (Chunk: can't create a variable with that name (explicitVariables?)) near "table", char 93
end mouseUp
Re: datagrid
Again I have send a wrong script; here the real actual one:
on mouseUp
put "naam" & tab & "adres" &tab& "pcplaats"& cr & \
"ALBADA VAN, A." & tab & "Henricus Muntinghlaan 51" & "9751 PV,HAREN" &cr & \
"ALBERTS, E.J." & tab & "Westerveen 39" &",9745 HT,HAREN" &cr & \
"ALBERTS, J." & tab &"Westerveen 39" &"9751 HV,HAREN" &cr & \
"ALEKSANDER," & tab &"Woortsmandijk 1" &"9608 PK,WESTERBROEK"& cr & \
"ANDERZORG," & tab & "Postbus 1177" &"7500 BD,ENSCHEDE" &cr & \
"AULT, L." & tab & "Gran Sol,0317 0" &"CALPE,Spanje" &cr & \
"BAKKER-KRAGTEN, H." & tab &"Benschopperweg 386" &"IJselstein" &cr & \
"BARKMEIJER, H." & tab&"Hugo de Vriesweg 12" &"Haren" &cr & \
"BEKKERING-BROUWER, A." & tab &"v.Ketwich Verschuurlaan 25" &"Groningen" &cr & \
"BELASTINGDIENST NOORD," & tab &"Pb 418" &"Groningen" &cr & \
"BELASTINGDIENST, centrale administratie" & tab &"centrale administratie" &"Groningen" &cr & \
"BEREGENING, DE BOER" & tab & "Scheiding 12" & tab &"9231 AN Surhuisterveen" into field "adres"
end mouseUp
execution error at line 14 (Chunk: no such object) near "adres", char 93: --> (the datagridfield is named "adres")
on mouseUp
put "naam" & tab & "adres" &tab& "pcplaats"& cr & \
"ALBADA VAN, A." & tab & "Henricus Muntinghlaan 51" & "9751 PV,HAREN" &cr & \
"ALBERTS, E.J." & tab & "Westerveen 39" &",9745 HT,HAREN" &cr & \
"ALBERTS, J." & tab &"Westerveen 39" &"9751 HV,HAREN" &cr & \
"ALEKSANDER," & tab &"Woortsmandijk 1" &"9608 PK,WESTERBROEK"& cr & \
"ANDERZORG," & tab & "Postbus 1177" &"7500 BD,ENSCHEDE" &cr & \
"AULT, L." & tab & "Gran Sol,0317 0" &"CALPE,Spanje" &cr & \
"BAKKER-KRAGTEN, H." & tab &"Benschopperweg 386" &"IJselstein" &cr & \
"BARKMEIJER, H." & tab&"Hugo de Vriesweg 12" &"Haren" &cr & \
"BEKKERING-BROUWER, A." & tab &"v.Ketwich Verschuurlaan 25" &"Groningen" &cr & \
"BELASTINGDIENST NOORD," & tab &"Pb 418" &"Groningen" &cr & \
"BELASTINGDIENST, centrale administratie" & tab &"centrale administratie" &"Groningen" &cr & \
"BEREGENING, DE BOER" & tab & "Scheiding 12" & tab &"9231 AN Surhuisterveen" into field "adres"
end mouseUp
execution error at line 14 (Chunk: no such object) near "adres", char 93: --> (the datagridfield is named "adres")
Re: datagrid

1. You need to add TABs to your data if your have THREE columns in your datagrid!
Code: Select all
on mouseUp
put "naam" & tab & "adres" &tab& "pcplaats"& cr & \
"ALBADA VAN, A." & tab & "Henricus Muntinghlaan 51" & TAB & "9751 PV,HAREN" &cr & \
###etc...
Code: Select all
on mouseUp
put "naam" & tab & "adres" &tab& "pcplaats"& cr & \
"ALBADA VAN, A." & tab & "Henricus Muntinghlaan 51" & TAB & "9751 PV,HAREN" &cr & \
##...
"BEREGENING, DE BOER" & tab & "Scheiding 12" & TAB &"9231 AN Surhuisterveen" into MyData

So set the dgtext of your datagrid, which is a GROUP!, to that variable...
Code: Select all
...
set the dgtext of grp "adres" to MyData
end mouseUp
Klaus
Re: datagrid
I left the datagrid behind me and changed for a textfield'Klaus: 2. You should put the data into a variable first...
What's wrong with this script:
on mouseUp
put "Naam"&","&& fld "adres"&","&&fld "pcplaats" into tLine
if fld "DB1" of cd "DB" is not empty then
put cr&tLine after fld "DB1" of cd "DB"
else
put tLine into fld "DB1" of cd "DB"
end if
end mouseUp
compilation error at line 2 (Chunk: can't create a variable with that name (explicitVariables?)) near "tLine", char 58
I have set the explicitVariables to true, but don't understand its relation with tLine
THANKS
Re: datagrid
Hi Rob,
if you set explicit variables to true you have to declare variables explicitely (hence the name) before you use them.
This means that if you want to use a variable tLine you first before you use it in your script have to
then it works. If you turn explicit variables off your original would work.
from the User Guide
5.10Tips for Writing Good Code
5.5 Variables
in the User Guide
Kind regards
Bernd
if you set explicit variables to true you have to declare variables explicitely (hence the name) before you use them.
This means that if you want to use a variable tLine you first before you use it in your script have to
Code: Select all
on mouseUp
local tLine -- here you declare the variable tLine
put "Naam"&","&& fld "adres"&","&&fld "pcplaats" into tLine
from the User Guide
5.10Tips for Writing Good Code
You might also want to have a look atExplicit Variables
If you're working on a larger code base you may want to turn on the Variable Checking option in the Script menu of the Code Editor. This makes LiveCode require that you declare all variables (even script locals) before you can compile your script. It also requires you to place all literal strings in quotes. This method of coding can help you to quickly track down errors as you go by making you think a little about what variables you are going to use at an early stage, and pointing out spelling mistakes.
What's most important is that you develop your own consistent style and then stick to it. Once you have been applying some of these techniques for a short time, they will become second nature.
For a more in-depth look at this subject, we recommend Fourth World's Scripting Style Guide at:
http://www.fourthworld.com/embassy/arti ... style.html
5.5 Variables
in the User Guide
Kind regards
Bernd