Author Topic: case statement problem  (Read 3892 times)

0 Members and 1 Guest are viewing this topic.

Offline badger

  • Forum Regular
  • Posts: 148
    • View Profile
case statement problem
« on: October 03, 2020, 07:24:29 pm »
Hell

Back from the er about to loose a toe nail to save the toe LOL first time in front of the computer

why does this select case skip  the line with chr$(13) if enter is hit it need to goto s1 meaning the string value is "" or chr$(13)


Code: QB64: [Select]
  1.         CASE CHR$(88): RETURN 'X
  2.         CASE CHR$(45): GOTO inv6 '-
  3.         CASE CHR$(13): GOTO s1 ' enter key or ""
  4.         CASE ELSE
  5.                 GOSUB custinforec_null
  6.                 custinforec.id = sr
  7.                 GOSUB inv0
  8.                 GOTO s2
  9.  

Thanks in advance

Badger

FellippeHeitor

  • Guest
Re: case statement problem
« Reply #1 on: October 03, 2020, 07:28:16 pm »
I may be to quick to say we have too little context here, but it does seem like too short a snippet for any help to be useful.

FellippeHeitor

  • Guest
Re: case statement problem
« Reply #2 on: October 03, 2020, 07:29:01 pm »
BTW, that's not how _DEFINE is supposed to work: http://www.qb64.org/wiki/DEFINE

You probably meant DIM http://www.qb64.org/wiki/DIM.

Offline badger

  • Forum Regular
  • Posts: 148
    • View Profile
Re: case statement problem
« Reply #3 on: October 03, 2020, 07:37:21 pm »
Hello

The way i am using it all variables that starts with the letter _defined is that type.

here is the whole module i am using
if this is not enough i will post the whole thing but it is sorta a long program

any variable thats starts with an s is a string
the gosub to custinforec.null just sets all custinforec files to ""
the gosub to dupidsearch calls a search to check for a duplicate id entered
Code: QB64: [Select]
  1. s1:
  2. saction = "Enter Customer ID X to Exit "
  3. ib = 10
  4. ilow = 1
  5. ihigh = 999999999
  6. iflag1 = 0
  7. searchid = sr
  8. GOSUB dupidsearch
  9.         CASE CHR$(88): RETURN 'X
  10.         CASE CHR$(45): GOTO inv6 '-
  11.         CASE CHR$(13): GOTO s1 ' enter key or ""
  12.         CASE ELSE
  13.                 GOSUB custinforec_null
  14.                 custinforec.id = sr
  15.                 GOSUB inv0
  16.                 GOTO s2
  17.  

Badger

FellippeHeitor

  • Guest
Re: case statement problem
« Reply #4 on: October 03, 2020, 07:38:15 pm »
How are you getting input?

Offline badger

  • Forum Regular
  • Posts: 148
    • View Profile
Re: case statement problem
« Reply #5 on: October 03, 2020, 07:44:34 pm »
Hello

first of all i use a lot of rem statements i found that my poor eye sight sees better this way dont ask my why so please do not get frustrated ok.. I have never before used subs and functions i need this done real quick. I will rewrite it later to use all subs and functions and then another rewrite using forms..

