Array of Commands...

Hi Folks,

the following code will give as output the received sms:


set xstr to "at+cmgf=1" & return
		serialport write xstr to dial
		delay 2
		set xstr to "at+cmgr=3" & return
		serialport write xstr to dial
		delay 2

output:

+CMGR: “REC UNREAD”,“+4367682007038”,“06/12/02,14:38:25+04”
Das ist eine lange testnachricht… Ein kleiner test mal sehen wie das aussieht

I am looking for a way to make an array to first check at+cmgr=1 then at+cmgr=2,… as long as the result contains “OK”

Has anybody a clue on how to do that?

Thanks for your feedback!

Stefan

Using what osax? It’s not dialModemOSAX.

Hi Adam,

its serialport X osax!

thanks and best regards,

Stefan

dial is not defined in your scriptlet

Hi Adam,

I know that I am not able to dial, I just want to write and read text messages with it - writing sms is easy, and receiving also, but I want to have the received messages in a loop - so every text message on the simcard will be presenting in a text field…


	if dial is equal to -1 then
		display dialog " could not open port "
	else
		
		set xstr to "at+cmgf=1" & return
		serialport write xstr to dial
		delay 1
		set theNumber to 0
		repeat until read_numb does not contain "+"
			set xstr to "at+cmgr=" & theNumber & return
			serialport write xstr to dial
			delay 1
			(*
		set xstr to "at+cnmi=2,1,0,0,1" & return
		serialport write xstr to dial
		delay 2
		*)
			set theNumber to theNumber + 1
			set read_numb to serialport read dial
		end repeat
		
	end if
	serialport close dial
	set contents of text view "text" of scroll view "text" of window id 1 to read_numb


This is not working, but it shouldn´t be so different from that…

Thanks for your help and best regards,

Stefan

First step done:


if dial is equal to -1 then
		display dialog " could not open port "
	else
		
		set xstr to "at+cmgf=1" & return
		serialport write xstr to dial
		delay 1
		set xstr to "at+cnmi=2,1,0,0,1" & return
		serialport write xstr to dial
		delay 1
		set read_numb1 to serialport read dial
		set theNumber to 0
		repeat with i from 0 to 20
			set xstr to "at+cmgr=" & theNumber & return
			serialport write xstr to dial
			delay 1
			set theNumber to theNumber + 1
			set read_numb to serialport read dial
			set contents of text view "text" of scroll view "text" of window id 1 to read_numb
		end repeat
	end if
	serialport close dial

This is a loop from 0 to 20 presenting the output every second! The thing I know need is how to store the output in a variable which can not be overwritten and how to present the variable one after the other…

Background: this loop is presenting text messages of cell phones using osax serialport x!

Thanks for your suggestions…

Stefan