Help cant assign value to variable for weird reason : /
Author |
Message |
Al_
|
Posted: Mon Jan 26, 2009 10:58 pm Post subject: Help cant assign value to variable for weird reason : / |
|
|
Hi there : )
Im having a problem : (
I decided to make a program that will act as command prompt (I know seems pointless)
and i need YOUR help.
Heres the code:
code: | var spoken, commandType : string
var choice : int
procedure SetupOpen %Setup for opening
if spoken = "MS Word" or spoken = "Microsoft word" or spoken = "Microsoft Word" then
cls
choice := 1
put "Opening Microsoft Word ..."
delay(1000)
elsif spoken = "MS Excel" or spoken = "Microsoft excel" or spoken = "Microsoft Excel" then
cls
choice := 2
put "Opening Microsoft Excel ..."
end if
end SetupOpen
procedure Open
var choice2, success : int
var command : string
case choice of
label 1 : command := "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Microsoft Word.lnk"
label 2 : command := "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Microsoft Excel.lnk"
label : put "Not Available"
assert false
end case
system ("chain:" + command, success)
put "System called failed."
put "Program \"", command, "\" couldn't be run."
assert false
end Open
loop
put "Your Command Type:" ..
get commandType
if commandType = "Open" or commandType = "open" then
cls
put "State the program you wish to open: " ..
get spoken
SetupOpen
Open
delay (500)
cls
end if
end loop
|
The error is: "Variable has no Value"
My question: Why?? : / plz help
Al
.
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
TheGuardian001
|
Posted: Tue Jan 27, 2009 12:08 am Post subject: Re: Help cant assign value to variable for weird reason : / |
|
|
For the exact reason it said. you never assigned a value to choice, the reason being that the if statement where you set choice is always ignored.
Turing: |
if commandType = "Open" or commandType = "open" then
cls
put "State the program you wish to open: " ..
get spoken
|
The problem is your get statement. The get command, by default, stops reading input when it sees either a space or an enter Character. This can be overridden by using
Turing: |
get variableName :*
|
Where variableName is the name of your variable. Turing by default will stop reading input after a space. :* overrides this, allowing more than 1 word to be entered.
so many edits... stupid new keyboard layout...
|
|
|
|
|
|
Al_
|
Posted: Tue Jan 27, 2009 12:19 am Post subject: Re: Help cant assign value to variable for weird reason : / |
|
|
tytytytytytytytytytytytytytytytytytytytytytytytytytytytytytytyty
: )
Now to fix my next problem: .lnk doesnt work : ( ill have to go .exe hunting : ) YAY!!! :D
EDIT:
: ( I cant figure it out
I tried using the following code to open up Microsoft Visio
code: | label 2 : command := "C:\\Program Files/Microsoft Office/Visio10/Visio.exe" |
I also tried:
code: | label 2 : command := "C:\\Program Files\\Microsoft Office\\Visio10\\Visio.exe" |
But no luck!
Is it because I Turing won't open Visio.exe or rather because of some of the reason??
|
|
|
|
|
|
DemonWasp
|
Posted: Tue Jan 27, 2009 9:10 am Post subject: RE:Help cant assign value to variable for weird reason : / |
|
|
Turing is pretty old, so it may be expecting shorter filenames. Windows (and DOS before it) used to operate on an 8.3 naming convention; names longer than that have a way of being truncated. Perhaps trying that would help.
To determine a directory's truncated name, open a command prompt and navigate to the parent directory, then do dir /X . You should find something like PROGRA~1 next to "Program Files". Try substituting that for "Program Files", and whatever the equivalent is for "Microsoft Office".
|
|
|
|
|
|
Al_
|
Posted: Tue Jan 27, 2009 12:10 pm Post subject: RE:Help cant assign value to variable for weird reason : / |
|
|
Ok trying that.
I opened Command and typed in cd c:\
typed dir
and Program Files shows up as "Program Files"
How do i mount program files onto the current directory? (Sorry havent used cmd in a while)
but as for you theory it doesnt seem to apply to my cmd : (
Any other ideas?
I copied the code from the turing help and altered it to get what you see above.
Theoretically it should work right?
My problem now is that it jumps straight to
code: | label : put "Not Available"
assert false
|
: (
Thx ahead of time
Al
.
|
|
|
|
|
|
Al_
|
Posted: Tue Jan 27, 2009 12:18 pm Post subject: RE:Help cant assign value to variable for weird reason : / |
|
|
AHAHAHA ::: ))))
I got it working only problem is the program wont open
The problem was, or i thought was:
Since the code below was in a process, it would read and execute it when the case finished regardless.
code: | system ("chain:" + command, success)
put "System called failed."
put "Program \"", command, "\" couldn't be run."
assert false
|
Ok so the loop works now. But why wont the program open?
Does something restrict turing's access to my system?
Any ideas? Meanwhile ill try generating a stand alone, see if that works.
Edit: K that doesnt work : (
Edit_2: K basically I want to know if there's any way to run an executable file from Turing
k i got it to work ill keep working at it : ) Thx for the help!!!
|
|
|
|
|
|
DemonWasp
|
Posted: Tue Jan 27, 2009 1:47 pm Post subject: RE:Help cant assign value to variable for weird reason : / |
|
|
Running the executable should work. You missed the /X in the command:
That's a special flag that tells it you want to see the PROGRA~1 nonsense alongside the rest of the output. After replacing, you should have something LIKE BUT NOT THE SAME AS:
code: |
command := "C:\\PROGRA~1\\MICROSO~1\\Visio10\\Visio.exe"
|
|
|
|
|
|
|
Al_
|
Posted: Tue Jan 27, 2009 4:41 pm Post subject: Re: Help cant assign value to variable for weird reason : / |
|
|
okay so I did a little more research and then re-engineered my program to look like this: (i found a way to make it easier to read : ) syntax="Turing, who knew lol)
Turing: | var winID : int
winID := Window.Open ("position:300;300,graphics:600;50")
var spoken, commandType, confirm : string
var Exit : int := 0
procedure SetupOpen
if spoken = "MS Word" or spoken = "Microsoft word" or spoken = "Microsoft Word" or spoken = "Word" or spoken = "word" then
cls
put "Please confirm:"
put "You wish to open Microsoft Word"
put "Confirmation: " ..
get confirm
if confirm = "Yes" or confirm = "yes" or confirm = "Yes" or confirm = "confirmed" or confirm = "Confirmed" or confirm = "confirm" or confirm = "Confirm" or confirm = "indeed" or confirm =
"Indeed" or confirm = "correct" or confirm = "Correct" then
cls
put "Opening Microsoft Word ..."
if not Sys.Exec ("C:\\ProgramData/Microsoft/Windows/Start Menu/Programs/Microsoft Word.lnk") then
put "Error! Program will not execute"
end if
delay (4000)
elsif confirm = "no" or confirm = "No" or confirm = "disconfirmed" or confirm = "Disconfirmed" then
cls
put "Access Unapproved"
delay (4000)
end if
%MS Visio
elsif spoken = "Microsoft Visio" or spoken = "Visio" or spoken = "visio" or spoken = "NS Visio" or spoken = "MS Visio" then
cls
put "Please confirm:"
put "You wish to open Microsoft Visio"
put "Confirmation: " ..
get confirm
if confirm = "Yes" or confirm = "yes" or confirm = "Yes" or confirm = "confirmed" or confirm = "Confirmed" or confirm = "confirm" or confirm = "Confirm" or confirm = "indeed" or confirm =
"Indeed" or confirm = "correct" or confirm = "Correct" then
cls
put "Opening Microsoft Visio ..."
if not Sys.Exec ("C:\\PROGRA~1\\MICROSO~1\\Visio10\\Visio.exe") then
put "Error! Program will not execute"
end if
delay (4000)
elsif confirm = "no" or confirm = "No" or confirm = "disconfirmed" or confirm = "Disconfirmed" then
cls
put "Access Unapproved"
delay (4000)
end if
%Password.exe
elsif spoken = "password" or spoken = "Password" or spoken = "password program" or spoken = "Password program" or spoken = "password Program" or spoken = "Password Program" then
cls
put "Please confirm:"
put "You wish to open Password.exe"
put "Confirmation: " ..
get confirm
if confirm = "Yes" or confirm = "yes" or confirm = "Yes" or confirm = "confirmed" or confirm = "Confirmed" or confirm = "confirm" or confirm = "Confirm" or confirm = "indeed" or confirm =
"Indeed" or confirm = "correct" or confirm = "Correct" then
cls
put "Opening Password program..."
if not Sys.Exec ("C:\\Users\\admin\\Desktop\\Programming\\Voice_Req\\Password.exe") then
put "Error! Program will not execute"
end if
delay (4000)
elsif confirm = "no" or confirm = "No" or confirm = "disconfirmed" or confirm = "Disconfirmed" then
cls
put "Access Unapproved"
delay (4000)
end if
else
put "Program is not within our records."
delay (4000)
end if
end SetupOpen
loop
cls
put "Your Command Type: " ..
get commandType
if commandType = "Open" or commandType = "open" then
cls
put "State the program you wish to open: " ..
get spoken : *
SetupOpen
delay (500)
cls
elsif commandType = "close" or commandType = "Close" or commandType = "Exit" or commandType = "exit" then
Exit := 1
end if
exit when Exit = 1
end loop
Window.Close (winID )
|
My problem now is that I can't find the direct path to Microsoft Visio, Word, excel, access, whatever else.
I am running windows visa. Please help!!
If you know a method or some code which would automatically look throughout the computer's C Drive and locate certain files with extensions such as Microsoft Word.exe or Microsoft Visio.exe ....
I'm not asking you to write this program for me, I am merely asking if you know of a command which would scan the computer for a certain file name without knowing the path to that file.
Help : )
Al
.
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
TheGuardian001
|
Posted: Tue Jan 27, 2009 8:04 pm Post subject: Re: Help cant assign value to variable for weird reason : / |
|
|
That depends on how badly you want the "chain:" part to be in there. if you make a system call without "chain:", any program stored in program files(and possibly WINDOWS, I don't remember), can be accessed simply by using the name of the .exe file with no path.
Turing: |
var worked : int
system("WINWORD",worked ) %this will open Microsoft Word!
system("chain:WINWORD",worked ) %this will fail.
system("iexplore",worked ) %this will open Internet explorer!
system("chain:iexplore",worked ) %this will fail.
|
I don't know of any way to preserve "chain:" and not have to search through the computer, which would probably be very inefficient and often not work, although you could probably just terminate the program in some other way.
|
|
|
|
|
|
Al_
|
Posted: Tue Jan 27, 2009 8:42 pm Post subject: RE:Help cant assign value to variable for weird reason : / |
|
|
thx ill keep working
Al
.
|
|
|
|
|
|
andrew.
|
Posted: Tue Jan 27, 2009 8:48 pm Post subject: Re: Help cant assign value to variable for weird reason : / |
|
|
TheGuardian001 @ Tue Jan 27, 2009 8:04 pm wrote: That depends on how badly you want the "chain:" part to be in there. if you make a system call without "chain:", any program stored in program files(and possibly WINDOWS, I don't remember), can be accessed simply by using the name of the .exe file with no path.
Turing: |
var worked : int
system("WINWORD",worked ) %this will open Microsoft Word!
system("chain:WINWORD",worked ) %this will fail.
system("iexplore",worked ) %this will open Internet explorer!
system("chain:iexplore",worked ) %this will fail.
|
I don't know of any way to preserve "chain:" and not have to search through the computer, which would probably be very inefficient and often not work, although you could probably just terminate the program in some other way.
If I'm remembering correctly, not all programs can be run like that. The programs have to be "registered" somewhere in Windows to be able to just say WINWORD or notepad. Normally, the only programs that work with the EXE name are the official Microsoft programs that come with Windows. You can check if a program works by opening up Run and typing in the name like "notepad" and pressing run. If it opens, then the program is "registered" in the database somewhere.
BTW, I made a simple command prompt program in Turing. I can post the compiled version if you want.
|
|
|
|
|
|
Al_
|
Posted: Wed Jan 28, 2009 1:33 pm Post subject: RE:Help cant assign value to variable for weird reason : / |
|
|
Thx for your help. I have one question, what code would i use to close MS Word? For example:
To open:
code: |
system("WINWORD",worked)
|
What would be the opposite? Thx for your help
Al
|
|
|
|
|
|
DemonWasp
|
Posted: Wed Jan 28, 2009 1:45 pm Post subject: RE:Help cant assign value to variable for weird reason : / |
|
|
There really isn't one, to the best of my knowledge.
|
|
|
|
|
|
andrew.
|
Posted: Wed Jan 28, 2009 4:59 pm Post subject: Re: Help cant assign value to variable for weird reason : / |
|
|
Here is the program I made. It's not very good right now because I barely worked on it.
Things you can do:
- ls
- ls -pause (prints a bit then pauses for you to read it)
- dir
- cd
- C:/, D:/, etc.
- color
- about
- pid OR processid (prints the current process ID of the command window)
- cls OR clear
- rm (removes both directories and files)
- copy (files only)
- mkdir (creates a directory)
- echo
- exit
Description: |
|
Download |
Filename: |
CMDTerminal.zip |
Filesize: |
274.07 KB |
Downloaded: |
78 Time(s) |
|
|
|
|
|
|
|
|