Code: QB64: [Select]
  1. REM ***************************************************************************
  2. REM **** Program Bridal Store *************************************************
  3. REM ***************************************************************************
  4. REM ***************************************************************************
  5. REM **** Author Philip King  **************************************************
  6. REM ***************************************************************************
  7. REM ***************************************************************************
  8. REM ***************************************************************************
  9. REM **** Includes go here *****************************************************
  10. REM ***************************************************************************
  11.  
  12. REM ***************************************************************************
  13. REM ***************************************************************************
  14. REM **** Sreen statements here ************************************************
  15. REM ***************************************************************************
  16. REM ***************************************************************************
  17.  
  18. REM ***************************************************************************
  19. REM **** defines for quick use data types *************************************
  20. REM ***************************************************************************
  21. REM ***************************************************************************
  22.  
  23. REM ***************************************************************************
  24. REM **** Listing of subs and funtions *****************************************
  25. REM ***************************************************************************
  26.  
  27. REM ***************************************************************************
  28.  
  29. REM ***************************************************************************
  30. REM **** arrays decleared here ************************************************
  31. REM ***************************************************************************
  32. imenu = 4
  33. DIM SHARED smenu(imenu) AS STRING
  34. REM ***************************************************************************
  35.  
  36. REM ***************************************************************************
  37. REM **** arrays set to data here **********************************************
  38. REM ***************************************************************************
  39. smenu(1) = "1) Edit Customer Info": smenu(2) = "3) Edit Inventory Data "
  40. smenu(3) = "2) Edit Sales ": smenu(4) = "4) System Maintenance "
  41. REM ***************************************************************************
  42.  
  43. REM ***************************************************************************
  44. REM **** variables declares go here *******************************************
  45. REM ***************************************************************************
  46. CONST null = ""
  47. DIM SHARED zrecordnum
  48. DIM SHARED lrecordlen
  49. REM ***************************************************************************
  50.  
  51. REM ***************************************************************************
  52. REM **** customer info record type ********************************************
  53. REM ***************************************************************************
  54. TYPE customer
  55.         id AS STRING * 10
  56.         sfirst_name AS STRING * 25
  57.         slast_name AS STRING * 25
  58.         saddress AS STRING * 30
  59.         scity AS STRING * 25
  60.         sstate AS STRING * 2
  61.         szip AS STRING * 5
  62.         sphone AS STRING * 10
  63.         sfiller AS STRING * 124
  64. REM ***************************************************************************
  65.  
  66. REM ***************************************************************************
  67. REM **** inventory record type ************************************************
  68. REM ***************************************************************************
  69. TYPE inventory
  70.         id AS STRING * 10
  71.         sdesc AS STRING * 10
  72.         sdate_bought AS STRING * 8
  73.         sdate_sold AS STRING * 8
  74.         fcost AS STRING * 15
  75.         fretail AS STRING * 15
  76.         ssize AS STRING * 2
  77.         ssold AS STRING * 1
  78.         sfiller AS STRING * 59
  79. REM ***************************************************************************
  80.  
  81. REM ***************************************************************************
  82. REM **** system data file record **********************************************
  83. REM ***************************************************************************
  84. TYPE systemdat
  85.         last_rec AS STRING * 9
  86.         system_data_path AS STRING * 25
  87.         customer_db AS STRING * 25
  88.         inventory_db AS STRING * 25
  89.         invoice_db AS STRING * 25
  90.         sfiller AS STRING * 19
  91. REM ***************************************************************************
  92.  
  93. REM ***************************************************************************
  94. REM **** point of sale type ***************************************************
  95. REM ***************************************************************************
  96. TYPE sposlposid
  97.         sposid AS STRING * 10
  98. REM ***************************************************************************
  99. DIM SHARED custinforec AS customer
  100. DIM SHARED systemrec AS systemdat
  101. DIM SHARED sinventoryrec AS inventory
  102. linventorylen = LEN(sinventoryrec)
  103. lcustreclen = LEN(custinforec)
  104. lsystemreclen = LEN(systemrec)
  105. 'PRINT lsystemreclen
  106. 'PRINT lcustreclen
  107. 'PRINT linventorylen
  108. 'END
  109. GOTO main
  110. REM ***************************************************************************
  111.  
  112. REM ***************************************************************************
  113. REM **** main menu loop *******************************************************
  114. REM ***************************************************************************
  115. menuloop:
  116. GOSUB systemheader
  117. GOSUB printmain
  118. GOSUB mainmenuchoice
  119. IF sr = "" OR sr = CHR$(13) THEN GOTO menuloop
  120. IF sr = "X" THEN END
  121. IF sr = "1" THEN
  122.         CLS
  123.         GOSUB custinforec_null
  124.         GOSUB systemheader
  125.         GOSUB s0
  126. IF sr = "3" THEN
  127.         CLS
  128.         GOSUB inventoryrec_null
  129.         GOSUB systemheader
  130.         GOSUB inv0
  131.  
  132. REM ***************************************************************************
  133.  
  134. REM ***************************************************************************
  135. REM **** Sytem Header *********************************************************
  136. REM ***************************************************************************
  137. systemheader:
  138. COLOR White, Blue
  139. LOCATE 1, 1: PRINT CHR$(201): LOCATE 1, 80: PRINT CHR$(187)
  140. LOCATE 1, 2: PRINT STRING$(78, 205):
  141. FOR ix = 2 TO 7
  142.         LOCATE ix, 1: PRINT CHR$(186)
  143.         LOCATE ix, 80: PRINT CHR$(186)
  144. NEXT ix
  145. LOCATE 7, 2: PRINT STRING$(78, 205)
  146. LOCATE 7, 1: PRINT CHR$(200): LOCATE 7, 80: PRINT CHR$(188)
  147. LOCATE 4, 30: PRINT "Main System Menu"
  148. LOCATE 4, 63: PRINT "Date ": LOCATE 4, 68: PRINT DATE$
  149. LOCATE 4, 4: PRINT "Virsion 1.0"
  150. REM ***************************************************************************
  151.  
  152. REM ***************************************************************************
  153. REM **** printes in system erros **********************************************
  154. REM ***************************************************************************
  155. sprintserrors:
  156. IF se = "" THEN se = "INVALID RESPONSE"
  157. itemp = LEN(se)
  158. itemp1 = 40 - (itemp / 2)
  159. COLOR 16, 7
  160. 'COLOR Yellow, Blue
  161. LOCATE 25, itemp1: _BLINK ON: PRINT se;
  162. idelay = 1.5
  163. CALL Delay(1.5)
  164. iflag2 = 1
  165. REM ***************************************************************************
  166.  
  167. REM *****************************************************************************
  168. REM **** numeric input sub ******************************************************
  169. REM *****************************************************************************
  170. snumeric:
  171. ftemp = VAL(sr)
  172. IF ftemp < ilow OR ftemp > ihigh THEN
  173.         se = "INPUT OUT OF BOUNDS"
  174.         GOSUB sprintserrors
  175. REM ***************************************************************************
  176.  
  177. REM ***************************************************************************
  178. REM **** alpha input sub ******************************************************
  179. REM ***************************************************************************
  180. salphainput:
  181. iflag2 = 0
  182. ilength1 = LEN(sr)
  183. ilength2 = LEN(saction) + 2
  184. LOCATE 23, 1: PRINT saction; '               prints action menu
  185. LOCATE 23, ilength2 '                        set prompt one space after action menu print
  186. COLOR Yellow, Black: PRINT SPC(ib); '                changes color and prints ib spaces to screen for input lenght
  187. LOCATE 23, ilength2 '                        sets curser at the begining of input space from previouse line
  188. LINE INPUT sr: sr = UCASE$(sr) '             inputs data from user changes it to upper case
  189. IF LEN(sr) > ib THEN
  190.         se = "INVALID INPUT LENGTH"
  191.         GOSUB sprintserrors
  192.         sr = ""
  193.         iflag2 = 1
  194.         GOTO salphainput
  195. IF sr = "X" AND iflag1 = 1 THEN iflag1 = 0
  196. IF iflag1 = 1 AND VAL(sr) < ilow AND VAL(sr) > ihigh THEN GOSUB snumeric
  197. COLOR White, Blue
  198. REM ***************************************************************************
  199.  
  200. REM ***************************************************************************
  201. REM **** main menu to the screen **********************************************
  202. REM ***************************************************************************
  203. printmain:
  204. COLOR White, Blue
  205. FOR ix = 11 TO imenu
  206.         READ smenu(ix): LOCATE ix, 20: PRINT smenu(ix)
  207. NEXT ix
  208. LOCATE 11, 15: PRINT smenu(1)
  209. LOCATE 11, 40: PRINT smenu(2)
  210. LOCATE 13, 15: PRINT smenu(3)
  211. LOCATE 13, 40: PRINT smenu(4)
  212. REM ***************************************************************************
  213.  
  214. REM ***************************************************************************
  215. REM **** menu prompts start here **********************************************
  216. REM ***************************************************************************
  217. mainmenuchoice:
  218. ib = 1
  219. ihigh = 99
  220. ilow = 1
  221. saction = "Choose Menu Option or X to Quit "
  222. GOSUB salphainput
  223. REM ***************************************************************************
  224.  
  225. REM ***************************************************************************
  226. REM **** clean up the prompt area *********************************************
  227. REM ***************************************************************************
  228. clearprompt:
  229. LOCATE 23, 1: PRINT STRING$(79, 32)
  230. REM ***************************************************************************
  231.  
  232. REM ***************************************************************************
  233. REM **** inventory input modual ***********************************************
  234. REM ***************************************************************************
  235. inv0:
  236. LOCATE 10, 1: PRINT "Inventory Number         ";: PRINT sinventoryrec.id
  237. LOCATE 11, 1: PRINT "Description File Name    ";: PRINT sinventoryrec.sdesc
  238. LOCATE 12, 1: PRINT "Date Purchased           ";: PRINT sinventoryrec.sdate_bought
  239. LOCATE 13, 1: PRINT "Date Sold                ";: PRINT sinventoryrec.sdate_sold
  240. LOCATE 14, 1: PRINT "Coste of Item            ";: PRINT sinventoryrec.fcost
  241. LOCATE 15, 1: PRINT "Retail Price             ";: PRINT sinventoryrec.fretail
  242. LOCATE 16, 1: PRINT "Size Of Item             ";: PRINT sinventoryrec.ssize
  243. LOCATE 17, 1: PRINT "Remove for Inventory Y/N ";: PRINT sinventoryrec.ssold
  244. REM **************************************************************************
  245. inv1:
  246. saction = "Enter Enventory Number X to Exit "
  247. ib = 10
  248. ilow = 1
  249. ihigh = 999999999
  250. iflag1 = 0
  251. GOSUB clearprompt
  252. GOSUB salphainput
  253.  
  254.         CASE CHR$(88): RETURN 'X
  255.         CASE CHR$(28): GOTO inv2 ' enter key or ""
  256.         CASE ELSE
  257.                 sdesc = sr
  258.                 sinventoryrec.id = sr
  259.                 GOSUB dupidsearch
  260.                 GOSUB inv0
  261.                 GOTO inv2
  262.  
  263.  
  264. 'sinventoryrec.id = sr: GOSUB inv0: GOTO inv2
  265. REM ***************************************************************************
  266. inv2:
  267. saction = "Enter D for Default, Type Name, X to Exit - To Backup "
  268. ib = 10
  269. ilow = 1
  270. ihigh = 999999999
  271. iflag1 = 0
  272. GOSUB clearprompt
  273. GOSUB salphainput
  274.         CASE CHR$(88): RETURN 'X
  275.         CASE CHR$(45): GOTO inv1 '-
  276.         CASE CHR$(68)
  277.                 sinventoryrec.sdesc = sinventoryrec.id
  278.                 sdesc = sinventoryrec.id
  279.                 GOSUB descinput
  280.                 GOSUB inv0
  281.                 GOTO inv3
  282.         CASE ELSE
  283.                 sinventoryrec.sdesc = sr
  284.                 sdesc = sr
  285.                 GOSUB descinput
  286.                 GOSUB inv0
  287.                 GOTO inv3
  288. REM ***************************************************************************
  289. inv3:
  290. saction = "Enter Date Bought X to Exit - To Backup "
  291. ib = 8
  292. ilow = 1
  293. ihigh = 999999999
  294. iflag1 = 0
  295. GOSUB clearprompt
  296. GOSUB salphainput
  297.         CASE CHR$(88): RETURN 'X
  298.         CASE CHR$(45): GOTO inv2 '-
  299.         CASE CHR$(28): GOTO inv4 ' enter key or ""
  300.         CASE ELSE
  301.                 sinventoryrec.sdate_bought = sr
  302.                 GOSUB inv0
  303.                 GOTO inv4
  304.  
  305. REM ***************************************************************************
  306. inv4:
  307. saction = "Enter Date Sold X to Exit - To Backup "
  308. ib = 10
  309. ilow = 1
  310. ihigh = 999999999
  311. iflag1 = 0
  312. GOSUB clearprompt
  313. GOSUB salphainput
  314.         CASE CHR$(88): RETURN 'X
  315.         CASE CHR$(45): GOTO inv2 '-
  316.         CASE CHR$(28): GOTO inv5 ' enter key or ""
  317.         CASE ELSE
  318.                 GOSUB inventoryrec_null
  319.                 sinventoryrec.sdate_sold = sr
  320.                 GOSUB inv0
  321.                 GOTO inv5
  322.  
  323. REM ***************************************************************************
  324. inv5:
  325. saction = "Enter Cost X to Exit - To Backup "
  326. ib = 10
  327. ilow = 1
  328. ihigh = 999999999
  329. iflag1 = 0
  330.  
  331. GOSUB clearprompt
  332. GOSUB salphainput
  333.         CASE CHR$(88): RETURN 'X
  334.         CASE CHR$(45): GOTO inv4 '-
  335.         CASE CHR$(28): GOTO inv6 ' enter key or ""
  336.         CASE ELSE
  337.                 GOSUB inventoryrec_null
  338.                 sinventoryrec.fcost = sr
  339.                 GOSUB inv0
  340.                 GOTO inv6
  341. REM ***************************************************************************
  342. inv6:
  343. saction = "Enter Retail Price X to Exit - To Backup "
  344. ib = 15
  345. ilow = 1
  346. ihigh = 999999999
  347. iflag1 = 0
  348. GOSUB clearprompt
  349. GOSUB salphainput
  350.         CASE CHR$(88): RETURN 'X
  351.         CASE CHR$(45): GOTO inv5 '-
  352.         CASE CHR$(28): GOTO inv7 ' enter key or ""
  353.         CASE ELSE
  354.                 GOSUB inventoryrec_null
  355.                 sinventoryrec.fretail = sr
  356.                 GOSUB inv0
  357.                 GOTO inv7
  358.  
  359. REM ***************************************************************************
  360. inv7:
  361. saction = "Enter Dress Size X to Exit - To Backup "
  362. ib = 2
  363. ilow = 1
  364. ihigh = 999999999
  365. iflag1 = 0
  366. GOSUB clearprompt
  367. GOSUB salphainput
  368.         CASE CHR$(88): RETURN 'X
  369.         CASE CHR$(45): GOTO inv6 '-
  370.         CASE CHR$(28): GOTO inv8 ' enter key or ""
  371.         CASE ELSE
  372.                 GOSUB inventoryrec_null
  373.                 sinventoryrec.ssize = sr
  374.                 GOSUB inv0
  375.                 GOTO inv8
  376. REM ***************************************************************************
  377. inv8:
  378. saction = "Date Sold X to Exit - To Backup "
  379. ib = 8
  380. ilow = 1
  381. ihigh = 999999999
  382. iflag1 = 0
  383. GOSUB clearprompt
  384. GOSUB salphainput
  385.         CASE CHR$(88): RETURN 'X
  386.         CASE CHR$(45): GOTO inv7 '-
  387.         CASE CHR$(28): GOTO inv9 ' enter key or ""
  388.         CASE ELSE
  389.                 GOSUB inventoryrec_null
  390.                 sinventoryrec.ssold = sr
  391.                 GOSUB inv0
  392.                 GOTO inv9
  393. REM ***************************************************************************
  394. inv9:
  395. saction = "Enter Take Out of Eventory Y/N X to Exit - To Backup "
  396. ib = 1
  397. ilow = 1
  398. ihigh = 999999999
  399. iflag1 = 0
  400. GOSUB clearprompt
  401. GOSUB salphainput
  402.         CASE CHR$(88): RETURN 'X
  403.         CASE CHR$(45): GOTO inv6 '-
  404.                 'CASE CHR$(28): GOTO inv7 ' enter key or ""
  405.         CASE ELSE
  406.                 GOSUB inventoryrec_null
  407.                 sinventoryrec.ssold = sr
  408.                 GOSUB inv0
  409.                 GOSUB puttorecord
  410.  
  411.  
  412. REM ***************************************************************************
  413. REM ***************************************************************************
  414. REM **** customer input modual ************************************************
  415. REM ***************************************************************************
  416. s0:
  417. LOCATE 10, 1: PRINT "Customer ID           ";: PRINT custinforec.id
  418. LOCATE 11, 1: PRINT "Customer First Name   ";: PRINT custinforec.sfirst_name
  419. LOCATE 12, 1: PRINT "customer Last Name    ";: PRINT custinforec.slast_name
  420. LOCATE 13, 1: PRINT "Customer Address      ";: PRINT custinforec.saddress
  421. LOCATE 14, 1: PRINT "Customer City         ";: PRINT custinforec.scity
  422. LOCATE 15, 1: PRINT "customer State        ";: PRINT custinforec.sstate
  423. LOCATE 16, 1: PRINT "customer Zip          ";: PRINT custinforec.szip
  424. LOCATE 17, 1: PRINT "Customer Phone Number ";
  425. PRINT LEFT$(custinforec.sphone, 3) + "/"; MID$(custinforec.sphone, 4, 3) + "/"; RIGHT$(custinforec.sphone, 4)
  426. REM ********************************************************************
  427.  
  428. s1:
  429. saction = "Enter Customer ID X to Exit "
  430. ib = 10
  431. ilow = 1
  432. ihigh = 999999999
  433. iflag1 = 0
  434. 'IF iflag2 = 1 THEN
  435. '        GOSUB clearprompt
  436. 'GOSUB salphainput
  437. 'ELSE
  438. '        GOSUB clearprompt
  439. 'GOSUB salphainput
  440. 'END IF
  441. 'IF sr = "X" THEN RETURN
  442. 'IF sr = "" OR sr = CHR$(13) GOTO s2
  443. searchid = sr
  444. GOSUB dupidsearch
  445.  
  446. 'IF iflag3 = 1 THEN
  447. 'GOSUB custinforec_null
  448. 'iflag3 = 0
  449. 'GOTO s1
  450. 'END IF
  451. 'custinforec.id = sr: GOSUB s0: GOTO s2
  452.         CASE CHR$(88): RETURN 'X
  453.         CASE CHR$(45): GOTO inv6 '-
  454.         CASE CHR$(13): GOTO s1 ' enter key or ""
  455.         CASE ELSE
  456.                 GOSUB custinforec_null
  457.                 custinforec.id = sr
  458.                 GOSUB inv0
  459.                 GOTO s2
  460.  
  461.  
  462.  
  463.  
  464. REM ********************************************************************
  465.  
  466. s2:
  467. saction = "Enter First Name X to Exit - To Backup "
  468. ib = 25
  469. ilow = 99
  470. ihigh = 99
  471. iflag1 = 0
  472. IF iflag2 = 1 THEN
  473.         GOSUB clearprompt
  474.         GOSUB salphainput
  475.         GOSUB clearprompt
  476.         GOSUB salphainput
  477. IF sr = "-" THEN GOTO s1
  478.  
  479. IF sr = "X" THEN RETURN
  480. IF sr = "" OR sr = CHR$(13) GOTO s3
  481. custinforec.sfirst_name = sr: GOSUB s0
  482. REM ***************************************************************************
  483.  
  484. s3:
  485. saction = "Enter Last Name X to Exit - To Back up "
  486. ib = 25
  487. ilow = 99
  488. ihigh = 99
  489. iflag1 = 0
  490. IF iflag2 = 1 THEN
  491.         GOSUB clearprompt
  492.         GOSUB salphainput
  493.         GOSUB clearprompt
  494.         GOSUB salphainput
  495. IF sr = "-" THEN GOTO s2
  496. IF sr = "X" THEN RETURN
  497. IF sr = "" OR sr = CHR$(13) GOTO s4
  498. custinforec.slast_name = sr: GOSUB s0
  499. REM ***************************************************************************
  500.  
  501. s4:
  502. saction = "Enter Address X to Exit - To Back up "
  503. ib = 30
  504. ilow = 99
  505. ihigh = 99
  506. iflag1 = 0
  507. IF iflag2 = 1 THEN
  508.         GOSUB clearprompt
  509.         GOSUB salphainput
  510.         GOSUB clearprompt
  511.         GOSUB salphainput
  512.  
  513. IF sr = "-" THEN GOTO s3
  514. IF sr = "X" THEN RETURN
  515. IF sr = "" OR sr = CHR$(13) GOTO s5
  516. custinforec.saddress = sr: GOSUB s0
  517. REM ***************************************************************************
  518.  
  519. s5:
  520. saction = "Enter City Name X to Exit - To Back up "
  521. ib = 25
  522. ilow = 99
  523. ihigh = 99
  524. iflag1 = 0
  525. IF iflag2 = 1 THEN
  526.         GOSUB clearprompt
  527.         GOSUB salphainput
  528.         GOSUB clearprompt
  529.         GOSUB salphainput
  530. IF sr = "-" THEN GOTO s4
  531. IF sr = "X" THEN RETURN
  532. IF sr = "" OR sr = CHR$(13) GOTO s6
  533. custinforec.scity = sr: GOSUB s0
  534. REM ***************************************************************************
  535.  
  536. s6:
  537. saction = "Enter State X to Exit - To Back up "
  538. ib = 2
  539. ilow = 99
  540. ihigh = 99
  541. iflag1 = 0
  542. IF iflag2 = 1 THEN
  543.         GOSUB clearprompt
  544.         GOSUB salphainput
  545.         GOSUB clearprompt
  546.         GOSUB salphainput
  547. IF sr = "-" THEN GOTO s5
  548. IF sr = "X" THEN RETURN
  549. IF sr = "" OR sr = CHR$(13) GOTO s7
  550. custinforec.sstate = sr: GOSUB s0
  551. REM ***************************************************************************
  552.  
  553. s7:
  554. saction = "Enter Zip Code Name X to Exit - To Back up "
  555. ib = 5
  556. ilow = 99
  557. ihigh = 99
  558. iflag1 = 0
  559. IF iflag2 = 1 THEN
  560.         GOSUB clearprompt
  561.         GOSUB salphainput
  562.         GOSUB clearprompt
  563.         GOSUB salphainput
  564. IF sr = "-" THEN GOTO s6
  565. IF sr = "X" THEN RETURN
  566. custinforec.szip = sr: GOSUB s0
  567. REM ***************************************************************************
  568.  
  569. s8:
  570. saction = "Enter Phone Number X to Exit - To Back up "
  571. ib = 10
  572. ilow = 99
  573. ihigh = 99
  574. iflag1 = 0
  575. IF iflag2 = 1 THEN
  576.         GOSUB clearprompt
  577.         GOSUB salphainput
  578.         GOSUB clearprompt
  579.         GOSUB salphainput
  580.  
  581. IF sr = "-" THEN GOTO s7
  582. IF sr = "X" THEN RETURN
  583. custinforec.sphone = sr: GOSUB s0
  584. REM ***************************************************************************
  585.  
  586. REM ***************************************************************************
  587. REM **** ask if you want to put data to record ********************************
  588. REM ***************************************************************************
  589. puttorecord:
  590. saction = "Commit Data to File Y/N"
  591. ib = 1
  592. ilow = 99
  593. ihigh = 99
  594. iflag1 = 0
  595. GOSUB clearprompt
  596. GOSUB salphainput
  597. IF sr = "Y" THEN GOSUB insertrec
  598. IF sr = "N" THEN RETURN
  599. REM ***************************************************************************
  600.  
  601.  
  602. REM ***************************************************************************
  603. REM **** set custinforrec variables to zero or null ***************************
  604. REM ***************************************************************************
  605. custinforec_null:
  606. custinforec.id = null
  607. custinforec.sfirst_name = null
  608. custinforec.slast_name = null
  609. custinforec.saddress = null
  610. custinforec.scity = null
  611. custinforec.sstate = null
  612. custinforec.szip = null
  613. custinforec.sphone = null
  614. REM ***************************************************************************
  615.  
  616. REM ***************************************************************************
  617. REM **** set inventoryrec variables to zero or null ***************************
  618. REM ***************************************************************************
  619. inventoryrec_null:
  620. sinventory.id = null
  621. sinventory.sdesc = null
  622. sinventory.sdate_bought = null
  623. sinventory.sdate_sold = null
  624. sinventory.fcost = null
  625. sinventory.fretail = null
  626. sinventory.ssize = null
  627. sinventory.ssold = null
  628. REM ***************************************************************************
  629.  
  630. REM ***************************************************************************
  631. REM **** opens random files ***************************************************
  632. REM ***************************************************************************
  633. randomfiles:
  634. OPEN "jbradal.db" FOR RANDOM AS #1 LEN = lcustreclen
  635. OPEN "system.db" FOR RANDOM AS #5 LEN = lsystemreclen
  636. OPEN "inventory.db" FOR RANDOM AS #2 LEN = linventorylen
  637. zcustrecnum = LOF(1) / lcustreclen
  638. zenventorynum = LOF(2) / lenventorylen
  639. zsystemrecnum = LOF(5) / lsystemreclen
  640.  
  641. REM ***************************************************************************
  642.  
  643. REM ***************************************************************************
  644. REM **** inserts record into random file **************************************
  645. REM ***************************************************************************
  646. insertrec:
  647. SELECT CASE ifilenum
  648.         CASE 1
  649.                 zcustrecnum = zcustrecnum + 1
  650.                 PUT #1, zcustrecnum, custinforec
  651.         CASE 3
  652.                 zenventorynum = zenventorynum + 1
  653.                 PUT #3, zenventorynum, sinventoryrec
  654. REM ***************************************************************************
  655.  
  656. REM ***************************************************************************
  657. REM **** custinforec duplicate id search **************************************
  658. REM ***************************************************************************
  659. dupidsearch:
  660. zx = 1
  661. iflag3 = 0
  662. SELECT CASE ifilenum
  663.         CASE 1
  664.                 DO
  665.  
  666.                         GET #1, zx, custinforec
  667.                         zx = zx + 1
  668.                         IF LTRIM$(RTRIM$(sr)) = LTRIM$(RTRIM$(custinforec.id)) THEN
  669.                                 BEEP
  670.                                 iflag3 = 1
  671.                                 EXIT DO
  672.                         END IF
  673.                 LOOP UNTIL zx > zcustrecnum
  674.                 IF zx > zcustrecnum THEN GOSUB custinforec_null
  675.         CASE 3
  676.                 DO
  677.  
  678.                         GET #1, zx, senventoryrec
  679.                         zx = zx + 1
  680.                         IF LTRIM$(RTRIM$(sr)) = LTRIM$(RTRIM$(senventory.id)) THEN
  681.                                 BEEP
  682.                                 iflag3 = 1
  683.                                 EXIT DO
  684.                         END IF
  685.                 LOOP UNTIL zx > zenventorynum
  686.                 IF zx > zenventorynum THEN GOSUB inventoryrec_null
  687. REM **************************************************************************
  688. REM **** shell for notepad for description files by inventory number *********
  689. REM **************************************************************************
  690. descinput:
  691. ifileexists = _FILEEXISTS(sdesc + ".txt")
  692. IF ifileexists = -1 THEN
  693.         SHELL "wordpad " + CHR$(34) + sdesc + ".txt" + CHR$(34)
  694.         OPEN sdesc + ".txt" FOR OUTPUT AS #6
  695.         PRINT #6, "Type in your stuff. Save the file and exit."
  696.         CLOSE #6
  697.         SHELL "wordpad " + CHR$(34) + sdesc + ".txt" + CHR$(34)
  698. REM **************************************************************************
  699.  
  700. REM ***************************************************************************
  701. REM **** main modual **********************************************************
  702. REM ***************************************************************************
  703. main:
  704. GOSUB randomfiles
  705. SCREEN _NEWIMAGE(640, 400, 32)
  706. COLOR LightCyan, MidnightBlue
  707. iflag2 = 0
  708. iflag3 = 0
  709. 'SCREEN 12
  710. IF se = "X" THEN
  711.         CLOSE
  712.         END
  713. mainloop:
  714. GOSUB menuloop:
  715. IF saction = "X" THEN
  716.         CLOSE
  717.         END
  718. IF sr = "1" THEN
  719.         ifilenum = 1
  720.         GOSUB custinforec_null
  721.         GOSUB s1
  722.         GOTO mainloop
  723. 'IF sr = "2" THEN
  724. 'ifilenum = 2
  725. 'GOSUB inventoryrec_null
  726. 'GOSUB inv1
  727. 'GOTO mainloop
  728. 'END IF
  729.  
  730. IF sr = "3" THEN
  731.         ifilenum = 2
  732.         GOSUB inventoryrec_null
  733.         GOSUB inv1
  734.         GOTO mainloop
  735. 'IF sr = "4" THEN
  736. '        ifilenum = 2
  737. 'GOSUB inventoryrec_null
  738. 'GOSUB inv1
  739. 'GOTO mainloop
  740. 'END IF
  741.  
  742.  
  743. REM **************************************************************************
  744.  
  745. REM **************************************************************************
  746. REM **** delay loop **********************************************************
  747. REM **************************************************************************
  748. SUB Delay (dlay!)
  749.         start! = TIMER
  750.         DO WHILE start! + dlay! >= TIMER
  751.                 IF start! > TIMER THEN start! = start! - 86400
  752.         LOOP
  753.  
  754.  

FellippeHeitor

  • Guest
Re: case statement problem
« Reply #6 on: October 03, 2020, 08:01:04 pm »
This is your problem:
Code: QB64: [Select]
  1. LINE INPUT sr: sr = UCASE$(sr)

LINE INPUT handles ENTER so the user can finish the input session. You won't ever capture CHR$(13) with LINE INPUT.

It will work with INPUT though.

I take it back. You will have to roll your own input routine using INKEY$.
« Last Edit: October 03, 2020, 08:03:51 pm by FellippeHeitor »

Offline badger

  • Forum Regular
  • Posts: 148
    • View Profile
Re: case statement problem
« Reply #7 on: October 03, 2020, 08:04:34 pm »
Hello

hmmm never knew that i always changed it to something else. so i will have to rethink some things


Thank You very very much this answers a lot of problems.   Sorry it it looks like spaghetti code

Badger