
-----------------------------------
renaissance
Wed Jan 23, 2008 9:07 pm

[RESUEST HELP]: How to run a turing program from a turing program?
-----------------------------------
How would I run a turing program from a turing program?

Anyone know? 

Thanks, renaissance.

-----------------------------------
ericfourfour
Wed Jan 23, 2008 9:23 pm

RE:[RESUEST HELP]: How to run a turing program from a turing program?
-----------------------------------
You can compile one and run it using Sys.Exec. Really, you should not have to run a Turing program from another one. Try to combine both source files into one. There is always the include command that can help you with this.

-----------------------------------
Clayton
Wed Jan 23, 2008 9:23 pm

RE:[RESUEST HELP]: How to run a turing program from a turing program?
-----------------------------------
You'll have to compile the program that you want to run, and then do some Sys.Exec() shenanigans to accomplish what you want to do.

-----------------------------------
renaissance
Wed Jan 23, 2008 10:17 pm

RE:[RESUEST HELP]: How to run a turing program from a turing program?
-----------------------------------
Also...I've a question.

How would I error trap a user to entering a 10 digit phone number?

Here's my code so far: 

            put "Enter phone number (10 digits and numbers only)."

            loop
                flag := false
                loop
                    get phoneNum : *
                    for decreasing i : length (phoneNum) .. 1
                        pattern:=index (nums, phoneNum (i))
                        if pattern>=1 then
                            flag := true
                        end if
                    end for
                    exit when flag=true
                    put "Enter a valid phone number (10 digits and numbers only)."
                end loop
                
                exit when length (phoneNum) = 10
                put "Enter a valid phone number (10 digits and numbers only)."
            end loop


Does not quite work yet though :i...

nums:="1234567890"

Thanks, renaissance

-----------------------------------
syntax_error
Wed Jan 23, 2008 10:34 pm

Re: [RESUEST HELP]: How to run a turing program from a turing program?
-----------------------------------
first please use code tags next time but as for your question in turing isnt there a syntax length(?) jsut look in the help

and then check if the length of the string is == to 10 if yes then use strint to make it a int if you need to use it as a int...

-----------------------------------
renaissance
Wed Jan 23, 2008 10:54 pm

RE:[RESUEST HELP]: How to run a turing program from a turing program?
-----------------------------------
Okay...

so...would this work?

I ask for the phone number AS AN INT...make sure it is 10 digits...if it is...then I'll use the intstr command?
Would that work?

Syntax   intstr ( i : int [ , width : int [ , base : int ] ] ) : string
 
Their examples don't really help much.

What I want accomplished in the end is:

User enters a number..like "5192223333" as  a integer.
Then using the instr command, it'll convert it to a string as still "5192223333"? 

Thanks, renaissance.

-----------------------------------
Nick
Wed Jan 23, 2008 10:58 pm

RE:[RESUEST HELP]: How to run a turing program from a turing program?
-----------------------------------
for converting from int to string use strint instead

-----------------------------------
renaissance
Wed Jan 23, 2008 11:03 pm

RE:[RESUEST HELP]: How to run a turing program from a turing program?
-----------------------------------
I'm so lost here...so if I were to use strint...could anyone show me an example of it in use? 

Thanks, renaissance.

-----------------------------------
Gooie
Wed Jan 23, 2008 11:17 pm

RE:[RESUEST HELP]: How to run a turing program from a turing program?
-----------------------------------
Just place the variable in the parameter of 'strint'.

Draw.Text (strint (40), 100, 100, font)


That will draw the text "40". Of course 40 can be replaced with a variable.

-----------------------------------
renaissance
Wed Jan 23, 2008 11:30 pm

RE:[RESUEST HELP]: How to run a turing program from a turing program?
-----------------------------------
Blah...I don't understand this strint command so I won't use it.

So...back to sq. 1. 


put "Enter phone number (10 digits and numbers only)."

            loop
                flag := true

                loop
                    get phoneNum : *
                    for decreasing i : length (phoneNum) .. 1

                        pattern:=index (phoneNum(i), nums)
                        if pattern>=1 then
                            flag := false
                        end if
                    end for
                    exit when flag=true
                    put "Enter a valid phone number (10 digits and numbers only)."
                end loop
                
                exit when length (phoneNum) = 10
                put "Enter a valid phone number (10 digits and numbers only)."
            end loop


Any tips on making this ensure that the phone numbered entered is numbers?

nums:="1234567890"

-----------------------------------
Clayton
Wed Jan 23, 2008 11:32 pm

RE:[RESUEST HELP]: How to run a turing program from a turing program?
-----------------------------------
use strintok()
