Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
lemodizon
- Posts: 219
- Joined: Thu Apr 05, 2018 3:33 pm
Post
by lemodizon » Sun Apr 07, 2019 10:34 am
Klaus,
i'm having a duplicate item every time i edit & save a certain item i want to edit only & save the edit item not to duplicate.thanks in advance
Code: Select all
on mouseUp
put fld "DateField" &TAB& the label of btn "ReasonMenu" &TAB& fld BadgeIDField &TAB& fld FullNameField &TAB& fld AssetTagField into tNewInputData
## Check if datagrid already has content:
put the dgtext of grp "DataGridLaptopList"of cd "RLMS-cd1" of stack "RLMS" into tOldData
## New and first entry:
if tOldData = EMPTY then
put tNewInputData into tOldData
else
// ## We ADD the data
put cr & tNewInputData after tOldData
end if
// ## Now set the new data:
// when i removed this script it won't duplicate but it will delete all other items.
set the dgtext of grp "DataGridLaptopList" of cd "RLMS-cd1" of stack "RLMS" to tOldData
end mouseUp
-
Attachments
-

Thank you & God Bless Everyone
Regards,
lemodizon
-
Klaus
- Posts: 14196
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Sun Apr 07, 2019 4:55 pm
AHA!
So you want to SAVE edited data back into the datagrid, sorry, did not understand this until now!

