Ooops
November 28, 2020, 01:06:44 PM

Author Topic: [bb] Examples of the parser by add [ 1+ years ago ]  (Read 488 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Examples of the parser by add [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : Examples of the parser
Author : add
Posted : 1+ years ago

Description : Shows how the parser function works

Code :
Code: BlitzBasic
  1. ; you need to define these variables inorder to use the parser functions!!!!
  2. ; Define Globals Used
  3. Type parsereturn
  4.         Field word$
  5.         Field num
  6.         Field real#
  7. End Type
  8. Global back.parsereturn=New parsereturn
  9. Global RealReturn#=0
  10. ; End of globals
  11.  
  12. Include "ParserFunction.bb"
  13.  
  14.  
  15. Graphics 640,480
  16. Cls
  17. limit$=" ,=[]" ;limiters used in these examples
  18. .start
  19. Read dis$
  20. If dis$="###" Then End
  21. Read example$
  22. Color 255,100,0
  23. Print dis$
  24. Color 100,255,100
  25. Print example$
  26.  
  27. If Instr(example$,"longseperator",1)>0 Then
  28.         example$=Replace$(example$,"longseperator",",")
  29.         Color 255,100,0:Print "Converts to"
  30.         Color 100,255,100:Print example$
  31. End If
  32.  
  33. result=parse(example$,limit$)
  34. Color 0,200,200
  35. Print "Parts of example="+result
  36. For back.parsereturn=Each parsereturn
  37.         Print "word="+backword$+" number="+back
  38. um+" real="+back
  39. eal
  40. Next
  41. Print
  42. Print
  43. WaitKey()
  44. Goto start
  45.  
  46.  
  47.  
  48. Data "Examples of Using the Parser","Mynumber=-445.2"
  49. Data "The Val function supports fraction,negative and exponents","-4,-5.003,0.909,0.0000000001,7.4e-2,9.00000e12"
  50. Data "Numbers burried in words are extracted","The-39.4steps"
  51. Data "Complex parsing","Type32c=2 rgb=[45,78,128] pos=[0.14,-12,-2.2e-016] Hat[21]=90"
  52. Data "Multiple seperators are ignored","fournumbers=5,6,,8 ,==[12]"
  53. Data "Remember that you can use 'replace' to convert multicharacter seperators","14longseperator16,7,12   longseperator13"
  54. Data "###"


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal