how to add only email adress in field and load it at startup

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

how to add only email adress in field and load it at startup

Post by sphere » Sat Sep 27, 2014 11:10 am

Hello,
thanks everyone for all these beautifull solutions we can find here.
So i'm new to Livecode, i have been busy with flowstone, but though there is Ruby in it, still you can't do all you want to do.
And this LiveCode seems easier than Ruby. But i'm stock with some questions, and i will not set them here all at once.
I searched a lot but can't find.

I have a simple input field. I can put in some text and when i push the button it is being saved to a local text file which i use as a kind of database (I don't want to use a real database on a server). So far so good.
Also new lines adding goes well. And reading the file in a scrolling field right after it has been saved also is working.

1. How do i get it that only email adresses can be added and nothing else?
This is the button script:

Code: Select all

on mouseUp
put field "New Email Adress" & cr before field "email list"
    put field "email list" into URL ( "file:" & specialFolderPath("Documents") & slash & "emailadresses.txt" )
end mouseUp

2. how should the script be in the stack to open the text file when starting? (the first time it does not exist of course, the text file is made after first input)
i have this but its not working

Code: Select all

if exist then put URL ( "file:" & specialFolderPath("Documents") & slash & "emailadresses.txt" ) into field "List of email addresses"
Thanks for any help on this :)

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: how to add only email adress in field and load it at sta

Post by sphere » Sat Sep 27, 2014 11:21 am

ok
first part i allready have (it was actually quite simple)
i added before the put lines this :

Code: Select all

if field "New Email Adress"contains "at blabla dot kom" then

and after the put lines this

Code: Select all

else answer "Only Email adresses ending on at blabla dot kom are allowed."

Klaus
Posts: 14208
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: how to add only email adress in field and load it at sta

Post by Klaus » Sat Sep 27, 2014 12:15 pm

Hi sphere,

1. welcome to the forum! :D

2. Do this:

Code: Select all

on openstack 
## or opencard
  ## Create the filename:
  put specialFolderPath("Documents") & "/emailadresses.txt" into tFile

  ## Now check its existence and act accordingly if present:
  if there is a file tFile then
    put url("file:" & tFile) into tMailAddresses
    ## Do something with tMailAddresses
  end if
end openstack
Check these great stacks to get the basics of Livecode:
http://www.hyperactivesw.com/revscriptc ... ences.html


Best

Klaus

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: how to add only email adress in field and load it at sta

Post by sphere » Sat Sep 27, 2014 2:13 pm

Hello Klaus,

Thanks for the Welcome !

I allready really love it to play and work with Livecode :D

I tested your code and changed to the actual names of the files and it runs perfectly ! Thanks very much.

Up to the next step. And if i can't figuring it out by altering some codes and examples i will search for it and alternatively create a new topic.

Thanks for helping me out.

zaxos
Posts: 222
Joined: Thu May 23, 2013 11:15 pm

Re: how to add only email adress in field and load it at sta

Post by zaxos » Mon Sep 29, 2014 3:49 pm

Code: Select all

on mouseUp
   if fld "New Email Adress" contains "@" then
      if the borderColor of fld "New Email Adress" is "red" then set the borderColor of fld "New Email Adress" to "0,0,0"
      put field "New Email Adress" & cr before field "email list"
   else
      set the borderColor of fld "New Email Adress" to "red"
   end if
end mouseUp
Knowledge is meant to be shared.

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: how to add only email adress in field and load it at sta

Post by sphere » Mon Sep 29, 2014 7:16 pm

Thanks Zaxos

also very nice!

thank you !

Post Reply