Do this:
Code: Select all
on mouseUp
## Fill this one according to what the user clicked:
## global edited_line
## Add these lines to your appropriate buttons:
## btn "Add" -> put EMPTY into edited_line
## btn "Edit" -> put the dghilitedlines of grp "your datagrid here" into edited_line
## So we know if we have to ADD a new entry or write back EDITED data
## into the original line of the datagrid -> edited_line
global edited_line
## Collect data first:
put fld "DateField" & TAB & the label of btn "ReasonMenu" & TAB & fld "BadgeIDField" &TAB & fld "FullNameField" & TAB & fld "AssetTagField" into tNewInputData
## Check if datagrid already has content:
put the dgtext of grp "DataGridLaptopList"of cd "RLMS-cd1" of stack "RLMS" into tOldData
if add_or_edit <> EMPTY then
## Write data back into original line = overwrite previous content!
put tNewInputData into line edited_line of tOldData
lock screen
set the dgtext of grp "DataGridLaptopList" of cd "RLMS-cd1" of stack "RLMS" to tOldData
## Restore hilitedline, always good style!
set the dghilitedlines of grp "DataGridLaptopList" of cd "RLMS-cd1" of stack "RLMS" to edited_line
unlock screen
## Done, so good-bye for now:
exit mouseup
end if
## We APPEND new data:
## New and first entry:
if tOldData = EMPTY then
put tNewInputData into tOldData
else
## We ADD the data
put cr & tNewInputData after tOldData
end if
## Now set the new data:
set the dgtext of grp "DataGridLaptopList" of cd "RLMS-cd1" of stack "RLMS" to tOldData
## Optional, hilite last = new line in datagrid:
set the dghilitedlines of grp "DataGridLaptopList" of cd "RLMS-cd1" of stack "RLMS" to (the num of lines of tOldData)
end mouseUp
Best
Klaus
-
Klaus
- Posts: 14196
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Sun Apr 07, 2019 5:17 pm
lemodizon wrote: ↑Sun Apr 07, 2019 10:34 am
i'm having a duplicate item every time i edit & save a certain item i want to edit only & save the edit item not to duplicate.
I hope you now know WHY this has happend!
P.S.
You can now also use this global variable in the "preopenstack" handler in your EDIT stack
to either EMPTY or fill all your fields and set hilites of your checkboxes. Know what I mean?
-
lemodizon
- Posts: 219
- Joined: Thu Apr 05, 2018 3:33 pm
Post
by lemodizon » Mon Apr 15, 2019 3:52 am
Thanks Klaus this is now working, i want to try this script code i found. i want to use it as my temporary storage. but i want to save the text file in network folder is that possible?
Code: Select all
on preopenstack
local tFilePath
put specialfolderpath("Documents") & "/ListofLaptops.txt" into tFilePath
set the text of fld "tasks" to url ("file:" & tFilePath)
end preopenstack
Thank you & God Bless Everyone
Regards,
lemodizon
-
Klaus
- Posts: 14196
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Mon Apr 15, 2019 11:21 am
What is "network folder"? Mobile or Desktop?
If LC provides a specialfolderpath() for this then yes.
-
lemodizon
- Posts: 219
- Joined: Thu Apr 05, 2018 3:33 pm
Post
by lemodizon » Mon Apr 15, 2019 5:23 pm
Sorry Klaus, What i mean is if i can use this script code to save the text file in other computer (via network) or a server? instead saving the text file to my computer using this specialfolderpath("Documents") if i want to save it in other computer documents the script code
Code: Select all
specialfolderpath("Documents")& "\\computer1\document\ListofLaptops.txt into tFilePath
is this right in saving a text file from other computer?
Thank you & God Bless Everyone
Regards,
lemodizon
-
Klaus
- Posts: 14196
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Mon Apr 15, 2019 5:46 pm
Hi Lemuel,
lemodizon wrote: ↑Mon Apr 15, 2019 5:23 pm
Code: Select all
specialfolderpath("Documents")& "\\computer1\document\ListofLaptops.txt into tFilePath
is this right in saving a text file from other computer?
No, leave out the specdialfolderpath() and try again!
Code: Select all
put "//computer1/document/ListofLaptops.txt" into tFilePath
No idea if that works. Best is to use LC to show you the correct path to a file on hte network.
Create a button with this script:
Code: Select all
on mouseup
answer file "Please select a file on the network!"
## Select ANY file on the other machine in the network
## where you want to write your LapTopList to
put it
end mouseup
Then the path to the selected file will be shown in the message box and you can check if your example path is correct -> //computer1/document/...
Know what I mean? Network pathnames can be tricky.
specialfolderpath("Documents") points to the HOME folder of the current user, so you cannot append a network pathname to it!?
Best
Klaus
-
bogs
- Posts: 5480
- Joined: Sat Feb 25, 2017 10:45 pm
Post
by bogs » Mon Apr 15, 2019 6:12 pm
Klaus wrote: ↑Mon Apr 15, 2019 5:46 pm
specialfolderpath("Documents") points to the HOME folder of the current user, so you cannot append a network pathname to it!?
lemodizon wrote: ↑Mon Apr 15, 2019 5:23 pm
specialfolderpath("Documents")& "\\computer1\document\ListofLaptops.txt" into tFilePath
What it looks like from here is that he is trying to put addresses to other computers that are in a text file that is located in the documents folder into the path, not use the documents folder itself per se.
-
lemodizon
- Posts: 219
- Joined: Thu Apr 05, 2018 3:33 pm
Post
by lemodizon » Wed Apr 17, 2019 3:38 am
Thanks Klaus i will try it, i found a script for "Find/Search" in this forum i tried it already and it works but i noticed that it will search everything in my datagrid. i want to search/find only the asset tag under my datagrid.
Code: Select all
on keyup
put me into tSearchString
put the dgtext of grp "DataGridLaptopList"of cd "RLMS-cd1" of stack "RLMS" into tOldData
filter tOldData with ("*" & tSearchString & "*")
if tOldData = empty then
beep
answer "no data found!"
exit to top
else
## We found something, so lets display the results:
set the dgtext of grp "DataGridLaptopList" of cd "RLMS-cd1" of stack "RLMS" to tOldData
end if
end keyup
on textChanged
if return is among the characters of me then replace return with space in me
end textChanged
Klaus, this works. what is the script to display all the data in my data grid again coz every time i search all the data from the data grid are gone.
-
Attachments
-

- search.PNG (1.43 KiB) Viewed 4339 times
Thank you & God Bless Everyone
Regards,
lemodizon