#186521 - 2008-03-28 03:17 PM
Printing within FOR...NEXT
|
Alan R
Fresh Scripter
Registered: 2003-05-18
Posts: 12
Loc: NJ
|
I cannot get a for next loop to print more than just the first variable. As in below:
$a="Joe" $b="User" for $cnt = 1 to 3 ? $cnt + $A + $b next
This is just an example. It seems to only print $cnt and ignores the additions. What I am doing is reading in the contents of a directory that has Ghost images and trying to create an indexed menu selection like: 1. Image1.gho 2. Image2.gho <---- trying to use the $cnt as selection no. 3. Image3.gho What image to restore(1-3)?
So the line after the FOR I am using something like: ? $cnt + ". " + $file[$cnt}
Any idea's?
|
|
Top
|
|
|
|
#186571 - 2008-03-31 05:01 PM
Re: Printing within FOR...NEXT
[Re: Glenn Barnas]
|
Alan R
Fresh Scripter
Registered: 2003-05-18
Posts: 12
Loc: NJ
|
Yes, Mart, thanks. I did not know that I don't need +. Glenn - not sure I understand the reason for the ? at the END of the line?
Particulars: Yes, I use an array which contains the full filename in each element.
:CHOOSE $ind= $ind -1 For $cnt = 1 to $ind $gho= $dir[$cnt] ? $cnt ". " $gho Next
This code seems to do what I want now. One question I have is how (using GET) would I be able to see the selections typed as selections are made? Or do I need to use GETS?
Thanks for the help.
Edited by Alan R (2008-03-31 05:03 PM)
|
|
Top
|
|
|
|
#186572 - 2008-03-31 05:20 PM
Re: Printing within FOR...NEXT
[Re: Alan R]
|
Alan R
Fresh Scripter
Registered: 2003-05-18
Posts: 12
Loc: NJ
|
Okay, now I know the reason for the ? at the end (didn't know I don't need ? to print every time either!!). But is ther a way to stop it from printing the selection on the next line? Ex: Is this correct? y I would like: Is this correct? y
GETS then?
|
|
Top
|
|
|
|
#186574 - 2008-03-31 06:08 PM
Re: Printing within FOR...NEXT
[Re: Alan R]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
|
You're looking for a single char, use Get, if you want more than one, or you want the user to press enter, use Gets.
If you want to display the result of the Get, simply echo the result back.
$Images = 'image1', 'image2', 'image3', 'image4'
For $I = 0 to UBound($Images)
$I + 1 ; put the menu choice on the line (1-based)
'. ' $Images[$I] '.gho' ? ; put the corresponding file name, extension on the line
Next
'What image to restore(1-' UBound($Images) + 1 ')? ' ; prompt for input
Get $Answer ; get answer
$Answer ? ; show answer, move to next line
"?" is a synonym for @CRLF - a carriage-return + line-feed. Use it only when you want to move to the next line. The most logical place is at the END of a line. Eliminating it continues printing on the same line.
Glenn
Edited by Glenn Barnas (2008-03-31 06:14 PM) Edit Reason: missing quote
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
#186647 - 2008-04-02 09:54 PM
Re: Printing within FOR...NEXT
[Re: Glenn Barnas]
|
Alan R
Fresh Scripter
Registered: 2003-05-18
Posts: 12
Loc: NJ
|
Okay, thanks. Now the last bit of the puzzle. As I might have mentioned I use BARTPE. I am using the script to restore the system drive of various PC's. Ghost wants to know the drive number. It looks like it will always be one, is that correct? If not is there a way to extract this with Kixtart?
|
|
Top
|
|
|
|
#186650 - 2008-04-02 10:20 PM
Re: Printing within FOR...NEXT
[Re: Glenn Barnas]
|
Alan R
Fresh Scripter
Registered: 2003-05-18
Posts: 12
Loc: NJ
|
Was thinking that. Checking into it.
|
|
Top
|
|
|
|
#186654 - 2008-04-02 11:15 PM
Re: Printing within FOR...NEXT
[Re: Alan R]
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
Makes me think of a DVD I made some years ago
- All HardWare is the same
- Sysprepped the computer and shut it down
- Made a Ghost
I used this image with a BartPE Boot DVD and KiXforms
- User boots DVD and gets only one button to restore image (with Ghost)
- Computer restarts after restore and shows menu with computer names
- user chooses the correct computername
- By clicking the button with the computer name, the sysprep.ini is rewritten
- user gets message to remove DVD and restart computer
- computer restarts, SYSPREP continues to configure computer and puts computer in Windows domain.
- Now, I only have to put the computer object in the right ou
I made this as restore DVD for some computers in our warehouses. I will see on that DVD tomorrow what command I used for Ghost.
|
|
Top
|
|
|
|
#186691 - 2008-04-03 05:08 PM
Re: Printing within FOR...NEXT
[Re: Witto]
|
Alan R
Fresh Scripter
Registered: 2003-05-18
Posts: 12
Loc: NJ
|
Thanks Witto, sounds like a future improvement I might tackle! Correct me if I am wrong, if you use Kixforms the dll needs to be installed on whatever you are running the script on, correct? On boot disk OR on user PC's in the case of some type of logon script?
Glenn,
Getting back to the get and printing the response. Echoing it back will print on the next line. "Ideally" I want the same thing as I see with gets with the answer on the same line as the question. I know it's trivial but is visually appealing.
|
|
Top
|
|
|
|
#186698 - 2008-04-03 07:18 PM
Re: Printing within FOR...NEXT
[Re: Alan R]
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
The command for ghost32.exe I used in the KiXtart script was like this:
Shell '"\PROGRAMS\GHOST8\GHOST32.EXE" -clone,mode=load,src=\Image\MyImage.gho,dst=1 -RB -SURE -BATCH'
I made my own AUTORUN10.CMD
@regsvr32 /s \SetupWH\KiXforms.dll
@exit
to register the kixforms.dll and AUTORUN20.CMD
@start \SetupWH\WKix32.exe \SetupWH\SetupWH.kix
@exit
to run the KiXtart script
|
|
Top
|
|
|
|
#186704 - 2008-04-03 09:41 PM
Re: Printing within FOR...NEXT
[Re: Glenn Barnas]
|
Alan R
Fresh Scripter
Registered: 2003-05-18
Posts: 12
Loc: NJ
|
Okay, I guess from the days I fooled around with BASIC I carried over the "?" to mean PRINT . I stand corrected. I looked in an electronic copy of the Kixtart book and saw exactly what you said. TYVM.
That kind of answers a couple questions. Just never saw variables printed without the "?" before in all the examples I have run across.
...AR
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 657 anonymous users online.
|
|
|