home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / mslang / stepon / example2.tx_ / example2.tx
Encoding:
Text File  |  1994-05-01  |  12.5 KB  |  417 lines

  1. ºaddshare.scpºIf "{_Locking}" = "-1"
  2.     OutBox "Your system uses locking."
  3. Else
  4.     MsgBox "r", "Should SHARE.EXE be activated?", "", "&Yes;&No"
  5.     If "{r}" = "1"
  6.         AddShareExe    
  7.         OutBox "Please leave Windows and restart your system to activate SHARE.EXE{_NL}For a sample how to do this with StepOne see command ReBoot."
  8.     EndIf
  9. EndIf
  10. ºaskbox.scpºAskBox "i", "Please enter a text.", ""
  11. If "{i}" <> ""
  12.     OutBox "You've entered the following text:{_NL}{i}"
  13. Else
  14.     OutBox "You haven't entered a text."
  15. EndIf
  16. ºaskend.scpºAskEnd
  17. OutBox "No problem."
  18. Endºbeep.scpºAskBox "b", "Enter the number of beeps you want to hear.", ""
  19. If "{b}" <> "0"
  20.     Beep "{b}"
  21. Else
  22.     OutBox "No beep."
  23. EndIf
  24. ºchdir.scpºGetDir "p"
  25. PathBox "p1", "Enter the name of the path you want to chang to."
  26. If "{p}" <>\ "{p1}"
  27.     ChDir "{p1}"
  28.     MsgBox "", "You've choosed '{p1}'. Do you want to reactivate '{p}'?", "", "&Yes;&No"
  29.     If "{_Stack}" = "1"
  30.         ChDir "{p}"
  31.     EndIf
  32. Else
  33.     OutBox "No problem..."
  34. EndIf
  35. ºchftype.scpºChangeFileType "NewName", "{_appname}", "ini"
  36. OutBox " INI file with same base name and path as the sample{_nl}'{_appname}'{_nl}is named:{_nl}'{NewName}'"
  37. ºclipread.scpºTextRead "t", "{_BootDrv}\autoexec.bat"
  38. ClipWrite "{t}"
  39. ClipRead "auto"
  40. OutBox "{auto}"
  41. ºclipwrit.scpºTextRead "t", "{_BootDrv}\autoexec.bat"
  42. ClipWrite "{t}"
  43. ClipRead "auto"
  44. OutBox "{auto}"
  45. ºcompute.scpºLet "a", "2"
  46. Compute "res", "2", "+", "{a}"
  47. OutBox "2 plus {a} is: {erg}", "Calc 1"
  48. Compute "res", "10" + "{a}"
  49. OutBox "10 plus {a} is: {erg}", "Calc 2"
  50. ºconcat.scpºLet "res", "Hello "
  51. Concat "res", "World!"
  52. OutBox "{res}", "Result"
  53. ºcopy.scpºPathBox "s", "Enter a source path.", "", "", "", "", "-1", "&OK"
  54. If "{s}" <> ""
  55.     SplitPathName "x", "{s}", "2"
  56.     PathBox "t", "Enter a target path."
  57.     If "{t}" <> ""
  58.         Copy "{s}", "{t}\{x}"
  59.         If "{_err}" = "0"
  60.             OutBox "Ready - file copied."
  61.         EndIf
  62.     Else
  63.         OutBox "No problem."
  64.     EndIf
  65. Else
  66.     OutBox "No problem."
  67. EndIf
  68. ºcreatetn.scpºTextRead "t", "{_bootdrv}\autoexec.bat", "0"
  69. CreateTempName "f"
  70. TextWrite "{f}", "{t}"
  71. TextRead "t1", "{f}"
  72. OutBox "{t1}"ºddeexec.scpºLet "p", "ProgMan"
  73. AskBox "g", "Program group, you want to create."
  74. If "{g}" <> ""
  75.     DDEExecute "{p}", "{p}", "", "[creategroup({g})]"
  76.      If "{_Err}" = "0"
  77.         MsgBox "r", "Should {g} be deleted?", "", "&Yes;&No"
  78.         If "{r}" = "1"
  79.             DDEExecute "{p}", "{p}", "", "[deletegroup( {g})]"
  80.         EndIf
  81.     EndIf
  82. Else
  83.     OutBox "No problem."
  84. EndIf
  85. ºddepoke.scpº' Please start first the _DDE example.
  86. DDEPoke "StepOne", "System", "DDESystem", "Client1~Display~Test" 
  87. ºddereque.scpºDDERequest "res", "Progman", "Progman", "Groups"
  88. Window "-1", "", "", "{res}"
  89. GetUserInput
  90. ºdel.scpºLet "f", "del.tmp"
  91. TextWrite "{f}", "This is a test for the Del command."
  92. FileExist "r", "{f}"
  93. If "{r}" = "0"
  94.     OutBox "There goes something wrong."
  95. Else
  96.     TextRead "i", "{f}"
  97.     MsgBox "", "File{_NL}'{f}'{_NL}was created with the following contents:{_NL}{i}{_NL}{_NL}Should StepOne now delete the file?", "", "&Yes;&No"
  98.     If "{_Stack}" = "1"
  99.         Del "{f}"
  100.     Else
  101.         OutBox "No problem..."
  102.     EndIf
  103. EndIf
  104. ºdirexist.scpºDirExist "t", "{_TempDir}"
  105. If "{t}" = "0"
  106.     OutBox "You don't have a TEMP directory."
  107. Else
  108.     OutBox "TEMP directory exists as '{_TempDir}'."
  109. EndIf
  110. ºend.scpºLet "f", "{_BootDrv}\command.com"
  111. FileExist "e", "{f}"
  112. If "{e}" = "0"
  113.     OutBox "You don't have MS-DOS, have you?"
  114. Else
  115.     OutBox "File{_NL}'{f}'{_NL}exists."
  116. EndIf
  117. ºfiledate.scpºLet "f", "{_BootDrv}\command.com" 
  118. FileExist "r", "{f}" 
  119. If "{r}" = "0" 
  120.     OutBox "You don't have MS-DOS, have you?" 
  121. Else 
  122.     FileDate "r", "{f}" 
  123.     OutBox "Your{_NL}'{f}'{_NL}is dated:{_NL}{r}" 
  124. EndIf 
  125. ºfileexis.scpºLet "f", "{_BootDrv}\command.com"
  126. FileExist "r", "{f}"
  127. If "{r}" = "0"
  128.     OutBox "You don't have MS-DOS, have you?"
  129. Else
  130.     OutBox "File{_NL}'{f}'{_NL}exists."
  131. EndIf
  132. ºfilelen.scpºLet "f", "{_BootDrv}\command.com" 
  133. FileExist "r", "{f}" 
  134. If "{r}" = "0" 
  135.     OutBox "You don't have MS-DOS, have you?"
  136. Else 
  137.     FileLen "r", "{f}" 
  138.     OutBox "File{_NL}'{f}'{_NL}is{_NL}{e} Bytes{_NL}long." 
  139. EndIf 
  140. ºfilesear.scpºFileSearch "FileWithPath", "command.com"
  141. OutBox "{FileWithPath}", "Searching in DOS path: command.com"
  142. FileSearch "FileWithPath", "io.sys"
  143. OutBox "{FileWithPath}", "Searching in DOS path: io.sys"
  144. ºfindfrst.scpºWindow "-1", "", "Please be patient...", "Searching INI files in Windows directory."
  145. Let "List", ""
  146. FindFirst "res", "{_windowsdir}\*.ini"
  147. For "i", "1", "1000"
  148.     If "{res}" <> ""
  149.         Concat     "List", "{res}{_nl}"
  150.         FindNext "res"
  151.     Else
  152.         ExitFor
  153.     EndIf
  154. Next 
  155. Compute "i", "{i}" - "1"
  156. Window "-1", "", "{i} INI files found", "{List}"
  157. GetUserInputºfornext.scpºFor "i", "1", "10"
  158.     MsgBox "res", "Counter has value: {i}.{_nl}Do you want to continue?", "", "&OK;&Cancel"
  159.     If "{res}" = "2"
  160.         ExitFor
  161.     EndIf
  162. Nextºgetdir.scpºGetDir "p"
  163. OutBox "Active path is:{_NL}'{p}'."
  164. ºgetdiskf.scpºLet "d", "{_BootDrv}"
  165. GetDiskFree "f", "{d}"
  166. OutBox "Your boot drive {d} has {_NL}{f} bytes{_NL} free."
  167. ºgetdiskl.scpºLet "d", "{_BootDrv}"
  168. GetDiskLabel "l", "{d}"
  169. OutBox "Volume label of your boot drive {d} is:{_NL}{l}"
  170. ºgetdisks.scpºLet "d", "{_BootDrv}"
  171. GetDiskSize "s", "{d}"
  172. OutBox "Your boot drive {d} has a capacity of:{_NL}{s} bytes{_NL}"
  173. ºgetdiskt.scpºLet "d", "{_BootDrv}"
  174. GetDiskType "t", "{d}"
  175. If "{t}" <> "HD"
  176.     OutBox "Your boot drive {d} isn't a hard drive."
  177. Else
  178.     OutBox "Your boot drive {d} is a hard drive."
  179. EndIf
  180. ºgetenvir.scpºgetenvironment "env", "prompt"
  181. OutBox "DOSPrompt: {env}"ºgetnewer.scpºGetNewerFile "newer", "{_bootdrv}\config.sys", "{_bootdrv}\autoexec.bat"
  182. GoSub "{newer}"
  183.  
  184. Sub 1
  185.     OutBox "File CONFIG.SYS is younger as file AUTOEXEC.BAT."
  186. EndSub
  187.  
  188. Sub 2
  189.     OutBox "File CONFIG.SYS is older as file AUTOEXEC.BAT."
  190. EndSubºgettabc.scpºGetTableCount "t"
  191. If "{t}" <> ""
  192.     OutBox "You have {t} table(s) in your project."
  193. Else
  194.     OutBox "You don't have tables in your project."
  195. EndIf
  196. ºgettabec.scpºGetTableElementCount "e"
  197. If "{e}" <> ""
  198.     OutBox "You've {e} elements in the table(s) of your project."
  199. Else
  200.     OutBox "You don't have tables in your project."
  201. EndIf
  202. ºgettablc.scpºGetTableLineCount "l"
  203. If "{l}" <> ""
  204.     OutBox "You've {l} lines in the table(s) of your project."
  205. Else
  206.     OutBox "You don't have tables in your project."
  207. EndIf
  208. ºgetuseri.scpºLet "t", "StepOne test"
  209. Window "-1", "{t}", "Info", "Press 'End', or 'Alt+E' to end '{t}'.", "-1", "10;10;990;900"
  210. GetUserInput "&End"
  211. ºgosub.scpºGoSub "test", "abc"
  212. End
  213.  
  214. Sub test
  215.     Parameter "x"
  216.     OutBox "{test:x}"
  217. EndSub
  218. ºgoto.scpºAskBox "res", "How often should loop be executed?{_NL}Please enter the desired number:"
  219. If "{res}" <> ""
  220.     Compute "", "{res}" + "1"
  221.     If "{_Err}" = "0"
  222.         Label "ForLoop"
  223.         Compute "i", "{i}" + "1"
  224.         If "{i}" <= "{res}"
  225.             PlayWave "{_WindowsDir}\xylophon.wav"
  226.              Goto "ForLoop"
  227.         Else
  228.             Goto "AfterForLoop"
  229.         EndIf
  230.     EndIf
  231. EndIf
  232. OutBox "Sorry, you haven't entered a number!"
  233. Label "AfterForLoop"
  234. ºif.scpºMsgBox "res", "Do you want to see a demonstration of If?", "",  "&Yes;&No"
  235. If "{res}" = "1"
  236.     Let "t", "You want to see a demonstration."
  237. Else
  238.     Let "t", "Why no?"
  239. EndIf
  240. OutBox "{t}"
  241. ºiniread.scpºIniRead "res", "", "Devices", "{_Nil}"
  242. Let "t", ""
  243. For "Count", "1", "100"
  244.     Split "dev", "{res}", "{_NL}", "{Count}" 
  245.     If "{dev}" <> ""
  246.         IniRead "res1", "", "Devices", "{dev}"
  247.         Concat "t", "{dev} at {erg1}{_NL}"
  248.     Else
  249.         ExitFor
  250.     EndIf
  251. Next
  252. If "{t}" <> ""
  253.     Let "t", "[Devices]{_NL}{t}"
  254.     OutBox "{t}", "Your devices and interfaces"
  255. EndIf
  256. ºiniwrite.scpºLet "Contents", "{_BootDrv}\StepOne\^.SCP"
  257. IniWrite "", "Extensions", ".SCP", "{Contents}"
  258. If "{_Err}" = "0"
  259.     IniRead "res", "", "Extensions", ".SCP"
  260.     OutBox "Your file WIN.INI was edited as follows:{_NL}[Extensions]{_NL}.SCP={res}"
  261. Else
  262.     OutBox "Error during editing of file WIN.INI."
  263. EndIf
  264. IniWrite "", "Extensions", ".SCP", "{_NIL}"
  265. ºisattrib.scpºLet "f", "{_BootDrv}\command.com"
  266. IsArchive "a", "{f}"
  267. IsHidden "h", "{f}"
  268. IsReadOnly "r", "{f}"
  269. IsSystem "s", "{f}"
  270. Let "t", "{f} has set the following attributes:{_NL}"
  271. If "{a}" = "-1"
  272.     Concat "t", "Archive{_NL}"
  273. EndIf
  274. If "{h}" = "-1"
  275.     Concat "t", "Hidden{_NL}"
  276. EndIf
  277. If "{r}" = "-1"
  278.     Concat "t", "Read only{_NL}"
  279. EndIf
  280. If "{s}" = "-1"
  281.     Concat "t", "System{_NL}"
  282. EndIf
  283. OutBox "{t}"
  284. ºisperm2w.scpºMsgBox "res", "Please enter a write protected disk in drive 'A'.", "", "&OK;&Cancel" 
  285. If "{res}" = "1" 
  286.     IsPermissionToWrite "res1", "a:"
  287.     If "{res1}" = "0"
  288.         OutBox "You don't have a write permission at drive 'A'."
  289.     Else
  290.         Outbox "The disk in drive 'A' isn't write protected."
  291.     EndIf
  292. EndIfºistaskac.scpºIsTaskActive "res", "{_WindowsDir}\progman.exe"
  293. If "{res}" = "-1"
  294.     OutBox "Program Manager is allready started."
  295. Else
  296.     OutBox "Program Manager isn't started."
  297. EndIf
  298. ºjump.scpºJump "+2"
  299. OutBox "This text will never be displayed"
  300. ' Comment lines don't count
  301. OutBox "Hello World"
  302. ºlabel.scpºLet "Count", "0"
  303. Let "Cancel", "0"
  304. '...
  305. If "{Cancel}" = "1"
  306.     Goto "LoopEnd"
  307. EndIf
  308. Label "LoopBegin"
  309.     Compute "Count", "{Count}", "+", "1"
  310.     MsgBox "Cancel", "Loop was executed {Count} times.{_NL}Do you want to exit?", "", "&Yes;&No"
  311.     If "{Cancel}" = "2"
  312.         Goto "LoopBegin"
  313.     EndIf
  314. Label "LoopEnd"
  315. OutBox "Loop was executed {Count} times."
  316. ºlen.scpºAskBox "t", "Please enter a text."
  317. Len "res", "{t}"
  318. If "{res}" = "0"
  319.     Let "tx", "You don't have entered a text."
  320. Else
  321.     Let "tx", "ou've entered the following text:{_NL}{t}{_NL}Text contains{_NL}{erg} characters."
  322. EndIf
  323. OutBox "{tx}"
  324. ºlet.scpºLet "res", "Hello "
  325. Concat "res", "World!"
  326. OutBox "{res}", "Result"
  327. ºmci2.scpºWindow "-1", "", "Now Playing: 1"
  328. Let "count", "1"
  329. Label "loop"
  330. MCISend "", "open cdaudio alias mymusic"
  331. If "{_err}" = "-1"
  332.     OutBox "No Audio CD found."
  333.     Goto "break"
  334. EndIf
  335. MCISend "", "set mymusic time format tmsf"
  336. MCISend "", "play mymusic from {count}"
  337. If "{_err}" = "-1"
  338.     Goto "break"
  339. EndIf
  340. Wait "+20"
  341. MCISend "", "stop mymusic"
  342. MCISend "", "close mymusic"
  343. Compute "count", "{count}" +  "1"
  344. Window "-1", "", "Now Playing: {count}"
  345. Goto "loop"
  346. Label "break"
  347. ºmcisend.scpºMCISend "", "open {_WindowsDir}\xylophon.wav type waveaudio alias mywave" 
  348. MCISend "", "play mywave wait"
  349. MCISend "", "close mywave"
  350. ºmkdir.scpºLet "targetp", "{_BootDrv}"
  351. Let "Datap", "{targetp}\dummy"
  352. MkDir "{Datap}"
  353. If "{_Err}" = "0"
  354.     PathBox "", "Path 'dummy' was created...", "", "{targetp}\dummy", "", "", "0", "&OK"
  355.     RmDir "{Datap}"
  356.     If "{_err}" = "0"
  357.         OutBox "... and now deleted!"
  358.     EndIf
  359. EndIf
  360. ºmsgbox.scpºLet "f", "AUTOEXEC.BAT"
  361. TextRead "res", "{_BootDrv}\{f}"
  362. MsgBox "r", "Do you want to see the contents of {f}?", "", "&Yes;&No"
  363. If "{r}" = "1"
  364.     OutBox "{res}"
  365. Else
  366.     OutBox "No problem..."
  367. EndIf
  368. ºnetaddc.scpº' Please use for 'd:' and '\\server\path' corresponding values to your system.
  369. NetAddConnection "d:", "\\server\path"
  370. ºnetcance.scpº' Please change 'f:' to a corresponding value on your system.
  371. NetGetConnection "Resource", "f:"
  372. If "{Resource}" <> ""
  373.     NetCancelConnection "f:"
  374. Else
  375.     OutBox "Network drive 'f:' isn't available."
  376. EndIf
  377. ºnetgetc.scpºNetGetConnection "Res", "f:"
  378. If "{Res}" = ""
  379.     OutBox "Network drive 'f:' isn't available."
  380. Else
  381.     OutBox "Drive 'f:' is named in network {Res}."
  382. EndIf
  383. ºoutbox.scpºTextRead "tf", "{_BootDrv}\AUTOEXEC.BAT"
  384. OutBox "{tf}", "AUTOEXEC.BAT"
  385. ºpatchf.scpºLet "hint", "Important hint!!!{_nl}"
  386. Concat "hint", "This example changes the file PATCHME.EXE. Some virus scanner "
  387. Concat "hint", "will recognize the change of this file and will "
  388. Concat "hint", "think this could be an unknown virus typ. "
  389. Concat "hint", "This is definitively wrong and a problem of virus scanner. "
  390. Concat "hint", "The software isn't able to make a difference between "
  391. Concat "hint", "legal and illegal changes of EXE files!"
  392. OutBox "{hint}"
  393. ' Gets the user name of the resource from file USER.EXE.
  394. ' This isn't documented but was described in german
  395. ' Microsoft System Journal 1/94. Command ResStringRead
  396. ' of StepOne is useful for this...
  397. ResStringRead "username", "user.exe", "514"
  398.  
  399. ' #515 is the name of the corporation
  400. ResStringRead "corpname", "user.exe", "515"
  401.  
  402. Let "username", "{username} of {corpname}"
  403. SplitPathName "path", "{_appname}", "1"
  404.  
  405. ' To make sure that the example works every time we only work with a copy of PatchMe
  406. Copy "{path}\patchme.exe", "{path}\patchme1.exe", "3"
  407.  
  408. PatchFile "{path}\patchme1.exe", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "{UserName}"
  409.  
  410. ' Checks, if it works fine
  411. TaskStart "{path}\patchme1.exe" ºpathbox.scpºPathBox "ini", "Please choose an INI file.", "", "", "", "*.ini", "-1"
  412. If "{ini}" <> ""
  413.     TextRead "i", "{ini}"
  414.     OutBox "You've choosed the following INI file:{_NL}{ini}{_NL}{i}"
  415. Else
  416.     OutBox "No problem."
  417. EndIf