Hi Folks,
may you can help me with the following:
in my application I have 3 text files - and one destination file:
apn_at.txt
apn_de.txt
apn_uk.txt
if a “if Clause” is true the file p.ex. apn_at.txt has to copied to the destination file: apn_mac.txt
here is my code so far:
-- Imsi holen
repeat
set xstr to "at+CIMI" & return
serialport write xstr to portRef
delay 1
set imsi to serialport read portRef
display dialog imsi
delay 1
set imsi to characters 11 thru 15 of imsi as string
display dialog imsi
if imsi is "23203" then
display dialog "T-Mobile A"
set apncheck to "1"
exit repeat
else if imsi is "26201" then
display dialog "T-Mobile D"
set apncheck to "2"
exit repeat
else if imsi is "23432" then
display dialog "T-Mobile UK"
set apncheck to "3"
exit repeat
end if
end repeat
-- Land setzen:
set fileToCheck to ((path to me as Unicode text) & "Contents:Resources:apn_mac.txt")
repeat
tell application "Finder" to set nofile to (not (exists file fileToCheck))
tell application "Finder" to set yesfile to (exists file fileToCheck)
if yesfile then exit repeat
if nofile then
display dialog "hier"
display dialog apncheck
try
if apncheck is "1" then
display dialog "da"
set dest to ((path to me as Unicode text) & "Contents:Resources:apn_at.txt")
set source to ((path to me as Unicode text) & "Contents:Resources:apn_mac.txt")
do shell script "cp dest source"
set run_file to "1"
exit repeat
else if apncheck is "2" then
tell application "Finder"
duplicate alias ((path to me as Unicode text) & "Contents:Resources:apn_de.txt") to alias ((path to me as Unicode text) & "Contents:Resources:apn_mac.txt")
end tell
exit repeat
else if apncheck is "3" then
tell application "Finder"
duplicate alias ((path to me as Unicode text) & "Contents:Resources:apn_uk.txt") to alias ((path to me as Unicode text) & "Contents:Resources:apn_mac.txt")
end tell
exit repeat
end if
end try
end if
if run_file is "1" then exit repeat
end repeat
--APN holen
delete every menu item of menu of popup button "apnlist" of drawer "Setting" of window "main"
set file_path to ((path to me as string) & "Contents:Resources:apn_mac.txt") as file specification
set read_data to paragraphs of (read file_path)
repeat with i from 1 to (length of read_data)
set current_item to (item i of read_data) as string
make new menu item at end of menu of popup button "apnlist" of drawer "Setting" of window "main" with properties {title:current_item, enabled:true}
end repeat
set apn_file to ((path to me as Unicode text) & "Contents:Resources:apn.txt") as file specification
set apn to read apn_file as string
set contents of text field "useapn" of drawer "Setting" of window "main" to apn
May you can help me solving this issue, because in this code the duplication will not work…
It is also funny, that even if apncheck is “1” I am not able to get out of the Repeat Loop…
Thanks for any help!
Stefan